Peano 4
Loading...
Searching...
No Matches
SelfSimilarInfallFD4.cpp
Go to the documentation of this file.
3
4
5tarch::logging::Log benchmarks::exahype2::euler::sphericalaccretionupscaling::SelfSimilarInfallFD4::_log( "benchmarks::exahype2::euler::sphericalaccretionupscaling::SelfSimilarInfallFD4" );
6
7
9
10
13
14
16 const tarch::la::Vector<Dimensions,double>& volumeCentre,
18 double density
19) {
20 double overDensity = density - BaseDensity;
21 double radius = tarch::la::norm2( volumeCentre );
22
23 double mass = overDensity * tarch::la::volume( volumeH );
24
25 logDebug( "touchCellFirstTime(...)", "dump data of " << volumeCentre << ": " << density << " x " << volumeH << "->" << radius << " x " << mass );
26
27 _accumulator.addMass(mass,radius);
28}
29
30
32 const double * __restrict__ Q, // Q[5+0]
35 double t
36) {
37 if (
39 and
40 tarch::la::norm2(volumeX) <= InitialTopHatRadius + volumeH(0) * NumberOfGridCellsPerPatchPerAxis
41 ) {
42 return ::exahype2::RefinementCommand::Refine;
43 }
44 else if (
45 DynamicAMR
46 and
47 ( Q[4]>1.1*BaseDensity )
48 ) {
49 return ::exahype2::RefinementCommand::Refine;
50 }
51 else if (
52 DynamicAMR
53 ) {
54 return ::exahype2::RefinementCommand::Erase;
55 }
56 else {
57 return ::exahype2::RefinementCommand::Keep;
58 }
59}
60
61
62
63
65 double * __restrict__ Q,
66 const tarch::la::Vector<Dimensions,double>& meshCellCentre,
68 bool gridIsConstructed
69) {
70 logTraceInWith3Arguments( "initialCondition(...)", meshCellCentre, meshCellH, gridIsConstructed );
71
73 Q,
74 BaseDensity,
75 pInitial,
76 Gamma
77 );
78
79/*
80 applications::exahype2::euler::sphericalaccretion::initialiseOverdensity_Gaussian(
81 Q,
82 meshCellCentre,
83 InitialTopHatRadius,
84 AdditionalMass,
85 BaseDensity,
86 pInitial,
87 Gamma
88 );
89*/
90
91 logTraceOut( "initialCondition(...)" );
92}
93
94
95
96
97
99 const double * __restrict__ Qinside, // Qinside[5+0]
100 double * __restrict__ Qoutside, // Qoutside[5+0]
101 const tarch::la::Vector<Dimensions,double>& faceCentre,
103 double t,
104 int normal
105) {
106 logTraceInWith4Arguments( "boundaryConditions(...)", faceCentre, volumeH, t, normal );
107
108 ::applications::exahype2::euler::NeumannBoundaryConditions(
109 Qinside,
110 Qoutside,
111 faceCentre,
112 volumeH,
113 t,
114 normal,
115 NumberOfUnknowns, // defined in superclass
116 NumberOfAuxiliaryVariables // defined in superclass
117 );
118
119 logTraceOut( "boundaryConditions(...)" );
120}
121
122
123
124
125
126double ::benchmarks::exahype2::euler::sphericalaccretionupscaling::SelfSimilarInfallFD4::maxEigenvalue(
127 const double * __restrict__ Q, // Q[5+0],
128 const tarch::la::Vector<Dimensions,double>& faceCentre,
130 double t,
131 double dt,
132 int normal
133) {
134 logTraceInWith4Arguments( "maxEigenvalue(...)", faceCentre, gridCellH, t, normal );
135
137 Q,
138 faceCentre,
139 gridCellH,
140 t,
141 dt,
142 normal,
143 NumberOfUnknowns,
144 NumberOfAuxiliaryVariables,
145 Gamma
146 );
147
148 logTraceOut( "maxEigenvalue(...)" );
149
150 if (result==0.0) {result=0.1;}
151 //result=0.1;
152 return result;
153}
154
155
156
157
158void ::benchmarks::exahype2::euler::sphericalaccretionupscaling::SelfSimilarInfallFD4::flux(
159 const double * __restrict__ Q, // Q[5+0],
160 const tarch::la::Vector<Dimensions,double>& faceCentre,
162 double t,
163 double dt,
164 int normal,
165 double * __restrict__ F // F[5]
166) {
167 logTraceInWith4Arguments( "flux(...)", faceCentre, gridCellH, t, normal );
168
170 Q,
171 faceCentre,
172 gridCellH,
173 t,
174 dt,
175 normal,
176 NumberOfUnknowns,
177 NumberOfAuxiliaryVariables,
178 F,
179 Gamma
180 );
181
182 logTraceOut( "flux(...)" );
183}
184
185
186
187
188
189
190
191void ::benchmarks::exahype2::euler::sphericalaccretionupscaling::SelfSimilarInfallFD4::sourceTerm(
192 const double * __restrict__ Q, // Q[5+0]
195 double t,
196 double dt,
197 double * __restrict__ S // S[5]
198) {
199 logTraceInWith4Arguments( "sourceTerm(...)", gridCellX, gridCellH, t, dt );
200
201 for (int i=0; i<NumberOfUnknowns; i++) {
202 S[i] = 0.0;
203 }
204
205 double massInterpolated = _accumulator.getMass_linearInterpolation( tarch::la::norm2( gridCellX ) );
206
208 S,
209 gridCellX,
210 Q,
211 massInterpolated,
212 aInitial,
213 t
214 );
215
216 logTraceOut( "sourceTerm(...)" );
217}
218
219
220void ::benchmarks::exahype2::euler::sphericalaccretionupscaling::SelfSimilarInfallFD4::finishTimeStep() {
221 AbstractSelfSimilarInfallFD4::finishTimeStep();
222 if (isLastGridSweepOfTimeStep()) {
223 _accumulator.finishAccumulation();
224 TotalMassInPreviousTimeStep = _accumulator.getTotalMass();
225 }
226}
#define logDebug(methodName, logMacroMessageStream)
Definition Log.h:50
#define logTraceOut(methodName)
Definition Log.h:379
#define logTraceInWith4Arguments(methodName, argument0, argument1, argument2, argument3)
Definition Log.h:373
#define logTraceInWith3Arguments(methodName, argument0, argument1, argument2)
Definition Log.h:372
void addDensity(const tarch::la::Vector< Dimensions, double > &volumeCentre, const tarch::la::Vector< Dimensions, double > &volumeH, double density)
Add density of one voxel to global bookkeeping.
static double TotalMassInPreviousTimeStep
After each time step, we backup the total mass in this static variable.
::exahype2::RefinementCommand refinementCriterion(const double *__restrict__ Q, const tarch::la::Vector< Dimensions, double > &volumeCentre, const tarch::la::Vector< Dimensions, double > &volumeH, double t) override
Refinement criterion.
void initialCondition(double *__restrict__ Q, const tarch::la::Vector< Dimensions, double > &volumeCentre, const tarch::la::Vector< Dimensions, double > &volumeH, bool gridIsConstructed) override
virtual void boundaryConditions(const double *__restrict__ Qinside, double *__restrict__ Qoutside, const tarch::la::Vector< Dimensions, double > &faceCentre, const tarch::la::Vector< Dimensions, double > &volumeH, double t, int normal) override
Log Device.
Definition Log.h:516
void addGravitationalSource_AlphaCDM(double *__restrict__ S, const tarch::la::Vector< Dimensions, double > &x, const double *__restrict__ Q, double mass, double aInitial, double t)
void initialiseHomogeneousDensity(double *__restrict__ Q, double baselineDensity, double baselinePressure, double gamma)
Baseline configuration where no overdensity is applied.
static void flux(const double *__restrict__ Q, int normal, double *__restrict__ F) InlineMethod
static double maxEigenvalue(const double *__restrict__ Q, int normal) InlineMethod
Scalar volume(const Vector< Size, Scalar > &vector)
Computes the volume of the tetrahedron spanned by the Cartesian unit vectors scaled by the correspond...
bool equals(const Matrix< Rows, Cols, Scalar > &lhs, const Matrix< Rows, Cols, Scalar > &rhs, const Scalar &tolerance=NUMERICAL_ZERO_DIFFERENCE)
Compares to matrices on equality by means of a numerical accuracy.
Scalar norm2(const Vector< Size, Scalar > &vector)
Computes the 2-norm of the vector, i.e.
Simple vector class.
Definition Vector.h:134