40 #include <boost/core/ignore_unused.hpp>
41 #include <boost/math/special_functions/gamma.hpp>
51 std::string DiffusionLFR::type[] = {
59 "LFRcmin", DiffusionLFR::create,
"LFRcmin"),
61 "LFRcinf", DiffusionLFR::create,
"LFRcinf")};
71 DiffusionLFR::DiffusionLFR(std::string diffType) : m_diffType(diffType)
95 int nConvectiveFields = pFields.size();
96 int nDim = pFields[0]->GetCoordim(0);
97 int nSolutionPts = pFields[0]->GetTotPoints();
98 int nTracePts = pFields[0]->GetTrace()->GetTotPoints();
118 for (i = 0; i < nConvectiveFields; ++i)
134 for (j = 0; j < nDim; ++j)
170 boost::ignore_unused(pSession);
175 int nLocalSolutionPts;
176 int nElements = pFields[0]->GetExpSize();
177 int nDimensions = pFields[0]->GetCoordim(0);
178 int nSolutionPts = pFields[0]->GetTotPoints();
179 int nTracePts = pFields[0]->GetTrace()->GetTotPoints();
182 for (i = 0; i < nDimensions; ++i)
201 for (n = 0; n < nElements; ++n)
203 ptsKeys = pFields[0]->GetExp(n)->GetPointsKeys();
204 nLocalSolutionPts = pFields[0]->GetExp(n)->GetTotPoints();
205 phys_offset = pFields[0]->GetPhys_Offset(n);
212 for (i = 0; i < nLocalSolutionPts; ++i)
214 m_jac[i + phys_offset] = jac[0];
232 for (n = 0; n < nElements; ++n)
234 base = pFields[0]->GetExp(n)->GetBase();
235 nquad0 = base[0]->GetNumPoints();
236 nquad1 = base[1]->GetNumPoints();
244 pFields[0]->GetExp(n)->GetTraceQFactors(0, auxArray1 =
246 pFields[0]->GetExp(n)->GetTraceQFactors(1, auxArray1 =
248 pFields[0]->GetExp(n)->GetTraceQFactors(2, auxArray1 =
250 pFields[0]->GetExp(n)->GetTraceQFactors(3, auxArray1 =
253 ptsKeys = pFields[0]->GetExp(n)->GetPointsKeys();
254 nLocalSolutionPts = pFields[0]->GetExp(n)->GetTotPoints();
255 phys_offset = pFields[0]->GetPhys_Offset(n);
268 ->GetDerivFactors(ptsKeys);
277 for (i = 0; i < nLocalSolutionPts; ++i)
279 m_jac[i + phys_offset] = jac[i];
280 m_gmat[0][i + phys_offset] = gmat[0][i];
281 m_gmat[1][i + phys_offset] = gmat[1][i];
282 m_gmat[2][i + phys_offset] = gmat[2][i];
283 m_gmat[3][i + phys_offset] = gmat[3][i];
288 for (i = 0; i < nLocalSolutionPts; ++i)
290 m_jac[i + phys_offset] = jac[0];
291 m_gmat[0][i + phys_offset] = gmat[0][0];
292 m_gmat[1][i + phys_offset] = gmat[1][0];
293 m_gmat[2][i + phys_offset] = gmat[2][0];
294 m_gmat[3][i + phys_offset] = gmat[3][0];
302 ASSERTL0(
false,
"3DFR Metric terms not implemented yet");
307 ASSERTL0(
false,
"Expansion dimension not recognised");
333 boost::ignore_unused(pSession);
339 int nquad0, nquad1, nquad2;
340 int nmodes0, nmodes1, nmodes2;
343 int nElements = pFields[0]->GetExpSize();
344 int nDim = pFields[0]->GetCoordim(0);
353 for (n = 0; n < nElements; ++n)
355 base = pFields[0]->GetExp(n)->GetBase();
356 nquad0 = base[0]->GetNumPoints();
357 nmodes0 = base[0]->GetNumModes();
361 base[0]->GetZW(z0, w0);
373 int p0 = nmodes0 - 1;
379 NekDouble ap0 = boost::math::tgamma(2 * p0 + 1) /
380 (pow(2.0, p0) * boost::math::tgamma(p0 + 1) *
381 boost::math::tgamma(p0 + 1));
391 ((2.0 * p0 + 1.0) * (p0 + 1.0) *
392 (ap0 * boost::math::tgamma(p0 + 1)) *
393 (ap0 * boost::math::tgamma(p0 + 1)));
397 c0 = 2.0 * (p0 + 1.0) /
398 ((2.0 * p0 + 1.0) * p0 *
399 (ap0 * boost::math::tgamma(p0 + 1)) *
400 (ap0 * boost::math::tgamma(p0 + 1)));
404 c0 = -2.0 / ((2.0 * p0 + 1.0) *
405 (ap0 * boost::math::tgamma(p0 + 1)) *
406 (ap0 * boost::math::tgamma(p0 + 1)));
410 c0 = 10000000000000000.0;
413 NekDouble etap0 = 0.5 * c0 * (2.0 * p0 + 1.0) *
414 (ap0 * boost::math::tgamma(p0 + 1)) *
415 (ap0 * boost::math::tgamma(p0 + 1));
417 NekDouble overeta0 = 1.0 / (1.0 + etap0);
430 for (i = 0; i < nquad0; ++i)
440 for (i = 0; i < nquad0; ++i)
463 for (n = 0; n < nElements; ++n)
465 base = pFields[0]->GetExp(n)->GetBase();
466 nquad0 = base[0]->GetNumPoints();
467 nquad1 = base[1]->GetNumPoints();
468 nmodes0 = base[0]->GetNumModes();
469 nmodes1 = base[1]->GetNumModes();
476 base[0]->GetZW(z0, w0);
477 base[1]->GetZW(z1, w1);
494 int p0 = nmodes0 - 1;
495 int p1 = nmodes1 - 1;
502 NekDouble ap0 = boost::math::tgamma(2 * p0 + 1) /
503 (pow(2.0, p0) * boost::math::tgamma(p0 + 1) *
504 boost::math::tgamma(p0 + 1));
506 NekDouble ap1 = boost::math::tgamma(2 * p1 + 1) /
507 (pow(2.0, p1) * boost::math::tgamma(p1 + 1) *
508 boost::math::tgamma(p1 + 1));
519 ((2.0 * p0 + 1.0) * (p0 + 1.0) *
520 (ap0 * boost::math::tgamma(p0 + 1)) *
521 (ap0 * boost::math::tgamma(p0 + 1)));
524 ((2.0 * p1 + 1.0) * (p1 + 1.0) *
525 (ap1 * boost::math::tgamma(p1 + 1)) *
526 (ap1 * boost::math::tgamma(p1 + 1)));
530 c0 = 2.0 * (p0 + 1.0) /
531 ((2.0 * p0 + 1.0) * p0 *
532 (ap0 * boost::math::tgamma(p0 + 1)) *
533 (ap0 * boost::math::tgamma(p0 + 1)));
535 c1 = 2.0 * (p1 + 1.0) /
536 ((2.0 * p1 + 1.0) * p1 *
537 (ap1 * boost::math::tgamma(p1 + 1)) *
538 (ap1 * boost::math::tgamma(p1 + 1)));
542 c0 = -2.0 / ((2.0 * p0 + 1.0) *
543 (ap0 * boost::math::tgamma(p0 + 1)) *
544 (ap0 * boost::math::tgamma(p0 + 1)));
546 c1 = -2.0 / ((2.0 * p1 + 1.0) *
547 (ap1 * boost::math::tgamma(p1 + 1)) *
548 (ap1 * boost::math::tgamma(p1 + 1)));
552 c0 = 10000000000000000.0;
553 c1 = 10000000000000000.0;
556 NekDouble etap0 = 0.5 * c0 * (2.0 * p0 + 1.0) *
557 (ap0 * boost::math::tgamma(p0 + 1)) *
558 (ap0 * boost::math::tgamma(p0 + 1));
560 NekDouble etap1 = 0.5 * c1 * (2.0 * p1 + 1.0) *
561 (ap1 * boost::math::tgamma(p1 + 1)) *
562 (ap1 * boost::math::tgamma(p1 + 1));
564 NekDouble overeta0 = 1.0 / (1.0 + etap0);
565 NekDouble overeta1 = 1.0 / (1.0 + etap1);
584 for (i = 0; i < nquad0; ++i)
594 for (i = 0; i < nquad1; ++i)
604 for (i = 0; i < nquad0; ++i)
614 for (i = 0; i < nquad1; ++i)
634 for (n = 0; n < nElements; ++n)
636 base = pFields[0]->GetExp(n)->GetBase();
637 nquad0 = base[0]->GetNumPoints();
638 nquad1 = base[1]->GetNumPoints();
639 nquad2 = base[2]->GetNumPoints();
640 nmodes0 = base[0]->GetNumModes();
641 nmodes1 = base[1]->GetNumModes();
642 nmodes2 = base[2]->GetNumModes();
651 base[0]->GetZW(z0, w0);
652 base[1]->GetZW(z1, w1);
653 base[1]->GetZW(z2, w2);
675 int p0 = nmodes0 - 1;
676 int p1 = nmodes1 - 1;
677 int p2 = nmodes2 - 1;
685 NekDouble ap0 = boost::math::tgamma(2 * p0 + 1) /
686 (pow(2.0, p0) * boost::math::tgamma(p0 + 1) *
687 boost::math::tgamma(p0 + 1));
690 NekDouble ap1 = boost::math::tgamma(2 * p1 + 1) /
691 (pow(2.0, p1) * boost::math::tgamma(p1 + 1) *
692 boost::math::tgamma(p1 + 1));
695 NekDouble ap2 = boost::math::tgamma(2 * p2 + 1) /
696 (pow(2.0, p2) * boost::math::tgamma(p2 + 1) *
697 boost::math::tgamma(p2 + 1));
709 ((2.0 * p0 + 1.0) * (p0 + 1.0) *
710 (ap0 * boost::math::tgamma(p0 + 1)) *
711 (ap0 * boost::math::tgamma(p0 + 1)));
714 ((2.0 * p1 + 1.0) * (p1 + 1.0) *
715 (ap1 * boost::math::tgamma(p1 + 1)) *
716 (ap1 * boost::math::tgamma(p1 + 1)));
719 ((2.0 * p2 + 1.0) * (p2 + 1.0) *
720 (ap2 * boost::math::tgamma(p2 + 1)) *
721 (ap2 * boost::math::tgamma(p2 + 1)));
725 c0 = 2.0 * (p0 + 1.0) /
726 ((2.0 * p0 + 1.0) * p0 *
727 (ap0 * boost::math::tgamma(p0 + 1)) *
728 (ap0 * boost::math::tgamma(p0 + 1)));
730 c1 = 2.0 * (p1 + 1.0) /
731 ((2.0 * p1 + 1.0) * p1 *
732 (ap1 * boost::math::tgamma(p1 + 1)) *
733 (ap1 * boost::math::tgamma(p1 + 1)));
735 c2 = 2.0 * (p2 + 1.0) /
736 ((2.0 * p2 + 1.0) * p2 *
737 (ap2 * boost::math::tgamma(p2 + 1)) *
738 (ap2 * boost::math::tgamma(p2 + 1)));
742 c0 = -2.0 / ((2.0 * p0 + 1.0) *
743 (ap0 * boost::math::tgamma(p0 + 1)) *
744 (ap0 * boost::math::tgamma(p0 + 1)));
746 c1 = -2.0 / ((2.0 * p1 + 1.0) *
747 (ap1 * boost::math::tgamma(p1 + 1)) *
748 (ap1 * boost::math::tgamma(p1 + 1)));
750 c2 = -2.0 / ((2.0 * p2 + 1.0) *
751 (ap2 * boost::math::tgamma(p2 + 1)) *
752 (ap2 * boost::math::tgamma(p2 + 1)));
756 c0 = 10000000000000000.0;
757 c1 = 10000000000000000.0;
758 c2 = 10000000000000000.0;
761 NekDouble etap0 = 0.5 * c0 * (2.0 * p0 + 1.0) *
762 (ap0 * boost::math::tgamma(p0 + 1)) *
763 (ap0 * boost::math::tgamma(p0 + 1));
765 NekDouble etap1 = 0.5 * c1 * (2.0 * p1 + 1.0) *
766 (ap1 * boost::math::tgamma(p1 + 1)) *
767 (ap1 * boost::math::tgamma(p1 + 1));
769 NekDouble etap2 = 0.5 * c2 * (2.0 * p2 + 1.0) *
770 (ap2 * boost::math::tgamma(p2 + 1)) *
771 (ap2 * boost::math::tgamma(p2 + 1));
773 NekDouble overeta0 = 1.0 / (1.0 + etap0);
774 NekDouble overeta1 = 1.0 / (1.0 + etap1);
775 NekDouble overeta2 = 1.0 / (1.0 + etap2);
800 for (i = 0; i < nquad0; ++i)
810 for (i = 0; i < nquad1; ++i)
820 for (i = 0; i < nquad2; ++i)
830 for (i = 0; i < nquad0; ++i)
840 for (i = 0; i < nquad1; ++i)
850 for (i = 0; i < nquad2; ++i)
863 ASSERTL0(
false,
"Expansion dimension not recognised");
875 const std::size_t nConvectiveFields,
882 boost::ignore_unused(pFwd, pBwd);
891 Basis = fields[0]->GetExp(0)->GetBase();
893 int nElements = fields[0]->GetExpSize();
894 int nDim = fields[0]->GetCoordim(0);
895 int nSolutionPts = fields[0]->GetTotPoints();
896 int nCoeffs = fields[0]->GetNcoeffs();
899 for (i = 0; i < nConvectiveFields; ++i)
912 for (i = 0; i < nConvectiveFields; ++i)
916 for (n = 0; n < nElements; n++)
918 phys_offset = fields[0]->GetPhys_Offset(n);
920 fields[i]->GetExp(n)->PhysDeriv(
921 0, auxArray1 = inarray[i] + phys_offset,
922 auxArray2 =
m_DU1[i][0] + phys_offset);
938 1, &
m_D1[i][0][0], 1);
948 for (i = 0; i < nConvectiveFields; ++i)
952 for (n = 0; n < nElements; n++)
954 phys_offset = fields[0]->GetPhys_Offset(n);
956 fields[i]->GetExp(n)->PhysDeriv(
957 0, auxArray1 =
m_D1[i][0] + phys_offset,
958 auxArray2 =
m_DD1[i][0] + phys_offset);
974 1, &outarray[i][0], 1);
977 if (!(
Basis[0]->Collocation()))
979 fields[i]->FwdTrans(outarray[i], outarrayCoeff[i]);
980 fields[i]->BwdTrans(outarrayCoeff[i], outarray[i]);
988 for (i = 0; i < nConvectiveFields; ++i)
990 for (j = 0; j < nDim; ++j)
999 &
m_gmat[0][0], 1, &u1_hat[0], 1);
1005 &
m_gmat[1][0], 1, &u2_hat[0], 1);
1013 &
m_gmat[2][0], 1, &u1_hat[0], 1);
1019 &
m_gmat[3][0], 1, &u2_hat[0], 1);
1025 for (n = 0; n < nElements; n++)
1027 phys_offset = fields[0]->GetPhys_Offset(n);
1029 fields[i]->GetExp(n)->StdPhysDeriv(
1030 0, auxArray1 = u1_hat + phys_offset,
1031 auxArray2 =
m_tmp1[i][j] + phys_offset);
1033 fields[i]->GetExp(n)->StdPhysDeriv(
1034 1, auxArray1 = u2_hat + phys_offset,
1035 auxArray2 =
m_tmp2[i][j] + phys_offset);
1043 &
m_DU1[i][j][0], 1);
1047 DerCFlux_2D(nConvectiveFields, j, fields, inarray[i],
1053 for (j = 0; j < nSolutionPts; ++j)
1074 for (j = 0; j < nSolutionPts; j++)
1086 for (j = 0; j < nDim; ++j)
1099 for (i = 0; i < nConvectiveFields; ++i)
1104 for (j = 0; j < nSolutionPts; j++)
1115 for (n = 0; n < nElements; n++)
1117 phys_offset = fields[0]->GetPhys_Offset(n);
1119 fields[0]->GetExp(n)->StdPhysDeriv(
1120 0, auxArray1 = f_hat + phys_offset,
1121 auxArray2 =
m_DD1[i][0] + phys_offset);
1123 fields[0]->GetExp(n)->StdPhysDeriv(
1124 1, auxArray1 = g_hat + phys_offset,
1125 auxArray2 =
m_DD1[i][1] + phys_offset);
1133 if (
Basis[0]->GetPointsType() ==
1135 Basis[1]->GetPointsType() ==
1149 &outarray[i][0], 1);
1154 &outarray[i][0], 1);
1157 if (!(
Basis[0]->Collocation()))
1159 fields[i]->FwdTrans(outarray[i], outarrayCoeff[i]);
1160 fields[i]->BwdTrans(outarrayCoeff[i], outarray[i]);
1168 ASSERTL0(
false,
"3D FRDG case not implemented yet");
1184 int nTracePts = fields[0]->GetTrace()->GetTotPoints();
1185 int nvariables = fields.size();
1186 int nDim = fields[0]->GetCoordim(0);
1194 for (i = 0; i < nDim; ++i)
1202 for (j = 0; j < nDim; ++j)
1204 for (i = 0; i < nvariables; ++i)
1207 fields[i]->GetFwdBwdTracePhys(ufield[i], Fwd, Bwd);
1217 fields[i]->GetTrace()->Upwind(Vn, Fwd, Bwd, fluxtemp);
1228 if (fields[0]->GetBndCondExpansions().size())
1259 int nBndEdgePts, nBndEdges;
1261 int nBndRegions = fields[var]->GetBndCondExpansions().size();
1262 int nTracePts = fields[0]->GetTrace()->GetTotPoints();
1266 fields[var]->ExtractTracePhys(ufield, uplus);
1269 for (i = 0; i < nBndRegions; ++i)
1272 nBndEdges = fields[var]->GetBndCondExpansions()[i]->GetExpSize();
1275 for (e = 0; e < nBndEdges; ++e)
1278 nBndEdgePts = fields[var]
1279 ->GetBndCondExpansions()[i]
1284 id1 = fields[var]->GetBndCondExpansions()[i]->GetPhys_Offset(e);
1287 id2 = fields[0]->GetTrace()->GetPhys_Offset(
1288 fields[0]->GetTraceMap()->GetBndCondIDToGlobalTraceID(cnt++));
1292 ->GetBndConditions()[i]
1297 &(fields[var]->GetBndCondExpansions()[i]->GetPhys())[id1],
1298 1, &penaltyflux[id2], 1);
1301 else if ((fields[var]->GetBndConditions()[i])
1302 ->GetBoundaryConditionType() ==
1305 Vmath::Vcopy(nBndEdgePts, &uplus[id2], 1, &penaltyflux[id2], 1);
1321 boost::ignore_unused(ufield);
1324 int nTracePts = fields[0]->GetTrace()->GetTotPoints();
1325 int nvariables = fields.size();
1326 int nDim = fields[0]->GetCoordim(0);
1339 for (i = 0; i < nDim; ++i)
1346 for (i = 0; i < nvariables; ++i)
1349 for (j = 0; j < nDim; ++j)
1352 fields[i]->GetFwdBwdTracePhys(qfield[i][j], qFwd, qBwd);
1366 fields[i]->GetTrace()->Upwind(Vn, qBwd, qFwd, qfluxtemp);
1391 if (fields[0]->GetBndCondExpansions().size())
1400 Vmath::Vadd(nTracePts, qfluxtemp, 1, qflux[i], 1, qflux[i], 1);
1414 boost::ignore_unused(C11);
1417 int nBndEdges, nBndEdgePts;
1418 int nBndRegions = fields[var]->GetBndCondExpansions().size();
1419 int nTracePts = fields[0]->GetTrace()->GetTotPoints();
1425 fields[var]->ExtractTracePhys(qfield, qtemp);
1427 for (i = 0; i < nBndRegions; ++i)
1429 nBndEdges = fields[var]->GetBndCondExpansions()[i]->GetExpSize();
1432 for (e = 0; e < nBndEdges; ++e)
1434 nBndEdgePts = fields[var]
1435 ->GetBndCondExpansions()[i]
1439 id1 = fields[var]->GetBndCondExpansions()[i]->GetPhys_Offset(e);
1441 id2 = fields[0]->GetTrace()->GetPhys_Offset(
1442 fields[0]->GetTraceMap()->GetBndCondIDToGlobalTraceID(cnt++));
1447 ->GetBndConditions()[i]
1451 &qtemp[id2], 1, &penaltyflux[id2], 1);
1454 else if ((fields[var]->GetBndConditions()[i])
1455 ->GetBoundaryConditionType() ==
1460 &(fields[var]->GetBndCondExpansions()[i]->GetPhys())[id1],
1461 1, &penaltyflux[id2], 1);
1478 const int nConvectiveFields,
1483 boost::ignore_unused(nConvectiveFields);
1486 int nLocalSolutionPts, phys_offset, t_offset;
1494 Basis = fields[0]->GetExp(0)->GetBasis(0);
1496 int nElements = fields[0]->GetExpSize();
1497 int nSolutionPts = fields[0]->GetTotPoints();
1499 vector<bool> leftAdjacentTraces =
1500 std::static_pointer_cast<MultiRegions::DisContField>(fields[0])
1501 ->GetLeftAdjacentTraces();
1512 fields[0]->GetTraceMap()->GetElmtToTrace();
1514 for (n = 0; n < nElements; ++n)
1516 nLocalSolutionPts = fields[0]->GetExp(n)->GetTotPoints();
1517 phys_offset = fields[0]->GetPhys_Offset(n);
1521 Vmath::Vcopy(nLocalSolutionPts, &flux[phys_offset], 1, &tmparrayX1[0],
1524 fields[0]->GetExp(n)->GetTracePhysVals(0, elmtToTrace[n][0], tmparrayX1,
1527 t_offset = fields[0]->GetTrace()->GetPhys_Offset(
1528 elmtToTrace[n][0]->GetElmtId());
1530 if (leftAdjacentTraces[2 * n])
1532 JumpL[n] = -iFlux[t_offset] - tmpFluxVertex[0];
1536 JumpL[n] = iFlux[t_offset] - tmpFluxVertex[0];
1539 t_offset = fields[0]->GetTrace()->GetPhys_Offset(
1540 elmtToTrace[n][1]->GetElmtId());
1542 fields[0]->GetExp(n)->GetTracePhysVals(1, elmtToTrace[n][1], tmparrayX1,
1544 if (leftAdjacentTraces[2 * n + 1])
1546 JumpR[n] = iFlux[t_offset] - tmpFluxVertex[0];
1550 JumpR[n] = -iFlux[t_offset] - tmpFluxVertex[0];
1554 for (n = 0; n < nElements; ++n)
1556 ptsKeys = fields[0]->GetExp(n)->GetPointsKeys();
1557 nLocalSolutionPts = fields[0]->GetExp(n)->GetTotPoints();
1558 phys_offset = fields[0]->GetPhys_Offset(n);
1566 JumpL[n] = JumpL[n] * jac[0];
1567 JumpR[n] = JumpR[n] * jac[0];
1578 Vmath::Vadd(nLocalSolutionPts, &DCL[0], 1, &DCR[0], 1,
1579 &derCFlux[phys_offset], 1);
1599 const int nConvectiveFields,
const int direction,
1604 boost::ignore_unused(nConvectiveFields);
1606 int n, e, i, j, cnt;
1611 int nElements = fields[0]->GetExpSize();
1613 int trace_offset, phys_offset;
1614 int nLocalSolutionPts;
1622 fields[0]->GetTraceMap()->GetElmtToTrace();
1625 for (n = 0; n < nElements; ++n)
1628 phys_offset = fields[0]->GetPhys_Offset(n);
1629 nLocalSolutionPts = fields[0]->GetExp(n)->GetTotPoints();
1630 ptsKeys = fields[0]->GetExp(n)->GetPointsKeys();
1639 base = fields[0]->GetExp(n)->GetBase();
1640 nquad0 = base[0]->GetNumPoints();
1641 nquad1 = base[1]->GetNumPoints();
1649 for (e = 0; e < fields[0]->GetExp(n)->GetNtraces(); ++e)
1652 nEdgePts = fields[0]->GetExp(n)->GetTraceNumPoints(e);
1658 trace_offset = fields[0]->GetTrace()->GetPhys_Offset(
1659 elmtToTrace[n][e]->GetElmtId());
1668 fields[0]->GetExp(n)->GetTracePhysVals(
1669 e, elmtToTrace[n][e], flux + phys_offset, auxArray1 = tmparray);
1674 Vmath::Vsub(nEdgePts, &iFlux[trace_offset], 1, &tmparray[0], 1,
1679 if (fields[0]->GetExp(n)->GetTraceOrient(e) ==
1688 ->as<LocalRegions::Expansion2D>()
1696 fields[0]->GetExp(n)->GetTracePhysVals(
1697 e, elmtToTrace[n][e], jac, auxArray1 = jacEdge);
1701 if (fields[0]->GetExp(n)->GetTraceOrient(e) ==
1709 for (j = 0; j < nEdgePts; j++)
1711 fluxJumps[j] = fluxJumps[j] * jacEdge[j];
1719 Vmath::Smul(nEdgePts, jac[0], fluxJumps, 1, fluxJumps, 1);
1728 for (i = 0; i < nquad0; ++i)
1733 for (j = 0; j < nquad1; ++j)
1735 cnt = i + j * nquad0;
1736 divCFluxE0[cnt] = fluxJumps[i] *
m_dGL_xi2[n][j];
1741 for (i = 0; i < nquad1; ++i)
1746 for (j = 0; j < nquad0; ++j)
1748 cnt = (nquad0)*i + j;
1749 divCFluxE1[cnt] = fluxJumps[i] *
m_dGR_xi1[n][j];
1754 for (i = 0; i < nquad0; ++i)
1759 for (j = 0; j < nquad1; ++j)
1761 cnt = j * nquad0 + i;
1762 divCFluxE2[cnt] = fluxJumps[i] *
m_dGR_xi2[n][j];
1767 for (i = 0; i < nquad1; ++i)
1771 for (j = 0; j < nquad0; ++j)
1773 cnt = j + i * nquad0;
1774 divCFluxE3[cnt] = fluxJumps[i] *
m_dGL_xi1[n][j];
1780 ASSERTL0(
false,
"edge value (< 3) is out of range");
1789 Vmath::Vadd(nLocalSolutionPts, &divCFluxE1[0], 1, &divCFluxE3[0], 1,
1790 &derCFlux[phys_offset], 1);
1792 else if (direction == 1)
1794 Vmath::Vadd(nLocalSolutionPts, &divCFluxE0[0], 1, &divCFluxE2[0], 1,
1795 &derCFlux[phys_offset], 1);
1814 const int nConvectiveFields,
1821 boost::ignore_unused(nConvectiveFields);
1823 int n, e, i, j, cnt;
1825 int nElements = fields[0]->GetExpSize();
1827 int nLocalSolutionPts;
1838 fields[0]->GetTraceMap()->GetElmtToTrace();
1841 for (n = 0; n < nElements; ++n)
1844 phys_offset = fields[0]->GetPhys_Offset(n);
1845 nLocalSolutionPts = fields[0]->GetExp(n)->GetTotPoints();
1847 base = fields[0]->GetExp(n)->GetBase();
1848 nquad0 = base[0]->GetNumPoints();
1849 nquad1 = base[1]->GetNumPoints();
1857 for (e = 0; e < fields[0]->GetExp(n)->GetNtraces(); ++e)
1860 nEdgePts = fields[0]->GetExp(n)->GetTraceNumPoints(e);
1869 trace_offset = fields[0]->GetTrace()->GetPhys_Offset(
1870 elmtToTrace[n][e]->GetElmtId());
1874 fields[0]->GetExp(n)->GetTraceNormal(e);
1878 fields[0]->GetExp(n)->GetTracePhysVals(e, elmtToTrace[n][e],
1879 fluxX1 + phys_offset,
1880 auxArray1 = tmparrayX1);
1884 fields[0]->GetExp(n)->GetTracePhysVals(e, elmtToTrace[n][e],
1885 fluxX2 + phys_offset,
1886 auxArray1 = tmparrayX2);
1889 for (i = 0; i < nEdgePts; ++i)
1896 Vmath::Vsub(nEdgePts, &numericalFlux[trace_offset], 1, &fluxN[0], 1,
1900 if (fields[0]->GetExp(n)->GetTraceOrient(e) ==
1904 auxArray2 = fluxJumps, 1);
1907 for (i = 0; i < nEdgePts; ++i)
1912 fluxJumps[i] = -fluxJumps[i];
1920 for (i = 0; i < nquad0; ++i)
1923 fluxJumps[i] = -(
m_Q2D_e0[n][i]) * fluxJumps[i];
1925 for (j = 0; j < nquad1; ++j)
1927 cnt = i + j * nquad0;
1928 divCFluxE0[cnt] = fluxJumps[i] *
m_dGL_xi2[n][j];
1933 for (i = 0; i < nquad1; ++i)
1936 fluxJumps[i] = (
m_Q2D_e1[n][i]) * fluxJumps[i];
1938 for (j = 0; j < nquad0; ++j)
1940 cnt = (nquad0)*i + j;
1941 divCFluxE1[cnt] = fluxJumps[i] *
m_dGR_xi1[n][j];
1946 for (i = 0; i < nquad0; ++i)
1949 fluxJumps[i] = (
m_Q2D_e2[n][i]) * fluxJumps[i];
1951 for (j = 0; j < nquad1; ++j)
1953 cnt = j * nquad0 + i;
1954 divCFluxE2[cnt] = fluxJumps[i] *
m_dGR_xi2[n][j];
1959 for (i = 0; i < nquad1; ++i)
1962 fluxJumps[i] = -(
m_Q2D_e3[n][i]) * fluxJumps[i];
1963 for (j = 0; j < nquad0; ++j)
1965 cnt = j + i * nquad0;
1966 divCFluxE3[cnt] = fluxJumps[i] *
m_dGL_xi1[n][j];
1972 ASSERTL0(
false,
"edge value (< 3) is out of range");
1978 Vmath::Vadd(nLocalSolutionPts, &divCFluxE0[0], 1, &divCFluxE1[0], 1,
1979 &divCFlux[phys_offset], 1);
1981 Vmath::Vadd(nLocalSolutionPts, &divCFlux[phys_offset], 1,
1982 &divCFluxE2[0], 1, &divCFlux[phys_offset], 1);
1984 Vmath::Vadd(nLocalSolutionPts, &divCFlux[phys_offset], 1,
1985 &divCFluxE3[0], 1, &divCFlux[phys_offset], 1);
2004 const int nConvectiveFields,
2011 boost::ignore_unused(nConvectiveFields);
2013 int n, e, i, j, cnt;
2015 int nElements = fields[0]->GetExpSize();
2016 int nLocalSolutionPts;
2027 fields[0]->GetTraceMap()->GetElmtToTrace();
2030 for (n = 0; n < nElements; ++n)
2033 phys_offset = fields[0]->GetPhys_Offset(n);
2034 nLocalSolutionPts = fields[0]->GetExp(n)->GetTotPoints();
2036 base = fields[0]->GetExp(n)->GetBase();
2037 nquad0 = base[0]->GetNumPoints();
2038 nquad1 = base[1]->GetNumPoints();
2046 for (e = 0; e < fields[0]->GetExp(n)->GetNtraces(); ++e)
2049 nEdgePts = fields[0]->GetExp(n)->GetTraceNumPoints(e);
2058 trace_offset = fields[0]->GetTrace()->GetPhys_Offset(
2059 elmtToTrace[n][e]->GetElmtId());
2063 fields[0]->GetExp(n)->GetTraceNormal(e);
2072 fields[0]->GetExp(n)->GetTracePhysVals(e, elmtToTrace[n][e],
2073 fluxX2 + phys_offset,
2074 auxArray1 = fluxN_D);
2079 Vmath::Vcopy(nEdgePts, &numericalFlux[trace_offset], 1,
2083 if (fields[0]->GetExp(n)->GetTraceOrient(e) ==
2087 auxArray2 = fluxN, 1);
2090 auxArray2 = fluxN_D, 1);
2094 for (i = 0; i < nquad0; ++i)
2097 fluxN_R[i] = (
m_Q2D_e0[n][i]) * fluxN[i];
2100 for (i = 0; i < nEdgePts; ++i)
2107 fluxN_R[i] = -fluxN_R[i];
2113 Vmath::Vsub(nEdgePts, &fluxN_R[0], 1, &fluxN_D[0], 1,
2118 for (i = 0; i < nquad0; ++i)
2120 for (j = 0; j < nquad1; ++j)
2122 cnt = i + j * nquad0;
2123 divCFluxE0[cnt] = -fluxJumps[i] *
m_dGL_xi2[n][j];
2131 fields[0]->GetExp(n)->GetTracePhysVals(e, elmtToTrace[n][e],
2132 fluxX1 + phys_offset,
2133 auxArray1 = fluxN_D);
2136 Vmath::Vcopy(nEdgePts, &numericalFlux[trace_offset], 1,
2140 if (fields[0]->GetExp(n)->GetTraceOrient(e) ==
2144 auxArray2 = fluxN, 1);
2147 auxArray2 = fluxN_D, 1);
2151 for (i = 0; i < nquad1; ++i)
2154 fluxN_R[i] = (
m_Q2D_e1[n][i]) * fluxN[i];
2157 for (i = 0; i < nEdgePts; ++i)
2164 fluxN_R[i] = -fluxN_R[i];
2170 Vmath::Vsub(nEdgePts, &fluxN_R[0], 1, &fluxN_D[0], 1,
2175 for (i = 0; i < nquad1; ++i)
2177 for (j = 0; j < nquad0; ++j)
2179 cnt = (nquad0)*i + j;
2180 divCFluxE1[cnt] = fluxJumps[i] *
m_dGR_xi1[n][j];
2190 fields[0]->GetExp(n)->GetTracePhysVals(e, elmtToTrace[n][e],
2191 fluxX2 + phys_offset,
2192 auxArray1 = fluxN_D);
2195 Vmath::Vcopy(nEdgePts, &numericalFlux[trace_offset], 1,
2199 if (fields[0]->GetExp(n)->GetTraceOrient(e) ==
2203 auxArray2 = fluxN, 1);
2206 auxArray2 = fluxN_D, 1);
2210 for (i = 0; i < nquad0; ++i)
2213 fluxN_R[i] = (
m_Q2D_e2[n][i]) * fluxN[i];
2216 for (i = 0; i < nEdgePts; ++i)
2223 fluxN_R[i] = -fluxN_R[i];
2230 Vmath::Vsub(nEdgePts, &fluxN_R[0], 1, &fluxN_D[0], 1,
2235 for (i = 0; i < nquad0; ++i)
2237 for (j = 0; j < nquad1; ++j)
2239 cnt = j * nquad0 + i;
2240 divCFluxE2[cnt] = fluxJumps[i] *
m_dGR_xi2[n][j];
2249 fields[0]->GetExp(n)->GetTracePhysVals(e, elmtToTrace[n][e],
2250 fluxX1 + phys_offset,
2251 auxArray1 = fluxN_D);
2255 Vmath::Vcopy(nEdgePts, &numericalFlux[trace_offset], 1,
2259 if (fields[0]->GetExp(n)->GetTraceOrient(e) ==
2263 auxArray2 = fluxN, 1);
2266 auxArray2 = fluxN_D, 1);
2270 for (i = 0; i < nquad1; ++i)
2273 fluxN_R[i] = (
m_Q2D_e3[n][i]) * fluxN[i];
2276 for (i = 0; i < nEdgePts; ++i)
2283 fluxN_R[i] = -fluxN_R[i];
2290 Vmath::Vsub(nEdgePts, &fluxN_R[0], 1, &fluxN_D[0], 1,
2295 for (i = 0; i < nquad1; ++i)
2297 for (j = 0; j < nquad0; ++j)
2299 cnt = j + i * nquad0;
2300 divCFluxE3[cnt] = -fluxJumps[i] *
m_dGL_xi1[n][j];
2305 ASSERTL0(
false,
"edge value (< 3) is out of range");
2311 Vmath::Vadd(nLocalSolutionPts, &divCFluxE0[0], 1, &divCFluxE1[0], 1,
2312 &divCFlux[phys_offset], 1);
2314 Vmath::Vadd(nLocalSolutionPts, &divCFlux[phys_offset], 1,
2315 &divCFluxE2[0], 1, &divCFlux[phys_offset], 1);
2317 Vmath::Vadd(nLocalSolutionPts, &divCFlux[phys_offset], 1,
2318 &divCFluxE3[0], 1, &divCFlux[phys_offset], 1);
#define ASSERTL0(condition, msg)
Represents a basis of a given type.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
const SpatialDomains::GeomFactorsSharedPtr & GetMetricInfo() const
Array< OneD, Array< OneD, Array< OneD, NekDouble > > > m_tmp2
Array< OneD, Array< OneD, NekDouble > > m_dGL_xi2
Array< OneD, Array< OneD, Array< OneD, NekDouble > > > m_IF1
Array< OneD, NekDouble > m_jac
void DerCFlux_1D(const int nConvectiveFields, const Array< OneD, MultiRegions::ExpListSharedPtr > &fields, const Array< OneD, const NekDouble > &flux, const Array< OneD, const NekDouble > &iFlux, Array< OneD, NekDouble > &derCFlux)
Compute the derivative of the corrective flux for 1D problems.
Array< OneD, Array< OneD, Array< OneD, NekDouble > > > m_DFC1
Array< OneD, Array< OneD, Array< OneD, NekDouble > > > m_DD1
Array< OneD, Array< OneD, NekDouble > > m_dGR_xi1
Array< OneD, Array< OneD, NekDouble > > m_divFC
void DerCFlux_2D(const int nConvectiveFields, const int direction, const Array< OneD, MultiRegions::ExpListSharedPtr > &fields, const Array< OneD, const NekDouble > &flux, const Array< OneD, NekDouble > &iFlux, Array< OneD, NekDouble > &derCFlux)
Compute the derivative of the corrective flux wrt a given coordinate for 2D problems.
void SetupMetrics(LibUtilities::SessionReaderSharedPtr pSession, Array< OneD, MultiRegions::ExpListSharedPtr > pFields)
Setup the metric terms to compute the contravariant fluxes. (i.e. this special metric terms transform...
LibUtilities::SessionReaderSharedPtr m_session
void WeakPenaltyforScalar(const Array< OneD, MultiRegions::ExpListSharedPtr > &fields, const int var, const Array< OneD, const NekDouble > &ufield, Array< OneD, NekDouble > &penaltyflux)
Imposes appropriate bcs for the 1st order derivatives.
Array< OneD, Array< OneD, NekDouble > > m_dGR_xi2
Array< OneD, Array< OneD, NekDouble > > m_dGL_xi1
void WeakPenaltyforVector(const Array< OneD, MultiRegions::ExpListSharedPtr > &fields, const int var, const int dir, const Array< OneD, const NekDouble > &qfield, Array< OneD, NekDouble > &penaltyflux, NekDouble C11)
Imposes appropriate bcs for the 2nd order derivatives.
void SetupCFunctions(LibUtilities::SessionReaderSharedPtr pSession, Array< OneD, MultiRegions::ExpListSharedPtr > pFields)
Setup the derivatives of the correction functions. For more details see J Sci Comput (2011) 47: 50–72...
void DivCFlux_2D(const int nConvectiveFields, const Array< OneD, MultiRegions::ExpListSharedPtr > &fields, const Array< OneD, const NekDouble > &fluxX1, const Array< OneD, const NekDouble > &fluxX2, const Array< OneD, const NekDouble > &numericalFlux, Array< OneD, NekDouble > &divCFlux)
Compute the divergence of the corrective flux for 2D problems.
Array< OneD, Array< OneD, NekDouble > > m_dGR_xi3
Array< OneD, Array< OneD, NekDouble > > m_gmat
Array< OneD, Array< OneD, NekDouble > > m_traceNormals
Array< OneD, Array< OneD, NekDouble > > m_Q2D_e0
Array< OneD, Array< OneD, Array< OneD, NekDouble > > > m_DU1
Array< OneD, Array< OneD, Array< OneD, NekDouble > > > m_DFC2
Array< OneD, Array< OneD, NekDouble > > m_Q2D_e3
Array< OneD, Array< OneD, Array< OneD, NekDouble > > > m_tmp1
Array< OneD, Array< OneD, NekDouble > > m_Q2D_e2
Array< OneD, Array< OneD, Array< OneD, NekDouble > > > m_D1
Array< OneD, Array< OneD, NekDouble > > m_dGL_xi3
virtual void v_Diffuse(const std::size_t nConvectiveFields, const Array< OneD, MultiRegions::ExpListSharedPtr > &fields, const Array< OneD, Array< OneD, NekDouble >> &inarray, Array< OneD, Array< OneD, NekDouble >> &outarray, const Array< OneD, Array< OneD, NekDouble >> &pFwd, const Array< OneD, Array< OneD, NekDouble >> &pBwd) override
Calculate FR Diffusion for the linear problems using an LDG interface flux.
Array< OneD, Array< OneD, NekDouble > > m_Q2D_e1
virtual void v_InitObject(LibUtilities::SessionReaderSharedPtr pSession, Array< OneD, MultiRegions::ExpListSharedPtr > pFields) override
Initiliase DiffusionLFR objects and store them before starting the time-stepping.
Array< OneD, Array< OneD, NekDouble > > m_IF2
Array< OneD, Array< OneD, NekDouble > > m_divFD
void NumFluxforVector(const Array< OneD, MultiRegions::ExpListSharedPtr > &fields, const Array< OneD, Array< OneD, NekDouble >> &ufield, Array< OneD, Array< OneD, Array< OneD, NekDouble >>> &qfield, Array< OneD, Array< OneD, NekDouble >> &qflux)
Build the numerical flux for the 2nd order derivatives.
void NumFluxforScalar(const Array< OneD, MultiRegions::ExpListSharedPtr > &fields, const Array< OneD, Array< OneD, NekDouble >> &ufield, Array< OneD, Array< OneD, Array< OneD, NekDouble >>> &uflux)
Builds the numerical flux for the 1st order derivatives.
Array< OneD, Array< OneD, Array< OneD, NekDouble > > > m_BD1
void DivCFlux_2D_Gauss(const int nConvectiveFields, const Array< OneD, MultiRegions::ExpListSharedPtr > &fields, const Array< OneD, const NekDouble > &fluxX1, const Array< OneD, const NekDouble > &fluxX2, const Array< OneD, const NekDouble > &numericalFlux, Array< OneD, NekDouble > &divCFlux)
Compute the divergence of the corrective flux for 2D problems where POINTSTYPE="GaussGaussLegendre".
std::shared_ptr< Basis > BasisSharedPtr
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::vector< PointsKey > PointsKeyVector
@ eGaussGaussLegendre
1D Gauss-Gauss-Legendre quadrature points
DiffusionFactory & GetDiffusionFactory()
@ eDeformed
Geometry is curved or has non-constant factors.
The above copyright notice and this permission notice shall be included.
void jacobd(const int np, const double *z, double *polyd, const int n, const double alpha, const double beta)
Calculate the derivative of Jacobi polynomials.
void Vmul(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Multiply vector z = x*y.
void Svtvp(int n, const T alpha, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
svtvp (scalar times vector plus vector): z = alpha*x + y
void Neg(int n, T *x, const int incx)
Negate x = -x.
void Vadd(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Add vector z = x+y.
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*x.
void Vdiv(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Multiply vector z = x/y.
void Reverse(int n, const T *x, const int incx, T *y, const int incy)
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
void Vsub(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Subtract vector z = x-y.