7#ifndef DGSYSEQNACOUSTICPERTURB_H_
8#define DGSYSEQNACOUSTICPERTURB_H_
41 const MInt sbpMode)
const;
85 std::array<std::array<MFloat, s_maxPolyDeg + 1>, 2>
m_cflFactor;
101 static constexpr const MInt nDim = 2;
104 static constexpr const MInt U = 0;
105 static constexpr const MInt V = 1;
106 static constexpr const MInt UU[nDim] = {0, 1};
107 static constexpr const MInt P = nDim;
110 static constexpr const MInt U0 = 0;
111 static constexpr const MInt V0 = 1;
112 static constexpr const MInt UU0[nDim] = {0, 1};
113 static constexpr const MInt RHO0 = 2;
114 static constexpr const MInt C0 = 3;
115 static constexpr const MInt DC0_DX = 4;
116 static constexpr const MInt DC0_DY = 5;
117 static constexpr const MInt DC0[nDim] = {4, 5};
122 static constexpr const MInt nDim = 3;
125 static constexpr const MInt U = 0;
126 static constexpr const MInt V = 1;
127 static constexpr const MInt W = 2;
128 static constexpr const MInt UU[nDim] = {0, 1, 2};
129 static constexpr const MInt P = nDim;
132 static constexpr const MInt U0 = 0;
133 static constexpr const MInt V0 = 1;
134 static constexpr const MInt W0 = 2;
135 static constexpr const MInt UU0[nDim] = {0, 1, 2};
136 static constexpr const MInt RHO0 = 3;
137 static constexpr const MInt C0 = 4;
138 static constexpr const MInt DC0_DX = 5;
139 static constexpr const MInt DC0_DY = 6;
140 static constexpr const MInt DC0_DZ = 7;
141 static constexpr const MInt DC0[nDim] = {5, 6, 7};
211 m_log <<
"APE default mean variables: ";
255 m_log <<
"APE: compressible source term " << statusMsg << std::endl;
258 MString dgIntegrationMethod =
"DG_INTEGRATE_GAUSS";
260 Context::getSolverProperty<MString>(
"dgIntegrationMethod", this->
m_solverId, AT_, &dgIntegrationMethod);
263 MString dgTimeIntegrationScheme =
"DG_TIMEINTEGRATION_CARPENTER_4_5";
265 Context::getSolverProperty<MString>(
"dgTimeIntegrationScheme", this->
m_solverId, AT_, &dgTimeIntegrationScheme));
277 m_cflFactor = {{{{2.497559, 2.390137, 1.978760, 1.652832, 1.413574, 1.230469, 1.097168, 0.984375, 0.890625,
278 0.812988, 0.747070, 0.691406, 0.643066, 0.602051, 0.565430, 0.533203}},
279 {{2.976074, 2.574463, 2.055664, 1.697998, 1.444092, 1.251221, 1.123047, 1.003418, 0.904541,
280 0.827637, 0.758057, 0.700684, 0.650635, 0.607910, 0.570068, 0.537109}}}};
283 m_cflFactor = {{{{5.916748, 5.916748, 3.868408, 2.753906, 2.116699, 1.722412, 1.458984, 1.259766, 1.107422,
284 0.990234, 0.895020, 0.815918, 0.750000, 0.692871, 0.644531, 0.602051}},
285 {{7.445068, 7.445068, 4.113770, 2.825928, 2.176514, 1.760254, 1.502686, 1.293945, 1.131592,
286 1.008301, 0.906982, 0.823975, 0.756836, 0.698242, 0.649414, 0.606689}}}};
294 m_cflFactor = {{{{2.497559, 2.390137, 1.978760, 1.652832, 1.413574, 1.230469, 1.097168, 0.984375, 0.890625,
295 0.812988, 0.747070, 0.691406, 0.643066, 0.602051, 0.565430, 0.533203}},
296 {{2.976074, 2.574463, 2.055664, 1.697998, 1.444092, 1.251221, 1.123047, 1.003418, 0.904541,
297 0.827637, 0.758057, 0.700684, 0.650635, 0.607910, 0.570068, 0.537109}}}};
300 m_cflFactor = {{{{5.916748, 5.916748, 3.868408, 2.753906, 2.116699, 1.722412, 1.458984, 1.259766, 1.107422,
301 0.990234, 0.895020, 0.815918, 0.750000, 0.692871, 0.644531, 0.602051}},
302 {{7.445068, 7.445068, 4.113770, 2.825928, 2.176514, 1.760254, 1.502686, 1.293945, 1.131592,
303 1.008301, 0.906982, 0.823975, 0.756836, 0.698242, 0.649414, 0.606689}}}};
310 m_cflFactor = {{{{9.669311, 9.232117, 7.577270, 6.309753, 5.397094, 4.675781, 4.187561, 3.739929, 3.382751,
311 3.085876, 2.836548, 2.625488, 2.443419, 2.283385, 2.144226, 2.021301}},
312 {{13.695678, 10.427733, 7.956481, 6.546325, 5.566406, 4.791747, 4.311645, 3.826904, 3.447692,
313 3.163574, 2.896850, 2.667236, 2.480529, 2.314696, 2.169739, 2.042175}}}};
316 m_cflFactor = {{{{18.998840, 18.998840, 12.540649, 9.887329, 7.777893, 6.397888, 5.569885, 4.792907, 4.213073,
317 3.758484, 3.392029, 3.090515, 2.840026, 2.625488, 2.442260, 2.283385}},
318 {{18.998840, 18.998840, 17.312683, 11.183837, 8.501526, 6.825806, 5.831970, 5.017882, 4.361510,
319 3.876770, 3.475524, 3.154296, 2.889892, 2.662597, 2.473572, 2.307739}}}};
327 m_cflFactor = {{{{2.497559, 2.390137, 1.978760, 1.652832, 1.413574, 1.230469, 1.097168, 0.984375, 0.890625,
328 0.812988, 0.747070, 0.691406, 0.643066, 0.602051, 0.565430, 0.533203}},
329 {{2.976074, 2.574463, 2.055664, 1.697998, 1.444092, 1.251221, 1.123047, 1.003418, 0.904541,
330 0.827637, 0.758057, 0.700684, 0.650635, 0.607910, 0.570068, 0.537109}}}};
333 m_cflFactor = {{{{5.916748, 5.916748, 3.868408, 2.753906, 2.116699, 1.722412, 1.458984, 1.259766, 1.107422,
334 0.990234, 0.895020, 0.815918, 0.750000, 0.692871, 0.644531, 0.602051}},
335 {{7.445068, 7.445068, 4.113770, 2.825928, 2.176514, 1.760254, 1.502686, 1.293945, 1.131592,
336 1.008301, 0.906982, 0.823975, 0.756836, 0.698242, 0.649414, 0.606689}}}};
344 m_cflFactor = {{{{2.497559, 2.390137, 1.978760, 1.652832, 1.413574, 1.230469, 1.097168, 0.984375, 0.890625,
345 0.812988, 0.747070, 0.691406, 0.643066, 0.602051, 0.565430, 0.533203}},
346 {{2.976074, 2.574463, 2.055664, 1.697998, 1.444092, 1.251221, 1.123047, 1.003418, 0.904541,
347 0.827637, 0.758057, 0.700684, 0.650635, 0.607910, 0.570068, 0.537109}}}};
350 m_cflFactor = {{{{5.916748, 5.916748, 3.868408, 2.753906, 2.116699, 1.722412, 1.458984, 1.259766, 1.107422,
351 0.990234, 0.895020, 0.815918, 0.750000, 0.692871, 0.644531, 0.602051}},
352 {{7.445068, 7.445068, 4.113770, 2.825928, 2.176514, 1.760254, 1.502686, 1.293945, 1.131592,
353 1.008301, 0.906982, 0.823975, 0.756836, 0.698242, 0.649414, 0.606689}}}};
361 m_cflFactor = {{{{2.497559, 2.390137, 1.978760, 1.652832, 1.413574, 1.230469, 1.097168, 0.984375, 0.890625,
362 0.812988, 0.747070, 0.691406, 0.643066, 0.602051, 0.565430, 0.533203}},
363 {{2.976074, 2.574463, 2.055664, 1.697998, 1.444092, 1.251221, 1.123047, 1.003418, 0.904541,
364 0.827637, 0.758057, 0.700684, 0.650635, 0.607910, 0.570068, 0.537109}}}};
367 m_cflFactor = {{{{5.916748, 5.916748, 3.868408, 2.753906, 2.116699, 1.722412, 1.458984, 1.259766, 1.107422,
368 0.990234, 0.895020, 0.815918, 0.750000, 0.692871, 0.644531, 0.602051}},
369 {{7.445068, 7.445068, 4.113770, 2.825928, 2.176514, 1.760254, 1.502686, 1.293945, 1.131592,
370 1.008301, 0.906982, 0.823975, 0.756836, 0.698242, 0.649414, 0.606689}}}};
413 std::fill_n(&nodeVars[
CV::DC0[0]], nDim, 0.0);
422 const MFloat freestreamMa = 0.3;
427 if(yPos < 1.0 && yPos > 0.0) {
428 u0 = freestreamMa * (2 * yPos - 2 * pow(yPos, 3) + pow(yPos, 4));
429 }
else if(yPos >= 1.0) {
438 std::fill_n(&nodeVars[
CV::DC0[0]], nDim, 0.0);
453 std::fill_n(&nodeVars[
CV::DC0[0]], nDim, 0.0);
474 const MFloat omega = F2 * PI * frequency / length;
475 const MFloat init = c + A * sin(omega * std::accumulate(x, x + nDim, -
a * t));
478 for(
MInt i = 0; i < nDim; i++) {
481 u[
CV::P] = init * init;
488 std::fill_n(&nodeVars[
CV::DC0[0]], nDim, 0.0);
498 for(
MInt i = 0; i < nDim; i++) {
505 const MFloat T_inf = 1.0 / (1.0 + (kappa - 1.0) * 0.5 * mach * mach);
506 const MFloat c_inf = sqrt(T_inf);
507 const MFloat rho_inf = pow(T_inf, 1.0 / (kappa - 1.0));
516 std::fill_n(&nodeVars[
CV::DC0[0]], nDim, 0.0);
533 u[
CV::P] = exp(-log(2.0) / 9.0 * (x[0] * x[0] + x[1] * x[1]));
540 std::fill_n(&nodeVars[
CV::DC0[0]], nDim, 0.0);
551 u[
CV::P] = 2.0 - exp(-1.0 / 0.25 * (x[0] * x[0] + x[1] * x[1]));
558 std::fill_n(&nodeVars[
CV::DC0[0]], nDim, 0.0);
569 u[
CV::P] = 2.0 - exp(-1.0 / 0.25 * ((x[0] + 7.5) * (x[0] + 7.5) + x[1] * x[1]));
576 std::fill_n(&nodeVars[
CV::DC0[0]], nDim, 0.0);
586 for(
MInt i = 0; i < nDim; i++) {
594 u[
CV::P] = 2.0 - exp(-1.0 / 2.0 * (x[0] * x[0] + x[1] * x[1] + x[2] * x[2]));
601 std::fill_n(&nodeVars[
CV::DC0[0]], nDim, 0.0);
611 for(
MInt i = 0; i < nDim; i++) {
615 u[
CV::P] = exp(-1.0 / 2.0 * (x[0] * x[0] + x[1] * x[1] + x[2] * x[2]));
622 std::fill_n(&nodeVars[
CV::DC0[0]], nDim, 0.0);
632 for(
MInt i = 0; i < nDim; i++) {
636 u[
CV::P] = 2.0 - exp(-1.0 / 2.0 * ((x[0] + 7.5) * (x[0] + 7.5) + x[1] * x[1] + x[2] * x[2]));
643 std::fill_n(&nodeVars[
CV::DC0[0]], nDim, 0.0);
654 for(
MInt i = 0; i < nDim; i++) {
659 const MFloat r = x[0] * x[0] + x[1] * x[1] + (x[2] + 45.0) * (x[2] + 45.0);
660 u[
CV::P] = exp(1 + 0.28 * exp(-r / (2.5))) - exp(1.0);
667 std::fill_n(&nodeVars[
CV::DC0[0]], nDim, 0.0);
677 for(
MInt i = 0; i < nDim; i++) {
682 u[
CV::P] = exp(-1.0 * log(2.0) / 25 * (x[0] * x[0] + (x[1] - 25.0) * (x[1] - 25.0)));
689 std::fill_n(&nodeVars[
CV::DC0[0]], nDim, 0.0);
699 u[
CV::U] = sin(PI * x[0]);
701 u[
CV::P] = sin(PI * x[0]);
708 std::fill_n(&nodeVars[
CV::DC0[0]], nDim, 0.0);
725 for(
MInt i = 0; i < nDim; i++) {
743 MBool pointInBox =
true;
744 for(
MInt dim = 0; dim < nDim; dim++) {
745 if(fabs(x[dim]) > 0.75) {
752 const MFloat delOmega = 0.05 * r0;
754 for(
MInt dim = 1; dim < nDim; dim++) {
755 rTemp += x[dim] * x[dim];
757 const MFloat r = sqrt(rTemp);
758 nodeVars[
CV::U0] = uj * (0.5 + 0.5 * tanh((r0 - r) / (2.0 * delOmega)));
759 nodeVars[
CV::V0] = 0.3 * (1.0 + 0.1 * x[1]);
763 std::fill_n(&nodeVars[
CV::DC0[0]], nDim, 0.1);
766 std::fill_n(&nodeVars[
CV::UU0[0]], nDim, 0.0);
769 std::fill_n(&nodeVars[
CV::DC0[0]], nDim, 0.0);
782 const MFloat delOmega = 0.05 * r0;
784 for(
MInt dim = 1; dim < nDim; dim++) {
785 rTemp += x[dim] * x[dim];
787 const MFloat r = sqrt(rTemp);
793 std::fill_n(&nodeVars[
CV::DC0[0]], nDim, 0.0);
798 nodeVars[
CV::U0] = uj * (0.5 + 0.5 * tanh((r0 - r) / (2.0 * delOmega)));
810 mTerm(1, AT_,
"The specified initial condition (" + std::to_string(this->
m_initialCondition) +
") is not valid!");
829 const MInt noNodes1D,
830 MFloat*
const flux)
const {
833 const MInt noNodes1D3 = (nDim == 3) ? noNodes1D : 1;
859 for(
MInt i = 0; i < noNodes1D; i++) {
860 for(
MInt j = 0; j < noNodes1D; j++) {
861 for(
MInt k = 0; k < noNodes1D3; k++) {
862 for(
MInt d = 0; d < nDim; d++) {
864 for(
MInt fd = 0; fd < nDim; fd++) {
865 f(i, j, k, d,
CV::UU[fd]) = 0.0;
867 f(i, j, k, d,
CV::UU[d]) = std::inner_product(&U0(i, j, k,
CV::UU0[0]),
868 &U0(i, j, k,
CV::UU0[0]) + nDim,
873 f(i, j, k, d,
CV::P) = U0(i, j, k,
CV::RHO0) *
POW2(U0(i, j, k,
CV::C0)) * U(i, j, k,
CV::UU[d])
898 const MInt noNodes1D,
900 MFloat*
const flux)
const {
903 const MInt noNodes1D3 = (nDim == 3) ? noNodes1D : 1;
908 for(
MInt i = 0; i < noNodes1D; i++) {
909 for(
MInt j = 0; j < noNodes1D3; j++) {
911 for(
MInt d = 0; d < nDim; d++) {
913 f(i, j,
CV::UU[d]) = std::inner_product(&U0(i, j,
CV::UU0[0]),
944 TERMM(1,
"Polynomial degree exceeds maximum supported");
971 MFloat*
const src)
const {
972 const MInt noNodes1D3 = (nDim == 3) ? noNodes1D : 1;
990 mTerm(1, AT_,
"The APE-1 sources are not yet implemented!");
996 mTerm(1, AT_,
"The APE-2 sources are not yet implemented!");
1002 mTerm(1, AT_,
"The APE-3 sources are not yet implemented!");
1008 mTerm(1, AT_,
"The APE-4 sources are not yet implemented!");
1029 const MFloat length = F2;
1034 const MFloat omega = F2 * PI * frequency / length;
1036 for(
MInt i = 0; i < noNodes1D; i++) {
1037 for(
MInt j = 0; j < noNodes1D; j++) {
1038 for(
MInt k = 0; k < noNodes1D3; k++) {
1039 const MFloat sumX = std::accumulate(&X(i, j, k, 0), &X(i, j, k, 0) + nDim, F0);
1040 const MFloat inner = omega * (sumX -
a * t);
1041 const MFloat sumVelBarMa = std::accumulate(&U0(i, j, k,
CV::UU0[0]), &U0(i, j, k,
CV::UU0[0]) + nDim, -
a);
1042 const MFloat F2sinA = F2 * sin(inner) * A;
1046 for(
MInt n = 0; n < nDim; n++) {
1047 s(i, j, k,
CV::UU[n]) = omega * cosA * (F2 * c + sumVelBarMa + F2sinA);
1050 s(i, j, k,
CV::P) = omega * cosA * (nDim + F2 * c * sumVelBarMa + sumVelBarMa * F2sinA);
1062 const MFloat pos[3] = {0.0, 0.0, 0.0};
1067 const MFloat factor = A * sin(2 * PI * f * t);
1068 const MFloat expFactor = -1.0 / (2 * r * r);
1070 for(
MInt i = 0; i < noNodes1D; i++) {
1071 for(
MInt j = 0; j < noNodes1D; j++) {
1072 for(
MInt k = 0; k < noNodes1D3; k++) {
1074 std::fill_n(&s(i, j, k,
CV::UU[0]), nDim, F0);
1078 for(
MInt n = 0; n < nDim; n++) {
1079 distSquared +=
POW2(X(i, j, k, n) - pos[n]);
1083 s(i, j, k,
CV::P) = factor * exp(expFactor * distSquared);
1095 const MFloat pos[3] = {25.0, 0.0, 0.0};
1100 const MFloat factor = A * sin(2 * PI * f * t);
1101 const MFloat expFactor = -1.0 / (2 * r * r);
1103 for(
MInt i = 0; i < noNodes1D; i++) {
1104 for(
MInt j = 0; j < noNodes1D; j++) {
1105 for(
MInt k = 0; k < noNodes1D3; k++) {
1107 std::fill_n(&s(i, j, k,
CV::UU[0]), nDim, F0);
1111 for(
MInt n = 0; n < nDim; n++) {
1112 distSquared +=
POW2(X(i, j, k, n) - pos[n]);
1116 s(i, j, k,
CV::P) = factor * exp(expFactor * distSquared);
1124 TERMM(1,
"dipole source needs testing");
1131 const MFloat pos1[3] = {-0.5 * d, 0.0, 0.0};
1132 const MFloat pos2[3] = {0.5 * d, 0.0, 0.0};
1139 const MFloat factor1 = A * sin(2 * PI * f * t);
1140 const MFloat factor2 = A * sin(2 * PI * (f * t + 0.5));
1142 const MFloat expFactor = -1.0 / (2 * r * r);
1144 for(
MInt i = 0; i < noNodes1D; i++) {
1145 for(
MInt j = 0; j < noNodes1D; j++) {
1146 for(
MInt k = 0; k < noNodes1D3; k++) {
1148 std::fill_n(&s(i, j, k,
CV::UU[0]), nDim, F0);
1151 MFloat distSquared1 = F0;
1152 MFloat distSquared2 = F0;
1153 for(
MInt n = 0; n < nDim; n++) {
1154 distSquared1 +=
POW2(X(i, j, k, n) - pos1[n]);
1155 distSquared2 +=
POW2(X(i, j, k, n) - pos2[n]);
1159 s(i, j, k,
CV::P) = factor1 * exp(expFactor * distSquared1) + factor2 * exp(expFactor * distSquared2);
1168 const MFloat freq = 20.0;
1169 const MFloat omega = 2.0 * PI * freq;
1171 const MFloat alpha = std::log(2.0) / 2.0;
1172 const MFloat x_s = 125.0;
1175 for(
MInt i = 0; i < noNodes1D; i++) {
1176 for(
MInt j = 0; j < noNodes1D; j++) {
1177 for(
MInt k = 0; k < noNodes1D3; k++) {
1179 const MFloat x_norm = X(i, j, k, 0) - x_s;
1180 const MFloat y_norm = X(i, j, k, 1) - y_s;
1181 const MFloat f = eps * std::exp(-alpha * (x_norm * x_norm + y_norm * y_norm));
1184 const MFloat source = f * std::sin(omega * t);
1185 s(i, j, k,
CV::U) = source;
1186 s(i, j, k,
CV::V) = source;
1187 s(i, j, k,
CV::P) = 0.0;
1196 const MFloat freq = 1.0 / 5.0;
1197 const MFloat omega = 2.0 * PI * freq;
1199 const MFloat alpha = std::log(2.0) / 2.0;
1200 const MFloat x_s = 125.0;
1203 for(
MInt i = 0; i < noNodes1D; i++) {
1204 for(
MInt j = 0; j < noNodes1D; j++) {
1205 for(
MInt k = 0; k < noNodes1D3; k++) {
1207 const MFloat x_norm = X(i, j, k, 0) - x_s;
1208 const MFloat y_norm = X(i, j, k, 1) - y_s;
1209 const MFloat f = eps * std::exp(-alpha * (x_norm * x_norm + y_norm * y_norm));
1212 const MFloat source = f * std::sin(omega * t);
1213 s(i, j, k,
CV::U) = source;
1214 s(i, j, k,
CV::V) = 0.0;
1215 s(i, j, k,
CV::P) = 0.0;
1223 TERMM_IF_COND(nDim == 3,
"only useful in 2D");
1231 const MFloat gamma = 1.0;
1232 const MFloat sigma = 1.0;
1233 const MFloat omega = gamma / 4. / PI;
1234 const MFloat alpha = gamma * gamma / 8 / PI / PI / sigma / sigma;
1235 const MFloat theta = omega * t;
1236 const MFloat bx = std::cos(theta);
1237 const MFloat by = std::sin(theta);
1252 const MFloat filterSlopeWidth = Context::getSolverProperty<MFloat>(
"filterSlopeWidth", this->
m_solverId, AT_);
1254 std::array<MFloat, nDim> filterRegionMin{};
1255 std::array<MFloat, nDim> filterRegionMax{};
1256 for(
MInt i = 0; i < 2; i++) {
1257 filterRegionMin[i] = Context::getSolverProperty<MFloat>(
"filterRegionMin", this->
m_solverId, AT_, i);
1258 filterRegionMax[i] = Context::getSolverProperty<MFloat>(
"filterRegionMax", this->
m_solverId, AT_, i);
1262 for(
MInt i = 0; i < noNodes1D; i++) {
1263 for(
MInt j = 0; j < noNodes1D; j++) {
1265 const MFloat rxPos = X(i, j, 0, 0) - bx;
1266 const MFloat ryPos = X(i, j, 0, 1) - by;
1267 const MFloat rPos = std::sqrt(rxPos * rxPos + ryPos * ryPos);
1268 const MFloat rxNeg = X(i, j, 0, 0) + bx;
1269 const MFloat ryNeg = X(i, j, 0, 1) + by;
1270 const MFloat rNeg = std::sqrt(rxNeg * rxNeg + ryNeg * ryNeg);
1272 alpha * (std::exp(-rPos * rPos / 2. / sigma / sigma) - std::exp(-rNeg * rNeg / 2. / sigma / sigma));
1273 const MFloat qmEwertX = qmEwert * std::cos(theta);
1274 const MFloat qmEwertY = qmEwert * std::sin(theta);
1277 const MFloat filter = maia::filter::slope::cosbox<nDim>(&filterRegionMin[0], &filterRegionMax[0],
1278 filterSlopeWidth, &X(i, j, 0, 0));
1281 s(i, j, 0,
CV::U) = filter * qmEwertX;
1282 s(i, j, 0,
CV::V) = filter * qmEwertY;
1283 s(i, j, 0,
CV::P) = 0.0;
1290 mTerm(1, AT_,
"The specified source term is not valid!");
1300 for(
MInt i = 0; i < noNodes1D; i++) {
1301 for(
MInt j = 0; j < noNodes1D; j++) {
1302 for(
MInt k = 0; k < noNodes1D3; k++) {
1303 for(
MInt dim = 0; dim < nDim; dim++) {
1304 s(i, j, k,
CV::P) += 2
1330 const MInt noNodes1D3 = (nDim == 3) ? noNodes1D : 1;
1333 MFloat gammaMinusOne = 5.0 / 3.0 - 1.0;
1334 MFloat FgammaMinusOne = 1.0 / gammaMinusOne;
1336 const MFloatTensor spongeEta(
const_cast<MFloat*
>(eta), noNodes1D, noNodes1D, noNodes1D3);
1340 for(
MInt i = 0; i < noNodes1D; i++) {
1341 for(
MInt j = 0; j < noNodes1D; j++) {
1342 for(
MInt k = 0; k < noNodes1D3; k++) {
1346 for(
MInt l = 0; l < nDim; l++) {
1347 spongeSource(i, j, k,
CV::UU[l]) = 0.0;
1369 const MFloat*
const NotUsed(u),
1370 const MInt noNodes1D,
1371 const MFloat invJacobian,
1372 const MInt sbpMode)
const {
1375 const MInt noNodes1D3 = (nDim == 3) ? noNodes1D : 1;
1376 const MFloat inf = std::numeric_limits<MFloat>::infinity();
1379 MFloat maxLambda[] = {-inf, -inf, -inf};
1380 for(
MInt i = 0; i < noNodes1D; i++) {
1381 for(
MInt j = 0; j < noNodes1D; j++) {
1382 for(
MInt k = 0; k < noNodes1D3; k++) {
1383 for(
MInt d = 0; d < nDim; d++) {
1384 maxLambda[d] = std::max(maxLambda[d], fabs(U0(i, j, k,
CV::UU0[d])) + U0(i, j, k,
CV::C0));
1392 dt = this->
cfl() * F2 / (invJacobian * std::accumulate(&maxLambda[0], &maxLambda[0] + nDim, F0) * (noNodes1D - 1));
1394 const MInt polyDeg = noNodes1D - 1;
1396 / (invJacobian * std::accumulate(&maxLambda[0], &maxLambda[0] + nDim, F0));
1427 const MInt noNodes1D,
1442 TERMM(1,
"Implementation does not work for internal fluxes, see comments");
1443 calcRiemannRoe(nodeVarsL, nodeVarsR, stateL, stateR, noNodes1D, dirId, flux);
1448 mTerm(1, AT_,
"The specified Riemann solver is not valid!");
1465 const MInt noNodes1D,
1470 const MInt noNodes1D3 = (nDim == 3) ? noNodes1D : 1;
1484 for(
MInt i = 0; i < noNodes1D; i++) {
1485 for(
MInt j = 0; j < noNodes1D3; j++) {
1486 maxLambda(i, j) = std::max(fabs(nL(i, j,
CV::UU0[dirId])) + nL(i, j,
CV::C0),
1500 calcFlux1D(nodeVarsL, stateL, noNodes1D, dirId, &fluxL[0]);
1501 calcFlux1D(nodeVarsR, stateR, noNodes1D, dirId, &fluxR[0]);
1505 for(
MInt i = 0; i < noNodes1D; i++) {
1506 for(
MInt j = 0; j < noNodes1D3; j++) {
1508 riemann(i, j, n) = 0.5 * ((fluxL(i, j, n) + fluxR(i, j, n)) - maxLambda(i, j) * (uR(i, j, n) - uL(i, j, n)));
1536 const MInt noNodes1D,
1541 const MInt nDim = 2;
1554 const std::array<MInt, nDim> n = {{1 - dirId, dirId}};
1557 for(
MInt i = 0; i < noNodes1D; i++) {
1561 const std::array<MFloat, nDim> meanVelocity = {
1565 const std::array<MFloat, nDim> um = {
1566 {meanVelocity[0] * n[0] + meanVelocity[1] * n[1], -meanVelocity[0] * n[1] + meanVelocity[1] * n[0]}};
1570 const std::array<MFloat, nDim> vecL = {
1572 const std::array<MFloat, nDim> vecR = {
1577 const MFloat L1 = 0.5 * (uR(i,
CV::P) + rho * c * (-vecR[0] + um[1] / (um[0] - c) * (-vecR[1])));
1578 const MFloat L2 = 0.5 * (uL(i,
CV::P) + rho * c * (vecL[0] + um[1] / (um[0] + c) * vecL[1]));
1581 f(i,
CV::P) = (um[0] - c) * (L1) + (um[0] + c) * (L2);
1582 f(i,
CV::UU[0]) = 1 / rho / c * (-1 * ((um[0] - c) * L1) + ((um[0] + c) * L2)) * n[0];
1583 f(i,
CV::UU[1]) = 1 / rho / c * (-1 * ((um[0] - c) * L1) + ((um[0] + c) * L2)) * n[1];
1610 const MInt noNodes1D,
1615 const MInt nDim = 3;
1628 const std::array<MInt, nDim> n = {{dirId == 0 ? 1 : 0, dirId == 1 ? 1 : 0, dirId == 2 ? 1 : 0}};
1632 for(
MInt i = 0; i < noNodes1D; i++) {
1633 for(
MInt j = 0; j < noNodes1D; j++) {
1637 const std::array<MFloat, nDim> meanVelocity = {{0.5 * (nL(i, j,
CV::U0) + nR(i, j,
CV::U0)),
1642 const std::array<MFloat, nDim> um = {{meanVelocity[0] * n[0] + meanVelocity[1] * n[1] + meanVelocity[2] * n[2],
1643 meanVelocity[0] * n[1] + meanVelocity[1] * n[2] + meanVelocity[2] * n[0],
1644 meanVelocity[0] * n[2] + meanVelocity[1] * n[0] + meanVelocity[2] * n[1]}};
1646 const std::array<MFloat, nDim> vecL = {
1647 {uL(i, j,
CV::UU[0]) * n[0] + uL(i, j,
CV::UU[1]) * n[1] + uL(i, j,
CV::UU[2]) * n[2],
1648 uL(i, j,
CV::UU[0]) * n[1] + uL(i, j,
CV::UU[1]) * n[2] + uL(i, j,
CV::UU[2]) * n[0],
1649 uL(i, j,
CV::UU[0]) * n[2] + uL(i, j,
CV::UU[1]) * n[0] + uL(i, j,
CV::UU[2]) * n[1]}};
1651 const std::array<MFloat, nDim> vecR = {
1652 {uR(i, j,
CV::UU[0]) * n[0] + uR(i, j,
CV::UU[1]) * n[1] + uR(i, j,
CV::UU[2]) * n[2],
1653 uR(i, j,
CV::UU[0]) * n[1] + uR(i, j,
CV::UU[1]) * n[2] + uR(i, j,
CV::UU[2]) * n[0],
1654 uR(i, j,
CV::UU[0]) * n[2] + uR(i, j,
CV::UU[1]) * n[0] + uR(i, j,
CV::UU[2]) * n[1]}};
1661 + rho * c * (-vecL[0] + um[1] / (um[0] - c) * (-vecL[1]) + um[2] / (um[0] - c) * (-vecL[2])));
1664 * (uL(i, j,
CV::P) + rho * c * (vecR[0] + um[1] / (um[0] + c) * vecR[1] + um[2] / (um[0] + c) * (vecR[2])));
1666 f(i, j,
CV::P) = (um[0] - c) * (L1) + (um[0] + c) * (L2);
1667 f(i, j,
CV::UU[0]) = 1 / rho / c * (-1 * ((um[0] - c) * L1) + ((um[0] + c) * L2)) * n[0];
1668 f(i, j,
CV::UU[1]) = 1 / rho / c * (-1 * ((um[0] - c) * L1) + ((um[0] + c) * L2)) * n[1];
1669 f(i, j,
CV::UU[2]) = 1 / rho / c * (-1 * ((um[0] - c) * L1) + ((um[0] + c) * L2)) * n[2];
1724 std::fill_n(&nodeVars[
CV::DC0[0]], nDim, 0.0);
1732 std::fill_n(&nodeVars[
CV::UU0[0]], nDim, 0.0);
1738 std::fill_n(&nodeVars[
CV::DC0[0]], nDim, 0.0);
1746 if(varId ==
CV::C0)
return false;
1747 for(
MInt i = 0; i < nDim; i++) {
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 getDefaultNodeVars(MFloat *const nodeVars) const
Return the default node variables.
DgSysEqnAcousticPerturb(MInt solverId)
Constructor calls parent constructor & loads all necessary properties for this equation.
void primToCons(const MFloat *prim, MFloat *cons) const
Calculates a set of conservative variables from a set of primitive variables.
MString m_dgIntegrationMethod
static const MInt s_noNodeVars
static const MBool s_hasTimeDependentNodeVars
static const MInt s_noVariables
MInt m_dgTimeIntegrationScheme
void calcInitialCondition(const MFloat t, const MFloat *x, MFloat *const nodeVars, MFloat *u) const
Calculate the initial condition for a certain point in space.
void calcFlux(const MFloat *const nodeVars, const MFloat *const q, const MInt noNodes1D, MFloat *const flux) const
Calculates the physical fluxes in all dimensions for all integrations points within a cell.
static const MString s_primVarNames[s_noVariables]
MFloat cflFactor(const MInt polyDeg) const
void calcRiemannLaxFriedich(const MFloat *nodeVarsL, const MFloat *nodeVarsR, const MFloat *stateL, const MFloat *stateR, const MInt noNodes1D, const MInt dirId, MFloat *flux) const
Calculate Riemann flux using the local Lax-Friedrichs flux scheme.
void calcFlux1D(const MFloat *const nodeVars, const MFloat *const q, const MInt noNodes1D, const MInt dirId, MFloat *const flux) const
Calculates the physical fluxes in dimension dirId for all integrations points on an element face.
std::array< std::array< MFloat, s_maxPolyDeg+1 >, 2 > m_cflFactor
static const MString s_sysEqnName
MFloat getTimeStep(const MFloat *nodeVars, const MFloat *const 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.
MBool m_constantSpeedOfSound
MFloat m_spongePressureInfy
MBool extendNodeVar(const MInt varId) const
Return if the given node variable should be extended.
MBool m_compressibleSourceTerm
void getDefaultNodeVarsBody(MFloat *const nodeVars) const
Return the default node variables inside a body.
void calcSource(const MFloat *const nodeVars, const MFloat *const u, const MInt noNodes1D, const MFloat t, const MFloat *const x, MFloat *const src) const
Calculates the source terms for all integration points within a cell.
void calcRiemannRoe(const MFloat *nodeVarsL, const MFloat *nodeVarsR, const MFloat *stateL, const MFloat *stateR, const MInt noNodes1D, const MInt dirId, MFloat *flux) const
void consToPrim(const MFloat *cons, MFloat *prim) const
Calculates a set of primitive variables from a set of conservative variables.
static const MInt s_maxPolyDeg
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.
static const MString s_nodeVarNames[s_noNodeVars]
std::array< MFloat, nDim > m_meanVelocity
MFloat m_meanSpeedOfSound
static const MString s_consVarNames[s_noVariables]
Base class for concrete system-of-equations classes (CRTP).
MFloat cflScaled(const MInt polyDeg) const
static constexpr MInt noVars()
MFloat m_initialNumberWaves
static constexpr MInt noNodeVars()
This class is a ScratchSpace.
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)
constexpr Real POW2(const Real x)
std::basic_string< char > MString
T cos(const T a, const T b, const T x)
Cosine slope filter.
static constexpr const MInt U0
static constexpr const MInt W0
static constexpr const MInt nDim
static constexpr const MInt P
static constexpr const MInt V0
static constexpr const MInt RHO0
static constexpr const MInt UU0[nDim]
static constexpr const MInt V
static constexpr const MInt DC0[nDim]
static constexpr const MInt UU[nDim]
static constexpr const MInt C0
static constexpr const MInt U