7#ifndef DGSYSEQNLINEARSCALARADV_H_
8#define DGSYSEQNLINEARSCALARADV_H_
34 const MInt sbpMode)
const;
62 std::array<std::array<MFloat, s_maxPolyDeg + 1>, 2>
m_cflFactor;
89 for(
MInt i = 0; i < nDim; i++) {
104 MString dgIntegrationMethod =
"DG_INTEGRATE_GAUSS";
106 Context::getSolverProperty<MString>(
"dgIntegrationMethod", this->
m_solverId, AT_, &dgIntegrationMethod);
109 MString dgTimeIntegrationScheme =
"DG_TIMEINTEGRATION_CARPENTER_4_5";
111 Context::getSolverProperty<MString>(
"dgTimeIntegrationScheme", this->
m_solverId, AT_, &dgTimeIntegrationScheme));
124 m_cflFactor = {{{{2.448730, 2.420654, 2.171631, 1.834717, 1.652832, 1.497803, 1.369629, 1.246338, 1.151123,
125 1.071777, 1.015625, 0.959473, 0.904541, 0.856934, 0.814209, 0.783691}},
126 {{2.891846, 2.716064, 2.454112, 2.081513, 1.877617, 1.702831, 1.523950, 1.382303, 1.281892,
127 1.203783, 1.132922, 1.060420, 1.002581, 0.960691, 0.912857, 0.868814}}}};
130 m_cflFactor = {{{{5.277100, 5.277100, 3.908691, 3.056641, 2.852783, 2.486572, 2.232660, 2.036133, 1.865234,
131 1.748047, 1.624756, 1.542969, 1.455078, 1.365967, 1.307373, 1.243896}},
132 {{5.848389, 5.848389, 3.948975, 3.621826, 3.244629, 2.897949, 2.618408, 2.298584, 2.114258,
133 1.972656, 1.834717, 1.741943, 1.669922, 1.539307, 1.470947, 1.406250}}}};
141 m_cflFactor = {{{{2.448730, 2.420654, 2.171631, 1.834717, 1.652832, 1.497803, 1.369629, 1.246338, 1.151123,
142 1.071777, 1.015625, 0.959473, 0.904541, 0.856934, 0.814209, 0.783691}},
143 {{2.891846, 2.716064, 2.454112, 2.081513, 1.877617, 1.702831, 1.523950, 1.382303, 1.281892,
144 1.203783, 1.132922, 1.060420, 1.002581, 0.960691, 0.912857, 0.868814}}}};
147 m_cflFactor = {{{{5.277100, 5.277100, 3.908691, 3.056641, 2.852783, 2.486572, 2.232660, 2.036133, 1.865234,
148 1.748047, 1.624756, 1.542969, 1.455078, 1.365967, 1.307373, 1.243896}},
149 {{5.848389, 5.848389, 3.948975, 3.621826, 3.244629, 2.897949, 2.618408, 2.298584, 2.114258,
150 1.972656, 1.834717, 1.741943, 1.669922, 1.539307, 1.470947, 1.406250}}}};
157 m_cflFactor = {{{{9.878051, 7.782532, 6.381652, 5.689331, 5.249816, 4.883361, 4.852050, 4.584167, 4.302368,
158 4.062316, 3.855896, 3.674987, 3.481323, 3.322448, 3.161255, 3.032532}},
159 {{11.289367, 10.013732, 7.770935, 7.036865, 6.197266, 5.667297, 5.417968, 5.106018, 4.787108,
160 4.493713, 4.266418, 4.072753, 3.840820, 3.692383, 3.507995, 3.385070}}}};
163 m_cflFactor = {{{{16.500915, 16.500915, 10.074035, 8.384399, 7.637573, 6.993957, 6.730712, 6.372375, 6.059265,
164 5.831970, 5.558288, 5.319396, 5.126892, 4.957580, 4.782471, 4.585327}},
165 {{18.998840, 18.998840, 11.339233, 9.595093, 8.869141, 8.107239, 7.406799, 6.981201, 6.632140,
166 6.465149, 6.123046, 5.956054, 5.783263, 5.485229, 5.329834, 5.112976}}}};
174 m_cflFactor = {{{{2.448730, 2.420654, 2.171631, 1.834717, 1.652832, 1.497803, 1.369629, 1.246338, 1.151123,
175 1.071777, 1.015625, 0.959473, 0.904541, 0.856934, 0.814209, 0.783691}},
176 {{2.891846, 2.716064, 2.454112, 2.081513, 1.877617, 1.702831, 1.523950, 1.382303, 1.281892,
177 1.203783, 1.132922, 1.060420, 1.002581, 0.960691, 0.912857, 0.868814}}}};
180 m_cflFactor = {{{{5.277100, 5.277100, 3.908691, 3.056641, 2.852783, 2.486572, 2.232660, 2.036133, 1.865234,
181 1.748047, 1.624756, 1.542969, 1.455078, 1.365967, 1.307373, 1.243896}},
182 {{5.848389, 5.848389, 3.948975, 3.621826, 3.244629, 2.897949, 2.618408, 2.298584, 2.114258,
183 1.972656, 1.834717, 1.741943, 1.669922, 1.539307, 1.470947, 1.406250}}}};
191 m_cflFactor = {{{{2.448730, 2.420654, 2.171631, 1.834717, 1.652832, 1.497803, 1.369629, 1.246338, 1.151123,
192 1.071777, 1.015625, 0.959473, 0.904541, 0.856934, 0.814209, 0.783691}},
193 {{2.891846, 2.716064, 2.454112, 2.081513, 1.877617, 1.702831, 1.523950, 1.382303, 1.281892,
194 1.203783, 1.132922, 1.060420, 1.002581, 0.960691, 0.912857, 0.868814}}}};
197 m_cflFactor = {{{{5.277100, 5.277100, 3.908691, 3.056641, 2.852783, 2.486572, 2.232660, 2.036133, 1.865234,
198 1.748047, 1.624756, 1.542969, 1.455078, 1.365967, 1.307373, 1.243896}},
199 {{5.848389, 5.848389, 3.948975, 3.621826, 3.244629, 2.897949, 2.618408, 2.298584, 2.114258,
200 1.972656, 1.834717, 1.741943, 1.669922, 1.539307, 1.470947, 1.406250}}}};
208 m_cflFactor = {{{{2.448730, 2.420654, 2.171631, 1.834717, 1.652832, 1.497803, 1.369629, 1.246338, 1.151123,
209 1.071777, 1.015625, 0.959473, 0.904541, 0.856934, 0.814209, 0.783691}},
210 {{2.891846, 2.716064, 2.454112, 2.081513, 1.877617, 1.702831, 1.523950, 1.382303, 1.281892,
211 1.203783, 1.132922, 1.060420, 1.002581, 0.960691, 0.912857, 0.868814}}}};
214 m_cflFactor = {{{{5.277100, 5.277100, 3.908691, 3.056641, 2.852783, 2.486572, 2.232660, 2.036133, 1.865234,
215 1.748047, 1.624756, 1.542969, 1.455078, 1.365967, 1.307373, 1.243896}},
216 {{5.848389, 5.848389, 3.948975, 3.621826, 3.244629, 2.897949, 2.618408, 2.298584, 2.114258,
217 1.972656, 1.834717, 1.741943, 1.669922, 1.539307, 1.470947, 1.406250}}}};
252 const MFloat origin[] = {-F1, -F1, -F1};
255 const MFloat omega = F2 * PI * frequency / length;
256 MFloat compound = sin(omega * (x[0] - origin[0] - m_advectionVelocity[0] * t));
257 for(
MInt i = 1; i < nDim; i++) {
258 compound *=
cos(omega * (x[i] - origin[i] - F1B4 * length / frequency - m_advectionVelocity[i] * t));
260 const MFloat init = F2 + A * compound;
276 u[0] += x[0] - m_advectionVelocity[0] * t;
285 const MFloat origin[] = {F0, F0, F0};
287 for(
MInt i = 0; i < nDim; i++) {
288 xNormalized += pow(x[i] - origin[i] - m_advectionVelocity[i] * t, F2);
290 u[0] = pow(F2, -25.0 * xNormalized);
294 mTerm(1, AT_,
"The specified initial condition (" + std::to_string(this->
m_initialCondition) +
")is not valid!");
313 const MInt noNodes1D3 = (nDim == 3) ? noNodes1D : 1;
315 MFloatTensor f(flux, noNodes1D, noNodes1D, noNodes1D3, nDim);
317 for(
MInt i = 0; i < noNodes1D; i++) {
318 for(
MInt j = 0; j < noNodes1D; j++) {
319 for(
MInt k = 0; k < noNodes1D3; k++) {
320 for(
MInt l = 0; l < nDim; l++) {
321 f(i, j, k, l) = U(i, j, k) * m_advectionVelocity[l];
342 if(polyDeg > s_maxPolyDeg) {
343 TERMM(1,
"Polynomial degree exceeds maximum supported (" + std::to_string(s_maxPolyDeg) +
")!");
347 const MFloat factor = 0.95 * m_cflFactor[nDim - 2][polyDeg];
370 const MInt noNodes1D3 = (nDim == 3) ? noNodes1D : 1;
371 MFloatTensor sourceTerms(src, noNodes1D, noNodes1D, noNodes1D3);
383 mTerm(1, AT_,
"The specified source term is not valid!");
404 const MInt NotUsed(noNodes1D),
405 const MFloat* NotUsed(eta),
406 MFloat* NotUsed(src))
const {
407 mTerm(1, AT_,
"Sponge: Implementation for linear scalar adv. is missing");
424 const MInt noNodes1D,
const MFloat invJacobian,
425 const MInt sbpMode)
const {
428 for(
MInt n = 0; n < nDim; n++) {
429 maxLambda += fabs(m_advectionVelocity[n]);
435 dt = this->
cfl() * F2 / (invJacobian * maxLambda * (noNodes1D - 1));
437 const MInt polyDeg = noNodes1D - 1;
438 dt = this->
cflScaled(polyDeg) * cflFactor(polyDeg) * F2 / (invJacobian * maxLambda);
462 const MFloat* NotUsed(nodeVarsR),
465 const MInt noNodes1D,
468 const MInt noNodes1D3 = (nDim == 3) ? noNodes1D : 1;
473 const MFloat maxLambda = m_advectionVelocity[dirId];
477 for(
MInt i = 0; i < noNodes1D; i++) {
478 for(
MInt j = 0; j < noNodes1D3; j++) {
479 riemann(i, j) = F1B2 * ((maxLambda + fabs(maxLambda)) * uL(i, j) + (maxLambda - fabs(maxLambda)) * uR(i, j));
498 std::copy(cons, cons + 1, prim);
515 std::copy(prim, prim + 1, cons);
Base class for concrete system-of-equations classes (CRTP).
MFloat cflScaled(const MInt polyDeg) const
MFloat m_initialNumberWaves
MString m_dgIntegrationMethod
MFloat cflFactor(const MInt polyDeg) const
static const MString s_consVarNames[s_noVariables]
static const MInt s_maxPolyDeg
void primToCons(const MFloat *prim, MFloat *cons) const
Calculates a set of conservative variables from a set of primitive variables.
static constexpr const MString * s_nodeVarNames
static const MBool s_hasTimeDependentNodeVars
MBool extendNodeVar(const MInt NotUsed(varId)) const
static const MInt s_noNodeVars
std::array< std::array< MFloat, s_maxPolyDeg+1 >, 2 > m_cflFactor
static const MInt s_noVariables
void calcRiemann(const MFloat *nodeVarsL, const MFloat *nodeVarsR, const MFloat *stateL, const MFloat *stateR, const MInt noNodes1D, const MInt dirId, MFloat *flux) const
Calculates the numerical flux at a surface given two states (left and right).
void consToPrim(const MFloat *cons, MFloat *prim) const
Calculates a set of primitive variables from a set of conservative variables.
MInt m_dgTimeIntegrationScheme
void getDefaultNodeVars(MFloat *const NotUsed(nodeVars)) const
MFloat m_advectionVelocity[nDim]
static const MString s_sysEqnName
void calcSpongeSource(const MFloat *nodeVars, const MFloat *u, const MInt noNodes1D, const MFloat *eta, MFloat *src) const
Calculates the sponge source terms for all integration points within a cell.
void calcSource(const MFloat *nodeVars, const MFloat *u, const MInt noNodes1D, const MFloat t, const MFloat *x, MFloat *src) const
Calculates the source terms for all integration points within a cell.
static const MString s_primVarNames[s_noVariables]
void calcFlux(const MFloat *nodeVars, const MFloat *u, const MInt noNodes1D, MFloat *flux) const
Calculates the physical fluxes in all dimensions for all integrations points within a cell.
MFloat getTimeStep(const MFloat *nodeVars, const MFloat *u, const MInt noNodes1D, const MFloat invJacobian, const MInt sbpMode) const
Calculate the time step for an explicit time stepping scheme for a given element.
DgSysEqnLinearScalarAdv(MInt solverId)
Constructor calls parent constructor & loads all necessary properties for this equation.
void calcInitialCondition(const MFloat t, const MFloat *x, MFloat *nodeVars, MFloat *u) const
Calculate the initial condition for a certain point in space.
MInt string2enum(MString theString)
This global function translates strings in their corresponding enum values (integer values)....
@ DG_TIMEINTEGRATION_CARPENTER_4_5
@ DG_TIMEINTEGRATION_TOULORGEC_3_7
@ DG_TIMEINTEGRATION_TOULORGEC_4_8
@ DG_TIMEINTEGRATION_TOULORGEF_4_8
@ DG_TIMEINTEGRATION_NIEGEMANN_4_13
@ DG_TIMEINTEGRATION_NIEGEMANN_4_14
void mTerm(const MInt errorCode, const MString &location, const MString &message)
std::basic_string< char > MString
T cos(const T a, const T b, const T x)
Cosine slope filter.