Esempio n. 1
0
//return Pressure, Velocity, Density
Real4 HalfProblemShockWave(Real PressureOut, Real VelocityOut, Real DensityOut,
		Real GammaOut, Real SoundOut, Real PressureContact,
		Real VelocityContact) {
	Real WaveSpeed;
	Real4 Result;
	Real DPressure = PressureContact / PressureOut;
	if (fabs(1 - DPressure) < Epsilon)
		WaveSpeed = VelocityOut - SoundOut;
	else {
		Real DGamma = (GammaOut - 1) / (2 * GammaOut);
		WaveSpeed = VelocityOut - DGamma * SoundOut * (1 - DPressure) / (1
				- pow(DPressure, DGamma));
	};
	if (WaveSpeed >= 0) {
		Pressure(Result) = PressureOut;
		Velocity(Result) = VelocityOut;
		Density(Result) = DensityOut;
	} else {
		Pressure(Result) = PressureContact;
		Velocity(Result) = VelocityContact;
		Density(Result) = DensityOut * ((GammaOut + 1) * PressureContact
				+ (GammaOut - 1) * PressureOut) / ((GammaOut - 1)
				* PressureContact + (GammaOut + 1) * PressureOut);
	};
	return Result;
}
Esempio n. 2
0
//return Pressure, Velocity, Density
Real4 HalfProblemDepressionWave(Real PressureOut, Real VelocityOut,
		Real DensityOut, Real GammaOut, Real SoundOut, Real PressureContact,
		Real VelocityContact) {
	Real4 Result;
	Real WaveLeftBoundarySpeed = VelocityOut - SoundOut,
			WaveRightBoundarySpeed = VelocityContact * Real(0.5) * (1
					+ GammaOut) - VelocityOut * Real(0.5) * (GammaOut - 1)
					- SoundOut;
	if (WaveLeftBoundarySpeed > 0) {
		Pressure(Result) = PressureOut;
		Velocity(Result) = VelocityOut;
		Density(Result) = DensityOut;
	} else {
		Real SoundContact = SoundOut + Real(0.5) * (GammaOut - 1)
				* (VelocityOut - VelocityContact);
		Real DensityContact = GammaOut * PressureContact / Sqr(SoundContact);
		if (WaveRightBoundarySpeed < 0) {
			Velocity(Result) = VelocityContact;
			Pressure(Result) = PressureContact;
			Density(Result) = DensityContact;
		} else {
			Real Ratio = WaveLeftBoundarySpeed / (WaveLeftBoundarySpeed
					- WaveRightBoundarySpeed);
			Pressure(Result) = PressureOut + (PressureContact - PressureOut)
					* Ratio;
			Density(Result) = DensityOut + (DensityContact - DensityOut)
					* Ratio;
			Velocity(Result) = VelocityOut + (VelocityContact - VelocityOut)
					* Ratio;
		};
	};
	return Result;
}
void XZHydrostatic_Pressure<EvalT, Traits>::
evaluateFields(typename Traits::EvalData workset)
{
  const Eta<EvalT> &E = Eta<EvalT>::self();

  for (int cell=0; cell < workset.numCells; ++cell) {
    for (int node=0; node < numNodes; ++node) {
/*
    	  if(cell == 0 && node == 0){
    		  std::cout << "Etatop = " << E.etatop() <<"\n";
    	  for (int level=0; level < numLevels; ++level) {
    		std::cout << "Here we are level, eta " << level << " " << E.eta(level) << "\n";
    	  }
    	  for (int level=0; level < numLevels; ++level) {
    		std::cout << "Here we are A, B " << level << " " << E.A(level) << "  " << E.B(level) << "\n";
    	  }
    	  }
*/
      for (int level=0; level < numLevels; ++level) {
        Pressure(cell,node,level) = E.A(level)*E.p0() + E.B(level)*Ps(cell,node);
        //std::cout <<"In Pressure "<< " Ps" << Ps(cell,node) <<" workset time" << workset.current_time << "\n";

      }
      //here instead of computing eta, A, B, and pressure at level interfaces directly,
      //averages are used to approx. pressure at level interfaces.
      for (int level=0; level < numLevels; ++level) {
        const ScalarT pm   = level             ? 0.5*( Pressure(cell,node,level) + Pressure(cell,node,level-1) ) : E.ptop();
        const ScalarT pp   = level<numLevels-1 ? 0.5*( Pressure(cell,node,level) + Pressure(cell,node,level+1) ) : ScalarT(Ps(cell,node));
        Pi(cell,node,level) = (pp - pm) /E.delta(level);
      }
    }
  }
}
Esempio n. 4
0
//return Pressure, Velocity, Density, Energy
Real4 CaseNotVacuum(Real PressureLeft, Real VelocityLeft, Real DensityLeft,
		Real GammaLeft, Real SoundLeft, Real PressureRight, Real VelocityRight,
		Real DensityRight, Real GammaRight, Real SoundRight) {
	Real2 Contact = NewtonVelocity(PressureLeft, VelocityLeft, DensityLeft,
			GammaLeft, SoundLeft, PressureRight, VelocityRight, DensityRight,
			GammaRight, SoundRight);
	if (Velocity(Contact) > 0)
		return SolveHalfProblem(PressureLeft, VelocityLeft, DensityLeft,
				GammaLeft, SoundLeft, Pressure(Contact), Velocity(Contact),
				true);
	else
		return SolveHalfProblem(PressureRight, VelocityRight, DensityRight,
				GammaRight, SoundRight, Pressure(Contact), Velocity(Contact),
				false);
}
Esempio n. 5
0
void CalcDensity(particle_t *SPH){
	#pragma omp parallel for
	for(int i = 0 ; i < N_SPHP ; ++ i){
		SPH[i].div_v = 0;
		SPH[i].omega = 0;
		SPH[i].rot_v = vec3<double>(0, 0, 0);
		SPH[i].p_smth = 0;
		for(int k = 0 ; k < SPH[i].n_ngb ; ++ k){
			int j = SPH[i].ngb_hash[k];
			SPH[i].p_smth += SPH[j].Y * kernel.W(SPH[i].r - SPH[j].r, SPH[i].h);
		}
		//Pressure
		SPH[i].p   = Pressure  (SPH[i].m * SPH[i].p_smth / SPH[i].Y, SPH[i].u);
		SPH[i].c   = SoundSpeed(SPH[i].m * SPH[i].p_smth / SPH[i].Y, SPH[i].u);
		SPH[i].rho = SPH[i].m * SPH[i].p_smth / SPH[i].Y;
		//div v and rot v
		for(int k = 0 ; k < SPH[i].n_ngb ; ++ k){
			int j = SPH[i].ngb_hash[k];
			if(i == j) continue;
			vec3<double> dr = SPH[i].r - SPH[j].r;
			vec3<double> dv = SPH[i].v - SPH[j].v;
			vec3<double> grad_kernel = kernel.gradW(dr, SPH[i].h);
			SPH[i].omega += - SPH[j].Y * (N_DIM / SPH[i].h * kernel.W(dr, SPH[i].h) - abs(dr) / SPH[i].h * abs(grad_kernel));
			double volume = SPH[j].Y / SPH[i].p_smth;
			SPH[i].div_v += - volume * inner(dv, grad_kernel);
			SPH[i].rot_v += - volume * outer(dv, grad_kernel);
		}
		//DEBUG
		SPH[i].er = (SPH[i].p_smth + 7.15 * 3309.0) / (SPH[i].rho * 6.15) / SPH[i].u - 1.0;
		//Balsara 1989
		SPH[i].f = abs(SPH[i].div_v) / (abs(SPH[i].div_v) + abs(SPH[i].rot_v) + 1.0e-4 * SPH[i].c / SPH[i].h);
		//Hosono+ (?)
		SPH[i].omega = 1.0 + SPH[i].h / (N_DIM * SPH[i].p_smth) * SPH[i].omega;
	}
}
Esempio n. 6
0
void BMP085NB::pollData (int *temperature, long *pressure, float *alti) {	
  switch (pressureState){
    case 0:
	  pressureState = 1;
	  newData = false;
	  timer = millis();
      StartUT();            
    break;
    case 1:
      if (millis() - timer >= 5) {
        pressureState = 2;
		ut = ReadUT();	
        *temperature = Temperature(ut);        
      }
    break;
    case 2:
      timer1 = millis();
      StartUP();      
      pressureState = 3;
    break;    
    case 3:			  
      if (millis() - timer1 >= 2 + (3<<OSS)) {	          
        up = ReadUP();
        *pressure = Pressure(up);
        *alti = Altitude(*pressure);
		newData = true;
		pressureState = 0;
      }
    break;
	default:
	break;
  }
}
Esempio n. 7
0
static SIZE_OR_ERROR OWQ_parse_output_float(struct one_wire_query *owq)
{
	/* should only need suglen+1, but uClibc's snprintf()
	   seem to trash 'len' if not increased */
	int len;
	char c[PROPERTY_LENGTH_FLOAT + 2];
	_FLOAT F;

	switch (OWQ_pn(owq).selected_filetype->format) {
	case ft_pressure:
		F = Pressure(OWQ_F(owq), PN(owq));
		break;
	case ft_temperature:
		F = Temperature(OWQ_F(owq), PN(owq));
		break;
	case ft_tempgap:
		F = TemperatureGap(OWQ_F(owq), PN(owq));
		break;
	default:
		F = OWQ_F(owq);
		break;
	}

	UCLIBCLOCK;
	if ( ShouldTrim(PN(owq)) ) {
		len = snprintf(c, PROPERTY_LENGTH_FLOAT + 1, "%1G", F);
	} else {
		len = snprintf(c, PROPERTY_LENGTH_FLOAT + 1, "%*G", PROPERTY_LENGTH_FLOAT, F);
	}
	UCLIBCUNLOCK;
	if ((len < 0) || ((size_t) len > PROPERTY_LENGTH_FLOAT)) {
		return -EMSGSIZE;
	}
	return OWQ_parse_output_offset_and_size(c, len, owq);
}
Esempio n. 8
0
void CalcDensity(particle_t *SPH){
	#pragma omp parallel for
	for(int i = 0 ; i < N_SPHP ; ++ i){
		SPH[i].div_v = 0;
		SPH[i].omega = 0;
		SPH[i].rot_v = vec3<double>(0, 0, 0);
		SPH[i].rho = 0;
		SPH[i].q = 0;
		for(int k = 0 ; k < SPH[i].n_ngb ; ++ k){
			int j = SPH[i].ngb_hash[k];
			SPH[i].rho += SPH[j].m *            kernel.W(SPH[i].r - SPH[j].r, SPH[i].h);
			SPH[i].q   += SPH[j].m * SPH[j].u * kernel.W(SPH[i].r - SPH[j].r, SPH[i].h);
		}
		//Pressure
		SPH[i].p = Pressure  (SPH[i].q / SPH[i].u, SPH[i].u);
		SPH[i].c = SoundSpeed(SPH[i].q / SPH[i].u, SPH[i].u);
		//div v and rot v
		for(int k = 0 ; k < SPH[i].n_ngb ; ++ k){
			int j = SPH[i].ngb_hash[k];
			if(i == j) continue;
			vec3<double> dr = SPH[i].r - SPH[j].r;
			vec3<double> dv = SPH[i].v - SPH[j].v;
			vec3<double> grad_kernel = kernel.gradW(dr, SPH[i].h);
			SPH[i].omega += - SPH[j].m * SPH[j].u * (N_DIM / SPH[i].h * kernel.W(dr, SPH[i].h) - abs(dr) / SPH[i].h * abs(grad_kernel));
			double volume = SPH[j].m * SPH[i].u / SPH[i].q;
			SPH[i].div_v += - volume * inner(dv, grad_kernel);
			SPH[i].rot_v += - volume * outer(dv, grad_kernel);
		}
		//Balsara 1989
		SPH[i].f = abs(SPH[i].div_v) / (abs(SPH[i].div_v) + abs(SPH[i].rot_v) + 1.0e-4 * SPH[i].c / SPH[i].h);
		//Hopkins 2012
		SPH[i].omega = 1.0 + SPH[i].h / (N_DIM * SPH[i].q) * SPH[i].omega;
	}
}
Esempio n. 9
0
//return Pressure, Velocity, Density
Real4 HalfProblemContactDiscontinuty(Real PressureOut, Real VelocityOut,
		Real DensityOut, Real GammaOut, Real SoundOut, Real PressureContact,
		Real VelocityContact) {
	Real4 Result;
	Pressure(Result) = PressureContact;
	Density(Result) = DensityOut;
	Velocity(Result) = VelocityContact;
	return Result;
}
Esempio n. 10
0
double Chevalier::P_star(double r)
{
	double P = Pressure(r); //dyn cm^-2
	double M_dot_prime = M_dot * msun_in_g/year_in_sec; // g/s
	double R_prime = R * parsec_in_cm; //cm
	double P_prime = sqrt(M_dot_prime)*sqrt(E_dot)/(R_prime*R_prime);

	//dimensionless pressure
	return P/P_prime;
}
Esempio n. 11
0
void make_P(double ** U, int NT, double * Press){
  Press[0] = 1.;
  int i;for(i=1;i<NT-1;++i){
    double Ui[3]; getcol(U, i, Ui);
    Press[i] = Pressure(Ui);
    //printf("Ui_%d %f  %f P=%f\n", i, Ui[0], Ui[1], Press[i]);
  }
  Press[NT] = 0.1;
  //printf("%f\n", Press[NT]);
}
Esempio n. 12
0
//return Pressure and Velocity
Real2 NewtonVelocity(Real PressureLeft, Real VelocityLeft, Real DensityLeft,
		Real GammaLeft, Real SoundLeft, Real PressureRight, Real VelocityRight,
		Real DensityRight, Real GammaRight, Real SoundRight) {
	int CountIterations = 0;
	Real2 Result;
	Pressure(Result) = (-VelocityRight + VelocityLeft + SoundLeft / GammaLeft
			+ SoundRight / GammaRight) / (SoundLeft
			/ (GammaLeft * PressureLeft) + SoundRight / (GammaRight
			* PressureRight));
	Real IterateVelocityLeft = AdiabatVelocity(PressureLeft, VelocityLeft,
			DensityLeft, SoundLeft, GammaLeft, Pressure(Result), true),
			IterateVelocityRight = AdiabatVelocity(PressureRight,
					VelocityRight, DensityRight, SoundRight, GammaRight,
					Pressure(Result), false);
	while ((fabs(IterateVelocityLeft - IterateVelocityRight) > Epsilon * (fabs(
			IterateVelocityLeft) - fabs(IterateVelocityRight)))
			&& (CountIterations < 1000)) {
		Real DerivatLeft = AdiabatVelocityDerivative(PressureLeft,
				VelocityLeft, DensityLeft, SoundLeft, GammaLeft,
				Pressure(Result), true);
		Real DerivatRight = AdiabatVelocityDerivative(PressureRight,
				VelocityRight, DensityRight, SoundRight, GammaRight,
				Pressure(Result), false);
		Real PressureStep = -(IterateVelocityLeft - IterateVelocityRight)
				/ (DerivatLeft - DerivatRight);
		if (fabs(PressureStep / Pressure(Result)) < Epsilon)
			break;
		Pressure(Result) += PressureStep;
		IterateVelocityRight = AdiabatVelocity(PressureRight, VelocityRight,
				DensityRight, SoundRight, GammaRight, Pressure(Result), false);
		IterateVelocityLeft = AdiabatVelocity(PressureLeft, VelocityLeft,
				DensityLeft, SoundLeft, GammaLeft, Pressure(Result), true);
		CountIterations++;
	};


    #ifndef CUDA
	if (CountIterations >= 1000)
		Velocity(Result) = Real(CountIterations / 0);
    else
	#endif
		Velocity(Result) = Real(0.5) * (IterateVelocityLeft + IterateVelocityRight);
		return Result;
	};
Esempio n. 13
0
double Chevalier::Temperature(double r)
{
  //temperature in K
  double T;
  double P = Pressure(r); // dyn cm^-2
	double u    = WindVelocity(r); 	//km/s
  double rho = Density(r); // g/cm^3
  double n = rho / mp_in_grams;


  T = P / (n*kb_cgs);

  return T; //in Kelvin
}
Esempio n. 14
0
double Entropy(double ** U, int NT, double dx, double * sumv, double * sump){
  double vsum = 0;
  double psum = 0;
  int i;for(i=1;i<NT-1;++i){
    double Ui[3]; getcol(U, i, Ui);
    double P = Pressure(Ui);
    double V = Velocity(Ui);
    double Pi = Pressurei(Ui[0]);
    double Vi = Velocityi(Ui[0]);
    vsum += dx*fabs(V - Vi);
    psum += dx*fabs(P - Pi);
  }
  *sumv = vsum; *sump = psum;
}
Esempio n. 15
0
//return Pressure, Velocity, Density, Energy
Real4 CaseVacuum(Real PressureLeft, Real VelocityLeft, Real DensityLeft,
		Real GammaLeft, Real SoundLeft, Real PressureRight, Real VelocityRight,
		Real DensityRight, Real GammaRight, Real SoundRight) {
	Real4 Result;
	if (VelocityLeft - SoundLeft >= 0) {
		Density(Result) = DensityLeft;
		Pressure(Result) = PressureLeft;
		Velocity(Result) = VelocityLeft;
		Energy(Result) = Pressure(Result)
				/ ((GammaLeft - 1) * Density(Result));
	} else if (VelocityLeft + 2 * SoundLeft / (GammaLeft - 1) >= 0) {
		Real Ratio = 2 / (GammaLeft + 1);
		Density(Result) = DensityLeft * Ratio;
		Pressure(Result) = PressureLeft * Ratio;
		Velocity(Result) = VelocityLeft + SoundLeft * Ratio;
		Energy(Result) = Pressure(Result)
				/ ((GammaLeft - 1) * Density(Result));
	}
	if (VelocityRight + SoundRight <= 0) {
		Density(Result) = DensityRight;
		Pressure(Result) = PressureRight;
		Velocity(Result) = VelocityRight;
		Energy(Result) = Pressure(Result) / ((GammaRight - 1)
				* Density(Result));
	} else if (VelocityLeft - 2 * SoundRight / (GammaRight - 1) <= 0) {
		Real Ratio = 2 / (GammaRight + 1);
		Density(Result) = DensityRight * Ratio;
		Pressure(Result) = PressureRight * Ratio;
		Velocity(Result) = VelocityRight - SoundLeft * Ratio;
		Energy(Result) = Pressure(Result) / ((GammaRight - 1)
				* Density(Result));
	} else {
		Density(Result) = 0;
		Pressure(Result) = 0;
		Velocity(Result) = 0;
		Energy(Result) = 0;
	};
	return Result;
}
Esempio n. 16
0
//return Pressure, Velocity, Density, Energy
Real4 SolveHalfProblem(Real PressureOut, Real VelocityOut, Real DensityOut,
		Real GammaOut, Real SoundOut, Real PressureContact,
		Real VelocityContact, bool Left) {
	Real Sign = Left ? Real(1) : Real(-1);
	Real4 Result;
	if (PressureOut > PressureContact)
		Result = HalfProblemDepressionWave(PressureOut, Sign * VelocityOut,
				DensityOut, GammaOut, SoundOut, PressureContact, Sign
						* VelocityContact);
	else if (PressureOut < PressureContact)
		Result = HalfProblemShockWave(PressureOut, Sign * VelocityOut,
				DensityOut, GammaOut, SoundOut, PressureContact, Sign
						* VelocityContact);
	else
		Result = HalfProblemContactDiscontinuty(PressureOut,
				Sign * VelocityOut, DensityOut, GammaOut, SoundOut,
				PressureContact, Sign * VelocityContact);
	Energy(Result) = Pressure(Result) / ((GammaOut - 1) * Density(Result));
	Velocity(Result) = Sign * Velocity(Result);
	return Result;
}
Esempio n. 17
0
void Flux(double * Ui, double * Fi, double P){
  Fi[0] = Ui[1]; 
  Fi[1] = pow(Ui[1], 2)/Ui[0] + Pressure(Ui);
  Fi[2] = (Ui[2] + Pressure(Ui))*Velocity(Ui);
}
Esempio n. 18
0
 static Pressure fromPSI(base::Time const& time, float psi)
 {
     return Pressure(time, base::Pressure::fromPSI(psi));
 }
Esempio n. 19
0
 static Pressure fromBar(base::Time const& time, float bar)
 {
     return Pressure(time, base::Pressure::fromBar(bar));
 }
Esempio n. 20
0
 static Pressure fromPascal(base::Time const& time, float pascal)
 {
     return Pressure(time, base::Pressure::fromPascal(pascal));
 }
Esempio n. 21
0
void InterfaceFreeEIO::Pressure(double *P,double *Dencity,double *Temperature,int Num)
  {		for (int k=1;k<=Num;k++) { P[k]=Pressure(Dencity[k],Temperature[k]);}}
Esempio n. 22
0
    > void initialize(
        const Geometries& geometries,
        Init_Cond& initial_conditions,
        const Background_Magnetic_Field& bg_B,
        dccrg::Dccrg<Cell, Geometry>& grid,
        const std::vector<uint64_t>& cells,
        const double time,
        const double adiabatic_index,
        const double vacuum_permeability,
        const double proton_mass,
        const bool verbose,
        const Mass_Density_Getter Mas,
        const Momentum_Density_Getter Mom,
        const Total_Energy_Density_Getter Nrj,
        const Magnetic_Field_Getter Mag,
        const Background_Magnetic_Field_Pos_X_Getter Bg_B_Pos_X,
        const Background_Magnetic_Field_Pos_Y_Getter Bg_B_Pos_Y,
        const Background_Magnetic_Field_Pos_Z_Getter Bg_B_Pos_Z,
        const Mass_Density_Flux_Getter Mas_f,
        const Momentum_Density_Flux_Getter Mom_f,
        const Total_Energy_Density_Flux_Getter Nrj_f,
        const Magnetic_Field_Flux_Getter Mag_f
    ) {
    if (verbose and grid.get_rank() == 0) {
        std::cout << "Setting default MHD state... ";
        std::cout.flush();
    }
    // set default state
    for (const auto cell_id: cells) {
        auto* const cell_data = grid[cell_id];
        if (cell_data == nullptr) {
            std::cerr <<  __FILE__ << "(" << __LINE__ << ") No data for cell: "
                      << cell_id
                      << std::endl;
            abort();
        }

        // zero fluxes and background fields
        Mas_f(*cell_data)         =
            Nrj_f(*cell_data)         =
                Mom_f(*cell_data)[0]      =
                    Mom_f(*cell_data)[1]      =
                        Mom_f(*cell_data)[2]      =
                            Mag_f(*cell_data)[0]      =
                                Mag_f(*cell_data)[1]      =
                                    Mag_f(*cell_data)[2]      = 0;

        const auto c = grid.geometry.get_center(cell_id);
        const auto r = sqrt(c[0]*c[0] + c[1]*c[1] + c[2]*c[2]);
        const auto
        lat = asin(c[2] / r),
        lon = atan2(c[1], c[0]);

        const auto mass_density
            = proton_mass
              * initial_conditions.get_default_data(
                  Number_Density(),
                  time,
                  c[0], c[1], c[2],
                  r, lat, lon
              );
        const auto velocity
            = initial_conditions.get_default_data(
                  Velocity(),
                  time,
                  c[0], c[1], c[2],
                  r, lat, lon
              );
        const auto pressure
            = initial_conditions.get_default_data(
                  Pressure(),
                  time,
                  c[0], c[1], c[2],
                  r, lat, lon
              );
        const auto magnetic_field
            = initial_conditions.get_default_data(
                  Magnetic_Field(),
                  time,
                  c[0], c[1], c[2],
                  r, lat, lon
              );

        Mas(*cell_data) = mass_density;
        Mom(*cell_data) = mass_density * velocity;
        Mag(*cell_data) = magnetic_field;
        Nrj(*cell_data) = get_total_energy_density(
                              mass_density,
                              velocity,
                              pressure,
                              magnetic_field,
                              adiabatic_index,
                              vacuum_permeability
                          );

        const auto cell_end = grid.geometry.get_max(cell_id);
        Bg_B_Pos_X(*cell_data) = bg_B.get_background_field(
        {cell_end[0], c[1], c[2]},
        vacuum_permeability
        );
        Bg_B_Pos_Y(*cell_data) = bg_B.get_background_field(
        {c[0], cell_end[1], c[2]},
        vacuum_permeability
        );
        Bg_B_Pos_Z(*cell_data) = bg_B.get_background_field(
        {c[0], c[1], cell_end[2]},
        vacuum_permeability
        );
    }

    // set non-default initial conditions
    if (verbose and grid.get_rank() == 0) {
        std::cout << "done\nSetting non-default initial MHD state... ";
        std::cout.flush();
    }

    /*
    Set non-default initial conditions
    */

    // mass density
    for (
        size_t i = 0;
        i < initial_conditions.get_number_of_regions(Number_Density());
        i++
    ) {
        const auto& init_cond = initial_conditions.get_initial_condition(Number_Density(), i);
        const auto& geometry_id = init_cond.get_geometry_id();
        const auto& cells = geometries.get_cells(geometry_id);
        for (const auto& cell: cells) {
            const auto c = grid.geometry.get_center(cell);
            const auto r = sqrt(c[0]*c[0] + c[1]*c[1] + c[2]*c[2]);
            const auto
            lat = asin(c[2] / r),
            lon = atan2(c[1], c[0]);

            const auto mass_density
                = proton_mass
                  * initial_conditions.get_data(
                      Number_Density(),
                      geometry_id,
                      time,
                      c[0], c[1], c[2],
                      r, lat, lon
                  );

            auto* const cell_data = grid[cell];
            if (cell_data == NULL) {
                std::cerr <<  __FILE__ << "(" << __LINE__ << std::endl;
                abort();
            }

            Mas(*cell_data) = mass_density;
        }
    }

    // velocity
    for (
        size_t i = 0;
        i < initial_conditions.get_number_of_regions(Velocity());
        i++
    ) {
        const auto& init_cond = initial_conditions.get_initial_condition(Velocity(), i);
        const auto& geometry_id = init_cond.get_geometry_id();
        const auto& cells = geometries.get_cells(geometry_id);
        for (const auto& cell: cells) {
            const auto c = grid.geometry.get_center(cell);
            const auto r = sqrt(c[0]*c[0] + c[1]*c[1] + c[2]*c[2]);
            const auto
            lat = asin(c[2] / r),
            lon = atan2(c[1], c[0]);

            const auto velocity = initial_conditions.get_data(
                                      Velocity(),
                                      geometry_id,
                                      time,
                                      c[0], c[1], c[2],
                                      r, lat, lon
                                  );

            auto* const cell_data = grid[cell];
            if (cell_data == NULL) {
                std::cerr <<  __FILE__ << "(" << __LINE__
                          << ") No data for cell: " << cell
                          << std::endl;
                abort();
            }

            Mom(*cell_data) = Mas(*cell_data) * velocity;
        }
    }

    // magnetic field
    for (
        size_t i = 0;
        i < initial_conditions.get_number_of_regions(Magnetic_Field());
        i++
    ) {
        const auto& init_cond = initial_conditions.get_initial_condition(Magnetic_Field(), i);
        const auto& geometry_id = init_cond.get_geometry_id();
        const auto& cells = geometries.get_cells(geometry_id);
        for (const auto& cell: cells) {
            const auto c = grid.geometry.get_center(cell);
            const auto r = sqrt(c[0]*c[0] + c[1]*c[1] + c[2]*c[2]);
            const auto
            lat = asin(c[2] / r),
            lon = atan2(c[1], c[0]);

            const auto magnetic_field = initial_conditions.get_data(
                                            Magnetic_Field(),
                                            geometry_id,
                                            time,
                                            c[0], c[1], c[2],
                                            r, lat, lon
                                        );

            auto* const cell_data = grid[cell];
            if (cell_data == NULL) {
                std::cerr <<  __FILE__ << "(" << __LINE__
                          << ") No data for cell: " << cell
                          << std::endl;
                abort();
            }

            Mag(*cell_data) = magnetic_field;
        }
    }

    // pressure
    for (
        size_t i = 0;
        i < initial_conditions.get_number_of_regions(Pressure());
        i++
    ) {
        std::cout << std::endl;
        const auto& init_cond = initial_conditions.get_initial_condition(Pressure(), i);
        const auto& geometry_id = init_cond.get_geometry_id();
        std::cout << geometry_id << std::endl;
        const auto& cells = geometries.get_cells(geometry_id);
        std::cout << cells.size() << std::endl;
        for (const auto& cell: cells) {
            const auto c = grid.geometry.get_center(cell);
            const auto r = sqrt(c[0]*c[0] + c[1]*c[1] + c[2]*c[2]);
            const auto
            lat = asin(c[2] / r),
            lon = atan2(c[1], c[0]);

            const auto pressure = initial_conditions.get_data(
                                      Pressure(),
                                      geometry_id,
                                      time,
                                      c[0], c[1], c[2],
                                      r, lat, lon
                                  );

            auto* const cell_data = grid[cell];
            if (cell_data == NULL) {
                std::cerr <<  __FILE__ << "(" << __LINE__
                          << ") No data for cell: " << cell
                          << std::endl;
                abort();
            }

            Nrj(*cell_data) = get_total_energy_density(
                                  Mas(*cell_data),
                                  Mom(*cell_data) / Mas(*cell_data),
                                  pressure,
                                  Mag(*cell_data),
                                  adiabatic_index,
                                  vacuum_permeability
                              );
        }
    }

    if (verbose and grid.get_rank() == 0) {
        std::cout << "done" << std::endl;
    }
}