40#include <boost/core/ignore_unused.hpp>
41#include <boost/math/special_functions/gamma.hpp>
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");
334 boost::ignore_unused(pSession);
340 int nquad0, nquad1, nquad2;
341 int nmodes0, nmodes1, nmodes2;
344 int nElements = pFields[0]->GetExpSize();
345 int nDim = pFields[0]->GetCoordim(0);
354 for (n = 0; n < nElements; ++n)
356 base = pFields[0]->GetExp(n)->GetBase();
357 nquad0 = base[0]->GetNumPoints();
358 nmodes0 = base[0]->GetNumModes();
362 base[0]->GetZW(z0, w0);
374 int p0 = nmodes0 - 1;
380 NekDouble ap0 = boost::math::tgamma(2 * p0 + 1) /
381 (pow(2.0, p0) * boost::math::tgamma(p0 + 1) *
382 boost::math::tgamma(p0 + 1));
392 ((2.0 * p0 + 1.0) * (p0 + 1.0) *
393 (ap0 * boost::math::tgamma(p0 + 1)) *
394 (ap0 * boost::math::tgamma(p0 + 1)));
398 c0 = 2.0 * (p0 + 1.0) /
399 ((2.0 * p0 + 1.0) * p0 *
400 (ap0 * boost::math::tgamma(p0 + 1)) *
401 (ap0 * boost::math::tgamma(p0 + 1)));
405 c0 = -2.0 / ((2.0 * p0 + 1.0) *
406 (ap0 * boost::math::tgamma(p0 + 1)) *
407 (ap0 * boost::math::tgamma(p0 + 1)));
411 c0 = 10000000000000000.0;
414 NekDouble etap0 = 0.5 * c0 * (2.0 * p0 + 1.0) *
415 (ap0 * boost::math::tgamma(p0 + 1)) *
416 (ap0 * boost::math::tgamma(p0 + 1));
418 NekDouble overeta0 = 1.0 / (1.0 + etap0);
431 for (i = 0; i < nquad0; ++i)
441 for (i = 0; i < nquad0; ++i)
464 for (n = 0; n < nElements; ++n)
466 base = pFields[0]->GetExp(n)->GetBase();
467 nquad0 = base[0]->GetNumPoints();
468 nquad1 = base[1]->GetNumPoints();
469 nmodes0 = base[0]->GetNumModes();
470 nmodes1 = base[1]->GetNumModes();
477 base[0]->GetZW(z0, w0);
478 base[1]->GetZW(z1, w1);
495 int p0 = nmodes0 - 1;
496 int p1 = nmodes1 - 1;
503 NekDouble ap0 = boost::math::tgamma(2 * p0 + 1) /
504 (pow(2.0, p0) * boost::math::tgamma(p0 + 1) *
505 boost::math::tgamma(p0 + 1));
507 NekDouble ap1 = boost::math::tgamma(2 * p1 + 1) /
508 (pow(2.0, p1) * boost::math::tgamma(p1 + 1) *
509 boost::math::tgamma(p1 + 1));
520 ((2.0 * p0 + 1.0) * (p0 + 1.0) *
521 (ap0 * boost::math::tgamma(p0 + 1)) *
522 (ap0 * boost::math::tgamma(p0 + 1)));
525 ((2.0 * p1 + 1.0) * (p1 + 1.0) *
526 (ap1 * boost::math::tgamma(p1 + 1)) *
527 (ap1 * boost::math::tgamma(p1 + 1)));
531 c0 = 2.0 * (p0 + 1.0) /
532 ((2.0 * p0 + 1.0) * p0 *
533 (ap0 * boost::math::tgamma(p0 + 1)) *
534 (ap0 * boost::math::tgamma(p0 + 1)));
536 c1 = 2.0 * (p1 + 1.0) /
537 ((2.0 * p1 + 1.0) * p1 *
538 (ap1 * boost::math::tgamma(p1 + 1)) *
539 (ap1 * boost::math::tgamma(p1 + 1)));
543 c0 = -2.0 / ((2.0 * p0 + 1.0) *
544 (ap0 * boost::math::tgamma(p0 + 1)) *
545 (ap0 * boost::math::tgamma(p0 + 1)));
547 c1 = -2.0 / ((2.0 * p1 + 1.0) *
548 (ap1 * boost::math::tgamma(p1 + 1)) *
549 (ap1 * boost::math::tgamma(p1 + 1)));
553 c0 = 10000000000000000.0;
554 c1 = 10000000000000000.0;
557 NekDouble etap0 = 0.5 * c0 * (2.0 * p0 + 1.0) *
558 (ap0 * boost::math::tgamma(p0 + 1)) *
559 (ap0 * boost::math::tgamma(p0 + 1));
561 NekDouble etap1 = 0.5 * c1 * (2.0 * p1 + 1.0) *
562 (ap1 * boost::math::tgamma(p1 + 1)) *
563 (ap1 * boost::math::tgamma(p1 + 1));
565 NekDouble overeta0 = 1.0 / (1.0 + etap0);
566 NekDouble overeta1 = 1.0 / (1.0 + etap1);
585 for (i = 0; i < nquad0; ++i)
595 for (i = 0; i < nquad1; ++i)
605 for (i = 0; i < nquad0; ++i)
615 for (i = 0; i < nquad1; ++i)
635 for (n = 0; n < nElements; ++n)
637 base = pFields[0]->GetExp(n)->GetBase();
638 nquad0 = base[0]->GetNumPoints();
639 nquad1 = base[1]->GetNumPoints();
640 nquad2 = base[2]->GetNumPoints();
641 nmodes0 = base[0]->GetNumModes();
642 nmodes1 = base[1]->GetNumModes();
643 nmodes2 = base[2]->GetNumModes();
652 base[0]->GetZW(z0, w0);
653 base[1]->GetZW(z1, w1);
654 base[1]->GetZW(z2, w2);
676 int p0 = nmodes0 - 1;
677 int p1 = nmodes1 - 1;
678 int p2 = nmodes2 - 1;
686 NekDouble ap0 = boost::math::tgamma(2 * p0 + 1) /
687 (pow(2.0, p0) * boost::math::tgamma(p0 + 1) *
688 boost::math::tgamma(p0 + 1));
691 NekDouble ap1 = boost::math::tgamma(2 * p1 + 1) /
692 (pow(2.0, p1) * boost::math::tgamma(p1 + 1) *
693 boost::math::tgamma(p1 + 1));
696 NekDouble ap2 = boost::math::tgamma(2 * p2 + 1) /
697 (pow(2.0, p2) * boost::math::tgamma(p2 + 1) *
698 boost::math::tgamma(p2 + 1));
710 ((2.0 * p0 + 1.0) * (p0 + 1.0) *
711 (ap0 * boost::math::tgamma(p0 + 1)) *
712 (ap0 * boost::math::tgamma(p0 + 1)));
715 ((2.0 * p1 + 1.0) * (p1 + 1.0) *
716 (ap1 * boost::math::tgamma(p1 + 1)) *
717 (ap1 * boost::math::tgamma(p1 + 1)));
720 ((2.0 * p2 + 1.0) * (p2 + 1.0) *
721 (ap2 * boost::math::tgamma(p2 + 1)) *
722 (ap2 * boost::math::tgamma(p2 + 1)));
726 c0 = 2.0 * (p0 + 1.0) /
727 ((2.0 * p0 + 1.0) * p0 *
728 (ap0 * boost::math::tgamma(p0 + 1)) *
729 (ap0 * boost::math::tgamma(p0 + 1)));
731 c1 = 2.0 * (p1 + 1.0) /
732 ((2.0 * p1 + 1.0) * p1 *
733 (ap1 * boost::math::tgamma(p1 + 1)) *
734 (ap1 * boost::math::tgamma(p1 + 1)));
736 c2 = 2.0 * (p2 + 1.0) /
737 ((2.0 * p2 + 1.0) * p2 *
738 (ap2 * boost::math::tgamma(p2 + 1)) *
739 (ap2 * boost::math::tgamma(p2 + 1)));
743 c0 = -2.0 / ((2.0 * p0 + 1.0) *
744 (ap0 * boost::math::tgamma(p0 + 1)) *
745 (ap0 * boost::math::tgamma(p0 + 1)));
747 c1 = -2.0 / ((2.0 * p1 + 1.0) *
748 (ap1 * boost::math::tgamma(p1 + 1)) *
749 (ap1 * boost::math::tgamma(p1 + 1)));
751 c2 = -2.0 / ((2.0 * p2 + 1.0) *
752 (ap2 * boost::math::tgamma(p2 + 1)) *
753 (ap2 * boost::math::tgamma(p2 + 1)));
757 c0 = 10000000000000000.0;
758 c1 = 10000000000000000.0;
759 c2 = 10000000000000000.0;
762 NekDouble etap0 = 0.5 * c0 * (2.0 * p0 + 1.0) *
763 (ap0 * boost::math::tgamma(p0 + 1)) *
764 (ap0 * boost::math::tgamma(p0 + 1));
766 NekDouble etap1 = 0.5 * c1 * (2.0 * p1 + 1.0) *
767 (ap1 * boost::math::tgamma(p1 + 1)) *
768 (ap1 * boost::math::tgamma(p1 + 1));
770 NekDouble etap2 = 0.5 * c2 * (2.0 * p2 + 1.0) *
771 (ap2 * boost::math::tgamma(p2 + 1)) *
772 (ap2 * boost::math::tgamma(p2 + 1));
774 NekDouble overeta0 = 1.0 / (1.0 + etap0);
775 NekDouble overeta1 = 1.0 / (1.0 + etap1);
776 NekDouble overeta2 = 1.0 / (1.0 + etap2);
801 for (i = 0; i < nquad0; ++i)
811 for (i = 0; i < nquad1; ++i)
821 for (i = 0; i < nquad2; ++i)
831 for (i = 0; i < nquad0; ++i)
841 for (i = 0; i < nquad1; ++i)
851 for (i = 0; i < nquad2; ++i)
864 ASSERTL0(
false,
"Expansion dimension not recognised");
876 const std::size_t nConvectiveFields,
883 boost::ignore_unused(pFwd, pBwd);
890 Basis = fields[0]->GetExp(0)->GetBase();
892 int nElements = fields[0]->GetExpSize();
893 int nDim = fields[0]->GetCoordim(0);
894 int nSolutionPts = fields[0]->GetTotPoints();
895 int nCoeffs = fields[0]->GetNcoeffs();
898 for (i = 0; i < nConvectiveFields; ++i)
911 for (i = 0; i < nConvectiveFields; ++i)
915 for (n = 0; n < nElements; n++)
917 phys_offset = fields[0]->GetPhys_Offset(n);
919 fields[i]->GetExp(n)->PhysDeriv(
920 0, auxArray1 = inarray[i] + phys_offset,
921 auxArray2 =
m_DU1[i][0] + phys_offset);
937 1, &
m_D1[i][0][0], 1);
947 for (i = 0; i < nConvectiveFields; ++i)
951 for (n = 0; n < nElements; n++)
953 phys_offset = fields[0]->GetPhys_Offset(n);
955 fields[i]->GetExp(n)->PhysDeriv(
956 0, auxArray1 =
m_D1[i][0] + phys_offset,
957 auxArray2 =
m_DD1[i][0] + phys_offset);
973 1, &outarray[i][0], 1);
976 if (!(
Basis[0]->Collocation()))
978 fields[i]->FwdTrans(outarray[i], outarrayCoeff[i]);
979 fields[i]->BwdTrans(outarrayCoeff[i], outarray[i]);
987 for (i = 0; i < nConvectiveFields; ++i)
989 for (j = 0; j < nDim; ++j)
998 &
m_gmat[0][0], 1, &u1_hat[0], 1);
1004 &
m_gmat[1][0], 1, &u2_hat[0], 1);
1012 &
m_gmat[2][0], 1, &u1_hat[0], 1);
1018 &
m_gmat[3][0], 1, &u2_hat[0], 1);
1024 for (n = 0; n < nElements; n++)
1026 phys_offset = fields[0]->GetPhys_Offset(n);
1028 fields[i]->GetExp(n)->StdPhysDeriv(
1029 0, auxArray1 = u1_hat + phys_offset,
1030 auxArray2 =
m_tmp1[i][j] + phys_offset);
1032 fields[i]->GetExp(n)->StdPhysDeriv(
1033 1, auxArray1 = u2_hat + phys_offset,
1034 auxArray2 =
m_tmp2[i][j] + phys_offset);
1042 &
m_DU1[i][j][0], 1);
1046 DerCFlux_2D(nConvectiveFields, j, fields, inarray[i],
1052 for (j = 0; j < nSolutionPts; ++j)
1073 for (j = 0; j < nSolutionPts; j++)
1085 for (j = 0; j < nDim; ++j)
1098 for (i = 0; i < nConvectiveFields; ++i)
1103 for (j = 0; j < nSolutionPts; j++)
1114 for (n = 0; n < nElements; n++)
1116 phys_offset = fields[0]->GetPhys_Offset(n);
1118 fields[0]->GetExp(n)->StdPhysDeriv(
1119 0, auxArray1 = f_hat + phys_offset,
1120 auxArray2 =
m_DD1[i][0] + phys_offset);
1122 fields[0]->GetExp(n)->StdPhysDeriv(
1123 1, auxArray1 = g_hat + phys_offset,
1124 auxArray2 =
m_DD1[i][1] + phys_offset);
1132 if (
Basis[0]->GetPointsType() ==
1134 Basis[1]->GetPointsType() ==
1148 &outarray[i][0], 1);
1153 &outarray[i][0], 1);
1156 if (!(
Basis[0]->Collocation()))
1158 fields[i]->FwdTrans(outarray[i], outarrayCoeff[i]);
1159 fields[i]->BwdTrans(outarrayCoeff[i], outarray[i]);
1167 ASSERTL0(
false,
"3D FRDG case not implemented yet");
1183 int nTracePts = fields[0]->GetTrace()->GetTotPoints();
1184 int nvariables = fields.size();
1185 int nDim = fields[0]->GetCoordim(0);
1193 for (i = 0; i < nDim; ++i)
1201 for (j = 0; j < nDim; ++j)
1203 for (i = 0; i < nvariables; ++i)
1206 fields[i]->GetFwdBwdTracePhys(ufield[i], Fwd, Bwd);
1216 fields[i]->GetTrace()->Upwind(Vn, Fwd, Bwd, fluxtemp);
1227 if (fields[0]->GetBndCondExpansions().size())
1258 int nBndEdgePts, nBndEdges;
1260 int nBndRegions = fields[var]->GetBndCondExpansions().size();
1261 int nTracePts = fields[0]->GetTrace()->GetTotPoints();
1265 fields[var]->ExtractTracePhys(ufield, uplus);
1268 for (i = 0; i < nBndRegions; ++i)
1271 nBndEdges = fields[var]->GetBndCondExpansions()[i]->GetExpSize();
1274 for (e = 0; e < nBndEdges; ++e)
1277 nBndEdgePts = fields[var]
1278 ->GetBndCondExpansions()[i]
1283 id1 = fields[var]->GetBndCondExpansions()[i]->GetPhys_Offset(e);
1286 id2 = fields[0]->GetTrace()->GetPhys_Offset(
1287 fields[0]->GetTraceMap()->GetBndCondIDToGlobalTraceID(cnt++));
1291 ->GetBndConditions()[i]
1296 &(fields[var]->GetBndCondExpansions()[i]->GetPhys())[id1],
1297 1, &penaltyflux[id2], 1);
1300 else if ((fields[var]->GetBndConditions()[i])
1301 ->GetBoundaryConditionType() ==
1304 Vmath::Vcopy(nBndEdgePts, &uplus[id2], 1, &penaltyflux[id2], 1);
1320 boost::ignore_unused(ufield);
1323 int nTracePts = fields[0]->GetTrace()->GetTotPoints();
1324 int nvariables = fields.size();
1325 int nDim = fields[0]->GetCoordim(0);
1338 for (i = 0; i < nDim; ++i)
1345 for (i = 0; i < nvariables; ++i)
1348 for (j = 0; j < nDim; ++j)
1351 fields[i]->GetFwdBwdTracePhys(qfield[i][j], qFwd, qBwd);
1365 fields[i]->GetTrace()->Upwind(Vn, qBwd, qFwd, qfluxtemp);
1371 if (fields[0]->GetBndCondExpansions().size())
1380 Vmath::Vadd(nTracePts, qfluxtemp, 1, qflux[i], 1, qflux[i], 1);
1394 boost::ignore_unused(C11);
1397 int nBndEdges, nBndEdgePts;
1398 int nBndRegions = fields[var]->GetBndCondExpansions().size();
1399 int nTracePts = fields[0]->GetTrace()->GetTotPoints();
1405 fields[var]->ExtractTracePhys(qfield, qtemp);
1407 for (i = 0; i < nBndRegions; ++i)
1409 nBndEdges = fields[var]->GetBndCondExpansions()[i]->GetExpSize();
1412 for (e = 0; e < nBndEdges; ++e)
1414 nBndEdgePts = fields[var]
1415 ->GetBndCondExpansions()[i]
1419 id1 = fields[var]->GetBndCondExpansions()[i]->GetPhys_Offset(e);
1421 id2 = fields[0]->GetTrace()->GetPhys_Offset(
1422 fields[0]->GetTraceMap()->GetBndCondIDToGlobalTraceID(cnt++));
1427 ->GetBndConditions()[i]
1431 &qtemp[id2], 1, &penaltyflux[id2], 1);
1434 else if ((fields[var]->GetBndConditions()[i])
1435 ->GetBoundaryConditionType() ==
1440 &(fields[var]->GetBndCondExpansions()[i]->GetPhys())[id1],
1441 1, &penaltyflux[id2], 1);
1458 const int nConvectiveFields,
1463 boost::ignore_unused(nConvectiveFields);
1466 int nLocalSolutionPts, phys_offset, t_offset;
1474 Basis = fields[0]->GetExp(0)->GetBasis(0);
1476 int nElements = fields[0]->GetExpSize();
1477 int nSolutionPts = fields[0]->GetTotPoints();
1479 vector<bool> leftAdjacentTraces =
1480 std::static_pointer_cast<MultiRegions::DisContField>(fields[0])
1481 ->GetLeftAdjacentTraces();
1492 fields[0]->GetTraceMap()->GetElmtToTrace();
1494 for (n = 0; n < nElements; ++n)
1496 nLocalSolutionPts = fields[0]->GetExp(n)->GetTotPoints();
1497 phys_offset = fields[0]->GetPhys_Offset(n);
1501 Vmath::Vcopy(nLocalSolutionPts, &flux[phys_offset], 1, &tmparrayX1[0],
1504 fields[0]->GetExp(n)->GetTracePhysVals(0, elmtToTrace[n][0], tmparrayX1,
1507 t_offset = fields[0]->GetTrace()->GetPhys_Offset(
1508 elmtToTrace[n][0]->GetElmtId());
1510 if (leftAdjacentTraces[2 * n])
1512 JumpL[n] = -iFlux[t_offset] - tmpFluxVertex[0];
1516 JumpL[n] = iFlux[t_offset] - tmpFluxVertex[0];
1519 t_offset = fields[0]->GetTrace()->GetPhys_Offset(
1520 elmtToTrace[n][1]->GetElmtId());
1522 fields[0]->GetExp(n)->GetTracePhysVals(1, elmtToTrace[n][1], tmparrayX1,
1524 if (leftAdjacentTraces[2 * n + 1])
1526 JumpR[n] = iFlux[t_offset] - tmpFluxVertex[0];
1530 JumpR[n] = -iFlux[t_offset] - tmpFluxVertex[0];
1534 for (n = 0; n < nElements; ++n)
1536 ptsKeys = fields[0]->GetExp(n)->GetPointsKeys();
1537 nLocalSolutionPts = fields[0]->GetExp(n)->GetTotPoints();
1538 phys_offset = fields[0]->GetPhys_Offset(n);
1546 JumpL[n] = JumpL[n] * jac[0];
1547 JumpR[n] = JumpR[n] * jac[0];
1558 Vmath::Vadd(nLocalSolutionPts, &DCL[0], 1, &DCR[0], 1,
1559 &derCFlux[phys_offset], 1);
1579 const int nConvectiveFields,
const int direction,
1584 boost::ignore_unused(nConvectiveFields);
1586 int n, e, i, j, cnt;
1590 int nElements = fields[0]->GetExpSize();
1591 int trace_offset, phys_offset;
1592 int nLocalSolutionPts;
1600 fields[0]->GetTraceMap()->GetElmtToTrace();
1603 for (n = 0; n < nElements; ++n)
1606 phys_offset = fields[0]->GetPhys_Offset(n);
1607 nLocalSolutionPts = fields[0]->GetExp(n)->GetTotPoints();
1608 ptsKeys = fields[0]->GetExp(n)->GetPointsKeys();
1617 base = fields[0]->GetExp(n)->GetBase();
1618 nquad0 = base[0]->GetNumPoints();
1619 nquad1 = base[1]->GetNumPoints();
1627 for (e = 0; e < fields[0]->GetExp(n)->GetNtraces(); ++e)
1630 nEdgePts = fields[0]->GetExp(n)->GetTraceNumPoints(e);
1636 trace_offset = fields[0]->GetTrace()->GetPhys_Offset(
1637 elmtToTrace[n][e]->GetElmtId());
1642 fields[0]->GetExp(n)->GetTracePhysVals(
1643 e, elmtToTrace[n][e], flux + phys_offset, auxArray1 = tmparray);
1648 Vmath::Vsub(nEdgePts, &iFlux[trace_offset], 1, &tmparray[0], 1,
1653 if (fields[0]->GetExp(n)->GetTraceOrient(e) ==
1662 ->as<LocalRegions::Expansion2D>()
1670 fields[0]->GetExp(n)->GetTracePhysVals(
1671 e, elmtToTrace[n][e], jac, auxArray1 = jacEdge);
1675 if (fields[0]->GetExp(n)->GetTraceOrient(e) ==
1683 for (j = 0; j < nEdgePts; j++)
1685 fluxJumps[j] = fluxJumps[j] * jacEdge[j];
1693 Vmath::Smul(nEdgePts, jac[0], fluxJumps, 1, fluxJumps, 1);
1702 for (i = 0; i < nquad0; ++i)
1704 for (j = 0; j < nquad1; ++j)
1706 cnt = i + j * nquad0;
1707 divCFluxE0[cnt] = fluxJumps[i] *
m_dGL_xi2[n][j];
1712 for (i = 0; i < nquad1; ++i)
1714 for (j = 0; j < nquad0; ++j)
1716 cnt = (nquad0)*i + j;
1717 divCFluxE1[cnt] = fluxJumps[i] *
m_dGR_xi1[n][j];
1722 for (i = 0; i < nquad0; ++i)
1724 for (j = 0; j < nquad1; ++j)
1726 cnt = j * nquad0 + i;
1727 divCFluxE2[cnt] = fluxJumps[i] *
m_dGR_xi2[n][j];
1732 for (i = 0; i < nquad1; ++i)
1734 for (j = 0; j < nquad0; ++j)
1736 cnt = j + i * nquad0;
1737 divCFluxE3[cnt] = fluxJumps[i] *
m_dGL_xi1[n][j];
1743 ASSERTL0(
false,
"edge value (< 3) is out of range");
1752 Vmath::Vadd(nLocalSolutionPts, &divCFluxE1[0], 1, &divCFluxE3[0], 1,
1753 &derCFlux[phys_offset], 1);
1755 else if (direction == 1)
1757 Vmath::Vadd(nLocalSolutionPts, &divCFluxE0[0], 1, &divCFluxE2[0], 1,
1758 &derCFlux[phys_offset], 1);
1777 const int nConvectiveFields,
1784 boost::ignore_unused(nConvectiveFields);
1786 int n, e, i, j, cnt;
1788 int nElements = fields[0]->GetExpSize();
1790 int nLocalSolutionPts;
1801 fields[0]->GetTraceMap()->GetElmtToTrace();
1804 for (n = 0; n < nElements; ++n)
1807 phys_offset = fields[0]->GetPhys_Offset(n);
1808 nLocalSolutionPts = fields[0]->GetExp(n)->GetTotPoints();
1810 base = fields[0]->GetExp(n)->GetBase();
1811 nquad0 = base[0]->GetNumPoints();
1812 nquad1 = base[1]->GetNumPoints();
1820 for (e = 0; e < fields[0]->GetExp(n)->GetNtraces(); ++e)
1823 nEdgePts = fields[0]->GetExp(n)->GetTraceNumPoints(e);
1832 trace_offset = fields[0]->GetTrace()->GetPhys_Offset(
1833 elmtToTrace[n][e]->GetElmtId());
1837 fields[0]->GetExp(n)->GetTraceNormal(e);
1841 fields[0]->GetExp(n)->GetTracePhysVals(e, elmtToTrace[n][e],
1842 fluxX1 + phys_offset,
1843 auxArray1 = tmparrayX1);
1847 fields[0]->GetExp(n)->GetTracePhysVals(e, elmtToTrace[n][e],
1848 fluxX2 + phys_offset,
1849 auxArray1 = tmparrayX2);
1852 for (i = 0; i < nEdgePts; ++i)
1859 Vmath::Vsub(nEdgePts, &numericalFlux[trace_offset], 1, &fluxN[0], 1,
1863 if (fields[0]->GetExp(n)->GetTraceOrient(e) ==
1867 auxArray2 = fluxJumps, 1);
1870 for (i = 0; i < nEdgePts; ++i)
1875 fluxJumps[i] = -fluxJumps[i];
1883 for (i = 0; i < nquad0; ++i)
1886 fluxJumps[i] = -(
m_Q2D_e0[n][i]) * fluxJumps[i];
1888 for (j = 0; j < nquad1; ++j)
1890 cnt = i + j * nquad0;
1891 divCFluxE0[cnt] = fluxJumps[i] *
m_dGL_xi2[n][j];
1896 for (i = 0; i < nquad1; ++i)
1899 fluxJumps[i] = (
m_Q2D_e1[n][i]) * fluxJumps[i];
1901 for (j = 0; j < nquad0; ++j)
1903 cnt = (nquad0)*i + j;
1904 divCFluxE1[cnt] = fluxJumps[i] *
m_dGR_xi1[n][j];
1909 for (i = 0; i < nquad0; ++i)
1912 fluxJumps[i] = (
m_Q2D_e2[n][i]) * fluxJumps[i];
1914 for (j = 0; j < nquad1; ++j)
1916 cnt = j * nquad0 + i;
1917 divCFluxE2[cnt] = fluxJumps[i] *
m_dGR_xi2[n][j];
1922 for (i = 0; i < nquad1; ++i)
1925 fluxJumps[i] = -(
m_Q2D_e3[n][i]) * fluxJumps[i];
1926 for (j = 0; j < nquad0; ++j)
1928 cnt = j + i * nquad0;
1929 divCFluxE3[cnt] = fluxJumps[i] *
m_dGL_xi1[n][j];
1935 ASSERTL0(
false,
"edge value (< 3) is out of range");
1941 Vmath::Vadd(nLocalSolutionPts, &divCFluxE0[0], 1, &divCFluxE1[0], 1,
1942 &divCFlux[phys_offset], 1);
1944 Vmath::Vadd(nLocalSolutionPts, &divCFlux[phys_offset], 1,
1945 &divCFluxE2[0], 1, &divCFlux[phys_offset], 1);
1947 Vmath::Vadd(nLocalSolutionPts, &divCFlux[phys_offset], 1,
1948 &divCFluxE3[0], 1, &divCFlux[phys_offset], 1);
1967 const int nConvectiveFields,
1974 boost::ignore_unused(nConvectiveFields);
1976 int n, e, i, j, cnt;
1978 int nElements = fields[0]->GetExpSize();
1979 int nLocalSolutionPts;
1990 fields[0]->GetTraceMap()->GetElmtToTrace();
1993 for (n = 0; n < nElements; ++n)
1996 phys_offset = fields[0]->GetPhys_Offset(n);
1997 nLocalSolutionPts = fields[0]->GetExp(n)->GetTotPoints();
1999 base = fields[0]->GetExp(n)->GetBase();
2000 nquad0 = base[0]->GetNumPoints();
2001 nquad1 = base[1]->GetNumPoints();
2009 for (e = 0; e < fields[0]->GetExp(n)->GetNtraces(); ++e)
2012 nEdgePts = fields[0]->GetExp(n)->GetTraceNumPoints(e);
2021 trace_offset = fields[0]->GetTrace()->GetPhys_Offset(
2022 elmtToTrace[n][e]->GetElmtId());
2026 fields[0]->GetExp(n)->GetTraceNormal(e);
2035 fields[0]->GetExp(n)->GetTracePhysVals(e, elmtToTrace[n][e],
2036 fluxX2 + phys_offset,
2037 auxArray1 = fluxN_D);
2042 Vmath::Vcopy(nEdgePts, &numericalFlux[trace_offset], 1,
2046 if (fields[0]->GetExp(n)->GetTraceOrient(e) ==
2050 auxArray2 = fluxN, 1);
2053 auxArray2 = fluxN_D, 1);
2057 for (i = 0; i < nquad0; ++i)
2060 fluxN_R[i] = (
m_Q2D_e0[n][i]) * fluxN[i];
2063 for (i = 0; i < nEdgePts; ++i)
2070 fluxN_R[i] = -fluxN_R[i];
2076 Vmath::Vsub(nEdgePts, &fluxN_R[0], 1, &fluxN_D[0], 1,
2081 for (i = 0; i < nquad0; ++i)
2083 for (j = 0; j < nquad1; ++j)
2085 cnt = i + j * nquad0;
2086 divCFluxE0[cnt] = -fluxJumps[i] *
m_dGL_xi2[n][j];
2094 fields[0]->GetExp(n)->GetTracePhysVals(e, elmtToTrace[n][e],
2095 fluxX1 + phys_offset,
2096 auxArray1 = fluxN_D);
2099 Vmath::Vcopy(nEdgePts, &numericalFlux[trace_offset], 1,
2103 if (fields[0]->GetExp(n)->GetTraceOrient(e) ==
2107 auxArray2 = fluxN, 1);
2110 auxArray2 = fluxN_D, 1);
2114 for (i = 0; i < nquad1; ++i)
2117 fluxN_R[i] = (
m_Q2D_e1[n][i]) * fluxN[i];
2120 for (i = 0; i < nEdgePts; ++i)
2127 fluxN_R[i] = -fluxN_R[i];
2133 Vmath::Vsub(nEdgePts, &fluxN_R[0], 1, &fluxN_D[0], 1,
2138 for (i = 0; i < nquad1; ++i)
2140 for (j = 0; j < nquad0; ++j)
2142 cnt = (nquad0)*i + j;
2143 divCFluxE1[cnt] = fluxJumps[i] *
m_dGR_xi1[n][j];
2153 fields[0]->GetExp(n)->GetTracePhysVals(e, elmtToTrace[n][e],
2154 fluxX2 + phys_offset,
2155 auxArray1 = fluxN_D);
2158 Vmath::Vcopy(nEdgePts, &numericalFlux[trace_offset], 1,
2162 if (fields[0]->GetExp(n)->GetTraceOrient(e) ==
2166 auxArray2 = fluxN, 1);
2169 auxArray2 = fluxN_D, 1);
2173 for (i = 0; i < nquad0; ++i)
2176 fluxN_R[i] = (
m_Q2D_e2[n][i]) * fluxN[i];
2179 for (i = 0; i < nEdgePts; ++i)
2186 fluxN_R[i] = -fluxN_R[i];
2193 Vmath::Vsub(nEdgePts, &fluxN_R[0], 1, &fluxN_D[0], 1,
2198 for (i = 0; i < nquad0; ++i)
2200 for (j = 0; j < nquad1; ++j)
2202 cnt = j * nquad0 + i;
2203 divCFluxE2[cnt] = fluxJumps[i] *
m_dGR_xi2[n][j];
2212 fields[0]->GetExp(n)->GetTracePhysVals(e, elmtToTrace[n][e],
2213 fluxX1 + phys_offset,
2214 auxArray1 = fluxN_D);
2218 Vmath::Vcopy(nEdgePts, &numericalFlux[trace_offset], 1,
2222 if (fields[0]->GetExp(n)->GetTraceOrient(e) ==
2226 auxArray2 = fluxN, 1);
2229 auxArray2 = fluxN_D, 1);
2233 for (i = 0; i < nquad1; ++i)
2236 fluxN_R[i] = (
m_Q2D_e3[n][i]) * fluxN[i];
2239 for (i = 0; i < nEdgePts; ++i)
2246 fluxN_R[i] = -fluxN_R[i];
2253 Vmath::Vsub(nEdgePts, &fluxN_R[0], 1, &fluxN_D[0], 1,
2258 for (i = 0; i < nquad1; ++i)
2260 for (j = 0; j < nquad0; ++j)
2262 cnt = j + i * nquad0;
2263 divCFluxE3[cnt] = -fluxJumps[i] *
m_dGL_xi1[n][j];
2268 ASSERTL0(
false,
"edge value (< 3) is out of range");
2274 Vmath::Vadd(nLocalSolutionPts, &divCFluxE0[0], 1, &divCFluxE1[0], 1,
2275 &divCFlux[phys_offset], 1);
2277 Vmath::Vadd(nLocalSolutionPts, &divCFlux[phys_offset], 1,
2278 &divCFluxE2[0], 1, &divCFlux[phys_offset], 1);
2280 Vmath::Vadd(nLocalSolutionPts, &divCFlux[phys_offset], 1,
2281 &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
virtual void v_Diffuse(const 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, 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
DiffusionLFR(std::string diffType)
DiffusionLFR uses the Flux Reconstruction (FR) approach to compute the diffusion term....
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
static std::string type[]
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
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.
static DiffusionSharedPtr create(std::string diffType)
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
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, 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
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.