Ejemplo n.º 1
0
//=====================================================================
int main(int argc, char **argv) {
	debugFg=DEBUG_LOG|DEBUG_PRINT; clearDeb();
//deb(0);
	initSG(argc, argv);
//	if(debugFg) {debugFg=DEBUG_LOG|DEBUG_PRINT; clearDeb(); }
	Preparator();

	Smoother();
	fflush(stdout);
	fclose(stdout);
	return 0;
}
Ejemplo n.º 2
0
//******************************************************************************
//Name:  SetInterpTensor                                                       *
//                                                                             *
//Purpose:  set the grid tensors based on interpolation from a tensor at an    *
//          arbitrary position                                                 *
//                                                                             *
//Takes: pointer to the position array and address of the rval tensor          *
//******************************************************************************
void field::SetInterpTensor(double *position, const tensor &rval)
{
 int step;
 int i, j, k;
 int scaled_pos[3];
 int grid_pos[3];
 double pos[3];
 tensor dummy, temp;


 step = 1;
 out_of_range = FALSE;

//Set the reference position
  for(i = 0; i < 3; i++) reference_pos[i] = position[i];

//Get the double indices for the scaled position
  GetIndices(reference_pos, scaled_pos);

//step through the floor steping
 while( !out_of_range )
 {
	 for( i = 0; i < 2; i++)
	 {
		 for( j = 0; j < 2; j++)
		 {
			 for( k = 0; k < 2; k++)
			 {
			   grid_pos[0] = (int)floor( scaled_pos[0] + i * step );
			   grid_pos[1] = (int)floor( scaled_pos[1] + j * step );
            grid_pos[2] = (int)floor( scaled_pos[2] + k * step );
            GetPosition(grid_pos, pos);
            dummy <= GetTensor(pos);
            temp <= rval;
			   temp.ScalarMult(Smoother(PARTICLE_SMOOTHING));
			   dummy <= dummy + temp;
			   if( out_of_range ) break;
			 }
		 }
	 }
//temp hack to keep the interpolation to within one cell
 out_of_range = TRUE;
 }

}
Ejemplo n.º 3
0
//******************************************************************************
//Name:  matterVar                                                             *
//                                                                             *
//Purpose:  returns the value of \frac{ \partial L}{\partial g^{ab} }          *
//                                                                             *
//Takes: an int telling what stage of the RK and 3 ints telling the grid       *
//       location                                                              *
//******************************************************************************
tensor Particle::matterVar(int stage, int i, int j, int k)
{

	//update the particle data if first time called
	if( stage != last_stage )
	{
		update_inv_g(stage);
      ADM_decomposition(stage);
      update_u_dns(stage);
      update_u_ups(stage);
      RK_step(stage);
      last_stage = stage;
   }

	//now return T_{\mu\nu}
   indices[0] = i;
   indices[1] = j;
   indices[2] = k;
   grid_pos <= GetPosition(indices);
   T_temp4x4 <= 0.0*T_temp4x4;
	for ( c1 = 0; c1 < numParticles; c1++)
	{
		pos_diff_tensor <= grid_pos - pos[stage][c1];
      y = pos_diff_tensor.Vmag() / smoothing_length;
      W = Smoother(CWM_SMOOTHER);
      //only calculate the matter variation term if within smoothing radius
      if( fabs(W) > 0 + SMOOTHING_TOL)
       {
 		   factor  = -0.5 * masses[c1] / u0_up[stage][c1];
        	T_temp4x4 <= T_temp4x4 + factor * four_U_dn[stage][c1]
                                         * four_U_dn[stage][c1]
                                         * W;
       }
	}

    //Currently stubbed out to return the identity matrix (more or less)
    return T_temp4x4;
Ejemplo n.º 4
0
//******************************************************************************
//Name:  GetInterpTensor                                                       *
//                                                                             *
//Purpose:  get the interpolated tensor at an arbitrary position               *
//                                                                             *
//Takes: pointer to the position array                                         *
//******************************************************************************
tensor field::GetInterpTensor(double *position)
{
 int i, j, k, m, n;
 double scaled_pos[3];
 int grid_pos[3];
 double W;

 if( is_series_set == FALSE )
  error("GetInterpTensor error:","series not set");

 //initialize member data tensors
 sum_Wm   <= 0.0*sum_Wm;
 sum_a2   <= 0.0*sum_a2;
 sum_da1  <= 0.0*sum_da1;
 d_sum_a2 <= 0.0*d_sum_a2;

 out_of_range = FALSE;

//Set the reference position
  for(i = 0; i < 3; i++) reference_pos[i] = position[i];

//Get the real indices for the scaled position
  GetIndices(reference_pos, scaled_pos);

//Create the return tensor and set it to zero
 ret_dummy <= 0.0*GetTensor(reference_pos);

//Reset the normalization
  normalization = 0.0;

//step through the floor steping
  for( i = grid_lower_bound; i < grid_upper_bound; i++)
   {
	 for( j = grid_lower_bound; j < grid_upper_bound; j++)
	  {
	   for( k = grid_lower_bound; k < grid_upper_bound; k++)
		 {
         //Get the indices of the lowest corner of the cell
			grid_pos[0] = (int)floor( scaled_pos[0] + i );
			grid_pos[1] = (int)floor( scaled_pos[1] + j );
         grid_pos[2] = (int)floor( scaled_pos[2] + k );

         //find the position this grid point
         GetPosition(grid_pos,current_pos);

         //form the difference array and its magnitude (for use by smoother)
         //and the difference position
         y = 0;
         for( m = 0; m < 3; m++ )
			 {
           pos_diff[m] = reference_pos[m] - current_pos[m];
           y += pos_diff[m]*pos_diff[m];
           d.Set(pos_diff[m], m);
			 }
         y = sqrt(y)/smoothing_length;
         if( y > 1.0 + SMOOTHING_TOL ) continue;

         //get all of the tensors requested by the order
         for( m = 0; m <= series.order; m++)
           tmp[m] <= series.list[m]->GetTensor(grid_pos);

         //get the (psuedo) scalar smoothing value
         W = Smoother(CWM_SMOOTHER);

			//if the field is basic (i.e. not a derivative of
			//another field)
			if( is_deriv_field == FALSE )
			 {
           if( series.order == 2 )
            {
              m = tmp[2].NumIndices() - 1;
              tmp[2] <= 0.5 *( tmp[2].Contract(d,m,0) ).Contract(d,m-1,0);
            }
           if( series.order == 1 || series.order == 2 )
            {
              m = tmp[1].NumIndices() - 1;
              tmp[1] <= tmp[1].Contract(d,m,0);
            }
           for( m = 0; m <= series.order; m++)
			      ret_dummy <= ret_dummy + W*tmp[m];
			 }


			//if the field is not basic (i.e. is a derivative of
			//another field
         if( is_deriv_field == TRUE )
			 {
			   //if the field is independent (i.e. its smoothing is not
			   //a derivative of the smoohting of its basic field
			   if( is_dep_field == FALSE )
			    {
				  temp0 <= 0.0*tmp[0];
				  if( series.order == 1 )
				   {
				    m = tmp[1].NumIndices() - 1;
				    temp0 <= tmp[1].Contract(d,m,0);
				   }
				  ret_dummy <= ret_dummy + W*(tmp[0] + temp0);
			    }
			   //if the field is dependent (i.e. it smoothing is
			   //based on the derivative of the smoothing of its basic field
			   else
			    {
				  temp0 <= 0.0*tmp[0];
              if( series.order == 2 )
				   {
                 m = tmp[2].NumIndices() - 1;
                 //form the 1/2 * t,ij*(z-x)_i*(z-x)_j term if neccessary
                 temp0 <= 0.5*( tmp[2].Contract(d,m,0) ).Contract(d,m-1,0);
				   }

				  temp1 <= 0.0*tmp[0];
				  if( series.order ==1 || series.order == 2 )
				   {
                 n = tmp[1].NumIndices() - 1;
				     //form the t,i*(z-x)_i term if neccessary
					  temp1 <= tmp[1].Contract(d,n,0);

					  //form the t,i + t,ij*(z-x)_j
                 temp2 <= 0.0*tmp[1];
                 if( series.order == 2 ) temp2 <=  tmp[2].Contract(d,m,0);
                 sum_da1 <= sum_da1 + W*(tmp[1] + temp2);
 				   }
				  //form the t + t,i*(z-x)_i + 1/2 * t,ij*(z-x)_i*(z-x)_j
              a2 <= tmp[0] + temp1 + temp0;

              sum_a2 <=  sum_a2 + W*a2;

              //get the derivative of the smoothing
              Wm <= Smoother_Deriv(CWM_SMOOTHER);

              //keep running sum
              sum_Wm <= sum_Wm + Wm;

              //form the term labeled dN_D_2 in the MathCAD
              d_sum_a2 <= d_sum_a2 + a2 * Wm;
			    }
          }
	    }
	  }
   }

//Normalize the interpolated tensor
  if( is_dep_field == FALSE ) ret_dummy <= (1.0/normalization)*ret_dummy;
  if( is_dep_field == TRUE  )
  {
    ret_dummy <= normalization * ( sum_da1 + d_sum_a2 ) - sum_a2 * sum_Wm;
    ret_dummy <= 1.0/(normalization*normalization) * ret_dummy;
  }

 return ret_dummy;

}
Ejemplo n.º 5
0
//******************************************************************************
//Name:  GetInterpTensor                                                       *
//                                                                             *
//Purpose:  get the interpolated tensor at an arbitrary position               *
//                                                                             *
//Takes: pointer to the position array                                         *
//******************************************************************************
tensor Particle::GetInterpTensor(double *position)
{
 int i, j, k, m, n;
 double scaled_pos[3];
 int grid_pos[3];
 double W;

 //initialize member data tensors
 sum_Wm   <= 0.0*sum_Wm;

//Set the reference position
  for(i = 0; i < 3; i++) reference_pos[i] = position[i];

//Get the real indices for the scaled position
  GetIndices(reference_pos, scaled_pos);

//Create the return tensor and set it to zero
// ret_dummy <= 0.0*GetTensor(reference_pos);

//Reset the normalization
  normalization = 0.0;

//step through the floor steping
  for( i = grid_lower_bound; i < grid_upper_bound; i++)
   {
	 for( j = grid_lower_bound; j < grid_upper_bound; j++)
	  {
	   for( k = grid_lower_bound; k < grid_upper_bound; k++)
		 {
         //Get the indices of the lowest corner of the cell
			grid_pos[0] = (int)floor( scaled_pos[0] + i );
			grid_pos[1] = (int)floor( scaled_pos[1] + j );
         grid_pos[2] = (int)floor( scaled_pos[2] + k );

         //find the position this grid point
         GetPosition(grid_pos,current_pos);

         //form the difference array and its magnitude (for use by smoother)
         //and the difference position
         y = 0;
         for( m = 0; m < 3; m++ )
			 {
           pos_diff[m] = reference_pos[m] - current_pos[m];
           y += pos_diff[m]*pos_diff[m];
           d.Set(pos_diff[m], m);
			 }
         y = sqrt(y)/smoothing_length;
         if( y > 1.0 + SMOOTHING_TOL ) continue;

         //get the (psuedo) scalar smoothing value
         W = Smoother(CWM_SMOOTHER);

         //get the derivative of the smoothing
         Smoother_Deriv(CWM_SMOOTHER);

         //keep running sum
         sum_Wm <= sum_Wm + Wm;
	    }
	  }
   }

//Normalize the interpolated tensor

 return ret_dummy;
Ejemplo n.º 6
0
//******************************************************************************
//Name:  update_inv_g                                                          *
//                                                                             *
//Purpose:  scans over the relevant regions of the grid and gets a smoothed    *
//          version of the inverse metric at the particle                      *
//                                                                             *
//Takes:                                                                       *
//******************************************************************************
void Particle::update_inv_g(int stage)
{
 int i, j, k, m, n;
 double scaled_pos[3];
 int grid_pos[3];
 double position[3];
 double W;

//loop over the particles and determine the smoothed inverse metric
//for each one
 for( c1 = 0; c1 < numParticles; c1++)
 {
  //Set the reference position using the particle's position
  reference_pos[0] = pos[stage][c1].Val(0);
  reference_pos[1] = pos[stage][c1].Val(1);
  reference_pos[2] = pos[stage][c1].Val(2);

  //Get the real indices for the scaled position
  GetIndices(reference_pos, scaled_pos);

  //Reset the normalization
  normalization = 0.0;

  //initialize member data tensors
  sum_Wm      <= 0.0*sum_Wm;
  T_temp4x4   <= 0.0*T_temp4x4;
  T_temp4x4x3 <= 0.0*T_temp4x4x3;

  //step through the floor steping
  for( i = grid_lower_bound; i < grid_upper_bound; i++)
   {
	 for( j = grid_lower_bound; j < grid_upper_bound; j++)
	  {
	   for( k = grid_lower_bound; k < grid_upper_bound; k++)
		 {
         //Get the indices of the lowest corner of the cell
			grid_pos[0] = (int)floor( scaled_pos[0] + i );
			grid_pos[1] = (int)floor( scaled_pos[1] + j );
         grid_pos[2] = (int)floor( scaled_pos[2] + k );

         //find the metric at the particular grid point
         inv_g_temp <= my_field_partner->GetInvG(stage,
                                                 grid_pos[0],
                                                 grid_pos[1],
                                                 grid_pos[2]);

         //find the position this grid point
         GetPosition(grid_pos,current_pos);

         //form the difference array and its magnitude (for use by smoother)
         //and the difference position
         y = 0;
         for( m = 0; m < 3; m++ )
			 {
           pos_diff[m] = reference_pos[m] - current_pos[m];
           y += pos_diff[m]*pos_diff[m];
			 }
         y = sqrt(y)/smoothing_length;
         if( y > 1.0 + SMOOTHING_TOL ) continue;

         //get the (psuedo) scalar smoothing value
         W = Smoother(CWM_SMOOTHER);

         //get the derivative of the smoothing
         Smoother_Deriv(CWM_SMOOTHER);

         //keep running sum
         sum_Wm      <= sum_Wm + Wm;
 	      T_temp4x4   <= T_temp4x4 + W*inv_g_temp;
         T_temp4x4x3 <= T_temp4x4x3 + inv_g_temp*Wm;

	    }
	  }
   }

  //Normalize the interpolated tensor and pack arrays
  inv_g[stage][c1]   <= T_temp4x4;
  d_inv_g[stage][c1] <= T_temp4x4x3;
  norm[stage][c1]     = normalization;
  d_norm[stage][c1]  <= sum_Wm;

 }