8 Initialisation snippet for the Gresho-Chan vortex in different spatial dimensions.
9 Returns a string with C++ code.
16 /* Code inserted via the python initialisation snippet library.
17 * Do not modify unless you know what you are doing.
21 * Initial Conditions: Gresho-Chan vortex.
22 * We give the particles values for the azhimutal velocity and
23 * pressure in a spherically-symmetric way.
27 // Internal search radius used by Peano and with max value R = grid_size/2
28 tarch::la::Vector<Dimensions,double> GridSize = marker.h();
29 const double GridSizeHalf_x = 0.5 * GridSize(0);
31 const double h_max = particle->getSmlMax();
32 const double H_max = h_max * kernel_gamma;
33 double search_radius = 0.999 * std::min(H_max, GridSizeHalf_x);
35 particle->setSearchRadius( search_radius );
37 /* Constant density field */
38 particle->setDensity ( 1.0 );
39 particle->setMass( particle->getDensity() / std::pow(HYDRO_PART_NUMBER, HYDRO_DIMENSIONS) );
41 /* Initial estimate for smoothing length */
42 const double eta_fac = particle->getEtaFactor();
43 particle->setSmoothingLength( eta_fac * std::pow(particle->getMass()/particle->getDensity(), 1.0 / HYDRO_DIMENSIONS) );
44 particle->setSmoothingLengthPrevious( particle->getSmoothingLength() );
47 tarch::la::Vector<Dimensions,double> x_0(0.5);
49 // Distance of particle to centre
50 tarch::la::Vector<Dimensions,double> pos = particle->getX();
51 tarch::la::Vector<Dimensions,double> dist = pos - x_0;
52 double r = tarch::la::norm2(dist);
54 // avoid velocity divergences at r=0
57 /* Initial azhimutal velocity */
60 if( r >= 0 && r < 0.2) {
62 } else if( r >= 0.2 && r < 0.4){
63 v_phi = 2.0 - 5.0 * r;
68 // Set velocity profile
69 tarch::la::Vector<Dimensions,double> v_ini;
71 // Get x and y particle coordinates
72 const double pos_x = pos[0];
73 const double pos_y = pos[1];
75 v_ini[0] = - v_phi * (pos_y - 0.5) / r;
76 v_ini[1] = v_phi * (pos_x - 0.5) / r;
78 particle->setV( v_ini );
80 /* Initial pressure profile */
83 if( r >= 0 && r < 0.2) {
84 pressure = 5.0 + 12.5 * r * r;
85 } else if( r >= 0.2 && r < 0.4){
86 pressure = 9.0 + 12.5 * r * r - 20.0 * r + 4.0 * log( 5.0 * r );
88 pressure = 3.0 + 4.0 * log( 2.0 );
91 // Set pressure profile
92 particle->setPressure( pressure );
94 /* Set U from the EoS */
95 double u_ini = ::exaparty::legacy::eos::gas_internal_energy_from_pressure( particle->getDensity(), particle->getPressure() );
96 particle->setU( u_ini );
99 const double soundspeed = ::exaparty::legacy::eos::gas_soundspeed_from_internal_energy( particle->getU() );
100 particle->setSoundSpeed(soundspeed);
103 * Initialize remaining fields
107 for(int d=0; d<Dimensions; d++){
108 particle->setA (d,0);
109 particle->setA_prev_step(d,0);
112 /* For 2D sims, we only get one component */
113 particle->setRot_v(0);
115 /* Initialise the "extended" arrays */
116 particle->setV_full(particle->getV());
117 particle->setU_full(particle->getU());
119 particle->setUDot (0.0);
120 particle->setUDot_prev_step(0.0);
121 particle->setHDot (0.0);
122 particle->setWcount(0.0);
123 particle->setNcount(0 );
124 particle->setF (0.0);
125 particle->setRho_dh(0.0);
126 particle->setWcount_dh(0.0);
128 particle->setHLeft (particle->getSmlMin());
129 particle->setHRight(particle->getSmlMax());
131 particle->setTimeStepSize(GLOBAL_TIME_STEP_SIZE);
132 particle->setHasConverged(false);
133 particle->setHasNoNeighbours(false);
134 particle->setResidual(0.0);
135 particle->setIterCount(0);
137 // Artificial viscosity scheme
138 particle->setDiv_v (0.0);
139 particle->setV_sig_AV(2.0 * particle->getSoundSpeed());
140 particle->setBalsara (0.0);
142 /* End of inserted block */
146 print(
"dimensions not supported!")
Initialisation snippet for the Gresho-Chan vortex in different spatial dimensions.
__init__(self, dimensions)