Peano
Loading...
Searching...
No Matches
TestDensityCalculation.py
Go to the documentation of this file.
2 """
3 Initialisation snippet for testing the calculation of the SPH density.
4 Returns a string with C++ code.
5 """
6
7 def __init__(self):
9 // Start of template in src/exaparty/api/scenario/TestDensityCalculation.py
10
11 /*
12 * Most of the initialised variables are dummy (i.e. not used)
13 */
14
15 // Internal search radious used by Peano and with max value R = grid_size/2
16
17 // Internal search radius used by Peano and with max value R = grid_size/2
18 tarch::la::Vector<Dimensions,double> GridSize = marker.h();
19 const double GridSizeHalf_x = 0.5 * GridSize(0);
20
21 const double h_max = particle->getSmlMax();
22 const double H_max = h_max * kernel_gamma;
23 double search_radius = 0.999 * std::min(H_max, GridSizeHalf_x);
24
25 particle->setSearchRadius( search_radius);
26
27 particle->setDensity ( 1.0 );
28 particle->setMass( particle->getDensity() / std::pow(HYDRO_PART_NUMBER, HYDRO_DIMENSIONS) );
29
30 particle->setU( 1e-1 );
31 particle->setUDot( 0 );
32 particle->setU_full( 1e-1 );
33 particle->setPressure( 1e-1 );
34 particle->setSoundSpeed( 1e-1 );
35
36 /* Compute initial smoothing length */
37 const double eta_fac = particle->getEtaFactor();
38 particle->setSmoothingLength( eta_fac * std::pow(particle->getMass()/particle->getDensity(), 1.0 / HYDRO_DIMENSIONS) );
39
40 /* Initialize remaining fields */
41
42 // Vectors
43 for(int d=0; d<Dimensions; d++){
44 particle->setV (d,0);
45 particle->setV_full (d,0);
46 particle->setA (d,0);
47 }
48
49 particle->setRot_v(0);
50 particle->setHDot (0.0);
51 particle->setWcount(0.0);
52 particle->setF (0.0);
53 particle->setRho_dh(0.0);
54 particle->setWcount_dh(0.0);
55
56 particle->setSmlIterLeftBound(particle->getSmlMin());
57 particle->setSmlIterRightBound(particle->getSmlMax());
58
59 particle->setHasNoNeighbours(false);
60 particle->setCellHasUpdatedParticle(false);
61 particle->setSmoothingLengthIterCount(0);
62
63 // Artificial viscosity scheme
64 particle->setDiv_v (0.0);
65 particle->setV_sig_AV(2.0 * particle->getSoundSpeed());
66 particle->setBalsara (0.0);
67
68#if PeanoDebug > 0
69 particle->setPartid(1);
70#endif
71
72 // End of inserted block
73
74 """
Initialisation snippet for testing the calculation of the SPH density.