Peano
Loading...
Searching...
No Matches
SodShock.py
Go to the documentation of this file.
1# @todo: add dependence on SPH scheme (only minimal SPH ATM)
2# @todo: add dependence on input parameters, e.g. grid size, HYDRO_DIMENSIONS...
3
4
6 """
7 Initialisation snippet for the Sod shock problem in different spatial dimensions.
8 This problem should have been initialized via a HDF5 file which set up
9 the relevant variables.
10 Here we initialize the rest of arrays which are mostly trivial, but
11 also fine-tune the boundary particles.
12
13 Returns a string with C++ code.
14 """
15
16 def __init__(self, dimensions):
17 if dimensions == 1:
19
20 /* Code inserted via the python initialisation snippet library.
21 * Do not modify unless you know what you are doing.
22 */
23
24 /*
25 * Initial Conditions: Sod shockwave.
26 * This problem should have been initialized via a HDF5 file which set up
27 * the relevant variables.
28 * Here we initialize the rest of arrays which are mostly trivial.
29 */
30
31 logError("Unused and deprecated. Probably needs fixing.")
32
33 // Internal search radius used by Peano and with max value R = grid_size/2
34 tarch::la::Vector<Dimensions,double> GridSize = marker.h();
35 const double GridSizeHalf_x = 0.5 * GridSize(0);
36
37 const double h_max = particle->getSmlMax();
38 const double H_max = h_max * kernel_gamma;
39 double search_radius = 0.999 * std::min(H_max, GridSizeHalf_x);
40
41 particle->setSearchRadius( search_radius );
42
43 /* Constant density field */
44 particle->setDensity ( 1.0 );
45 particle->setMass( particle->getDensity() / std::pow(HYDRO_PART_NUMBER, HYDRO_DIMENSIONS) );
46
47 /* Initial estimate for smoothing length */
48 const double eta_fac = particle->getEtaFactor();
49 particle->setSmoothingLength( eta_fac * std::pow(particle->getMass()/particle->getDensity(), 1.0 / HYDRO_DIMENSIONS) );
50 particle->setSmoothingLengthPrevious( particle->getSmoothingLength() );
51
52 particle->setU( 1e-1 );
53 particle->setPressure( 1e-1 );
54 particle->setSoundSpeed( 1e-1 );
55
56 /* Initialize remaining fields */
57
58 // Vectors
59 for(int d=0; d<Dimensions; d++){
60 particle->setV (d,0);
61 particle->setA (d,0);
62 }
63
64 /* For 2D sims, we only get one component */
65 particle->setRot_v(0);
66
67 /* Initialise the "extended" arrays */
68 particle->setV_full( particle->getV() );
69 particle->setU_full( particle->getU() );
70
71 particle->setUDot (0.0);
72 particle->setHDot (0.0);
73 particle->setWcount(0.0);
74 particle->setF (0.0);
75 particle->setRho_dh(0.0);
76 particle->setWcount_dh(0.0);
77
78 particle->setHLeft (particle->getSmlMin());
79 particle->setHRight(particle->getSmlMax());
80
81 particle->setSmoothingLengthConverged(false);
82 particle->setHasNoNeighbours(false);
83 particle->setSmoothingLengthIterCount(0);
84
85 // Artificial viscosity scheme
86 particle->setDiv_v (0.0);
87 particle->setV_sig_AV(2.0 * particle->getSoundSpeed());
88 particle->setBalsara (0.0);
89
90 particle->setPartid(1);
91
92 /* End of inserted block */
93
94 """
95 else:
96 print("dimensions not supported!")
Initialisation snippet for the Sod shock problem in different spatial dimensions.
Definition SodShock.py:5