static int main_v()
{
	local_vars();
	typededuction_in_functions();
	accepting_rvalues_and_lvalues();
	forwarding();

	std::cin.get();
}
Beispiel #2
0
/* Routine to get the relevant values at each step 'r' along the ray (moving out), 
 *   and then step the ray to the next r value based on the local smoothing length 
 */
void line_of_sight(Ray_struct *R)
{
	/* Handy values throughout the routine */
	float costheta,sintheta,cosphi,sinphi,r0,dr0,x0,y0,z0,x,y,z,x_max,y_max,z_max;
	float x_min,y_min,z_min,dr_min;
	//float *rtemp, *drtemp, *r, *dr;
	float *rtemp, *drtemp, *dr;
	int n_steps,n_steps_max,r_i;
	//LOCALVAL local_temp, *local_quantities;
	LOCALVAL local_temp;
	/* This subroutine is now independent of what quantities are in LOCALVAL - 
	    if you add a quantity, you just need to edit lineofsight.h & localvalues.c */
	
	costheta = cos(R->theta);
	sintheta = sin(R->theta);
	cosphi = cos(R->phi);
	sinphi = sin(R->phi);

	/* The initial position of the ray should be set from the calling routine */
	/*!!*/
	x0 = R->pos[0];
	y0 = R->pos[1];
	z0 = R->pos[2];

	x_min = -1.0 * (float)MAX_DISTANCE_FROM0;
	x_max = 1.0 * (float)MAX_DISTANCE_FROM0;
	y_min = x_min;
	y_max = x_max;
	z_min = x_min;
	z_max = x_max;
	n_steps_max = (int)LINE_NMAX;
	dr_min = abs(x_max-x_min) / (200.0 * (float)n_steps_max);

    //local_quantities = (LOCALVAL *) malloc (n_steps_max*sizeof(LOCALVAL));
    //r = (float *) malloc (n_steps_max*sizeof(float));    
    	
	r0 = 0.0;
	x = x0; y = y0; z = z0;
	n_steps = 0;
	
	/* (could easily switch this to a criteria based on an asymptoting density, but 
		for a large box it's not really an issue) */
//printf("Load quantities along ray\n"); fflush(stdout);
	while (x>x_min && x<x_max && y>y_min && y<y_max 
	    && z>z_min && z<z_max && n_steps<n_steps_max) {
	  r_along_ray[n_steps] = r0;
		
//printf("into local_vars, n_steps= %d\n",n_steps); fflush(stdout);
	  local_vars(x,y,z,&local_quantities[n_steps]);
//printf("OK, back after the first step, where to next?\n"); fflush(stdout);
	  dr0 = (float)FRACTIONAL_STEPSIZE*local_quantities[n_steps].h;	/* Set the spacing to the local smoothing length */
//printf("dr0= %g\n",dr0); fflush(stdout);
	  if (dr0 < dr_min) dr0 = dr_min;					/* Ensure you can reach the box edge with the ray */
      
	  r0 += dr0;
	  x = x0 + r0 * R->n_hat[0];
	  y = y0 + r0 * R->n_hat[1];
	  z = z0 + r0 * R->n_hat[2];	
	  n_steps += 1;
	}
	if (n_steps < 1) n_steps = 1;
//printf("Done with ray \n"); fflush(stdout);

	R->N_steps = n_steps;
    R->r = (float *) malloc (n_steps*sizeof(float));
    R->local = (LOCALVAL *) malloc (n_steps*sizeof(LOCALVAL));

    for (r_i=0; r_i<n_steps; r_i++) R->r[r_i] = r_along_ray[r_i];
    for (r_i=0; r_i<n_steps; r_i++) R->local[r_i] = local_quantities[r_i];

    
    //for (r_i=0; r_i<n_steps; r_i++) printf("r,rho = %e %e %e %e \n",R->r[r_i],R->local[r_i].rho,R->local[r_i].h,local_quantities[r_i].rho);
    //for (r_i=0; r_i<n_steps; r_i++) printf("r,rho,Temp = %e %e %e (%e) \n",R->r[r_i],R->local[r_i].rho,R->local[r_i].T,local_quantities[r_i].T);
	/* need to de-construct these two quantities */
	//free(local_quantities);
	//free(r);
}