39 #include <boost/algorithm/string/predicate.hpp>
40 #include <boost/core/ignore_unused.hpp>
41 #include <boost/math/special_functions/gamma.hpp>
103 int nConvectiveFields = pFields.size();
104 int nScalars = nConvectiveFields - 1;
105 int nDim = pFields[0]->GetCoordim(0);
106 int nSolutionPts = pFields[0]->GetTotPoints();
107 int nTracePts = pFields[0]->GetTrace()->GetTotPoints();
110 if (pSession->DefinesSolverInfo(
"HOMOGENEOUS"))
140 for (i = 0; i < nScalars; ++i)
149 for (j = 0; j < nDim; ++j)
160 for (i = 0; i < nConvectiveFields; ++i)
168 for (j = 0; j < nDim; ++j)
179 for (j = 0; j < nScalars; ++j)
189 for (j = 0; j < nScalars + 1; ++j)
216 boost::ignore_unused(pSession);
221 int nLocalSolutionPts;
222 int nElements = pFields[0]->GetExpSize();
223 int nDimensions = pFields[0]->GetCoordim(0);
224 int nSolutionPts = pFields[0]->GetTotPoints();
225 int nTracePts = pFields[0]->GetTrace()->GetTotPoints();
228 for (i = 0; i < nDimensions; ++i)
247 for (n = 0; n < nElements; ++n)
249 ptsKeys = pFields[0]->GetExp(n)->GetPointsKeys();
250 nLocalSolutionPts = pFields[0]->GetExp(n)->GetTotPoints();
251 phys_offset = pFields[0]->GetPhys_Offset(n);
258 for (i = 0; i < nLocalSolutionPts; ++i)
260 m_jac[i + phys_offset] = jac[0];
278 for (n = 0; n < nElements; ++n)
280 base = pFields[0]->GetExp(n)->GetBase();
281 nquad0 = base[0]->GetNumPoints();
282 nquad1 = base[1]->GetNumPoints();
290 pFields[0]->GetExp(n)->GetTraceQFactors(0, auxArray1 =
292 pFields[0]->GetExp(n)->GetTraceQFactors(1, auxArray1 =
294 pFields[0]->GetExp(n)->GetTraceQFactors(2, auxArray1 =
296 pFields[0]->GetExp(n)->GetTraceQFactors(3, auxArray1 =
299 ptsKeys = pFields[0]->GetExp(n)->GetPointsKeys();
300 nLocalSolutionPts = pFields[0]->GetExp(n)->GetTotPoints();
301 phys_offset = pFields[0]->GetPhys_Offset(n);
314 ->GetDerivFactors(ptsKeys);
323 for (i = 0; i < nLocalSolutionPts; ++i)
325 m_jac[i + phys_offset] = jac[i];
326 m_gmat[0][i + phys_offset] = gmat[0][i];
327 m_gmat[1][i + phys_offset] = gmat[1][i];
328 m_gmat[2][i + phys_offset] = gmat[2][i];
329 m_gmat[3][i + phys_offset] = gmat[3][i];
334 for (i = 0; i < nLocalSolutionPts; ++i)
336 m_jac[i + phys_offset] = jac[0];
337 m_gmat[0][i + phys_offset] = gmat[0][0];
338 m_gmat[1][i + phys_offset] = gmat[1][0];
339 m_gmat[2][i + phys_offset] = gmat[2][0];
340 m_gmat[3][i + phys_offset] = gmat[3][0];
348 ASSERTL0(
false,
"3DFR Metric terms not implemented yet");
353 ASSERTL0(
false,
"Expansion dimension not recognised");
379 boost::ignore_unused(pSession);
385 int nquad0, nquad1, nquad2;
386 int nmodes0, nmodes1, nmodes2;
389 int nElements = pFields[0]->GetExpSize();
390 int nDim = pFields[0]->GetCoordim(0);
399 for (n = 0; n < nElements; ++n)
401 base = pFields[0]->GetExp(n)->GetBase();
402 nquad0 = base[0]->GetNumPoints();
403 nmodes0 = base[0]->GetNumModes();
407 base[0]->GetZW(z0, w0);
419 int p0 = nmodes0 - 1;
425 NekDouble ap0 = boost::math::tgamma(2 * p0 + 1) /
426 (pow(2.0, p0) * boost::math::tgamma(p0 + 1) *
427 boost::math::tgamma(p0 + 1));
437 ((2.0 * p0 + 1.0) * (p0 + 1.0) *
438 (ap0 * boost::math::tgamma(p0 + 1)) *
439 (ap0 * boost::math::tgamma(p0 + 1)));
443 c0 = 2.0 * (p0 + 1.0) /
444 ((2.0 * p0 + 1.0) * p0 *
445 (ap0 * boost::math::tgamma(p0 + 1)) *
446 (ap0 * boost::math::tgamma(p0 + 1)));
450 c0 = -2.0 / ((2.0 * p0 + 1.0) *
451 (ap0 * boost::math::tgamma(p0 + 1)) *
452 (ap0 * boost::math::tgamma(p0 + 1)));
456 c0 = 10000000000000000.0;
459 NekDouble etap0 = 0.5 * c0 * (2.0 * p0 + 1.0) *
460 (ap0 * boost::math::tgamma(p0 + 1)) *
461 (ap0 * boost::math::tgamma(p0 + 1));
463 NekDouble overeta0 = 1.0 / (1.0 + etap0);
476 for (i = 0; i < nquad0; ++i)
486 for (i = 0; i < nquad0; ++i)
509 for (n = 0; n < nElements; ++n)
511 base = pFields[0]->GetExp(n)->GetBase();
512 nquad0 = base[0]->GetNumPoints();
513 nquad1 = base[1]->GetNumPoints();
514 nmodes0 = base[0]->GetNumModes();
515 nmodes1 = base[1]->GetNumModes();
522 base[0]->GetZW(z0, w0);
523 base[1]->GetZW(z1, w1);
540 int p0 = nmodes0 - 1;
541 int p1 = nmodes1 - 1;
548 NekDouble ap0 = boost::math::tgamma(2 * p0 + 1) /
549 (pow(2.0, p0) * boost::math::tgamma(p0 + 1) *
550 boost::math::tgamma(p0 + 1));
552 NekDouble ap1 = boost::math::tgamma(2 * p1 + 1) /
553 (pow(2.0, p1) * boost::math::tgamma(p1 + 1) *
554 boost::math::tgamma(p1 + 1));
565 ((2.0 * p0 + 1.0) * (p0 + 1.0) *
566 (ap0 * boost::math::tgamma(p0 + 1)) *
567 (ap0 * boost::math::tgamma(p0 + 1)));
570 ((2.0 * p1 + 1.0) * (p1 + 1.0) *
571 (ap1 * boost::math::tgamma(p1 + 1)) *
572 (ap1 * boost::math::tgamma(p1 + 1)));
576 c0 = 2.0 * (p0 + 1.0) /
577 ((2.0 * p0 + 1.0) * p0 *
578 (ap0 * boost::math::tgamma(p0 + 1)) *
579 (ap0 * boost::math::tgamma(p0 + 1)));
581 c1 = 2.0 * (p1 + 1.0) /
582 ((2.0 * p1 + 1.0) * p1 *
583 (ap1 * boost::math::tgamma(p1 + 1)) *
584 (ap1 * boost::math::tgamma(p1 + 1)));
588 c0 = -2.0 / ((2.0 * p0 + 1.0) *
589 (ap0 * boost::math::tgamma(p0 + 1)) *
590 (ap0 * boost::math::tgamma(p0 + 1)));
592 c1 = -2.0 / ((2.0 * p1 + 1.0) *
593 (ap1 * boost::math::tgamma(p1 + 1)) *
594 (ap1 * boost::math::tgamma(p1 + 1)));
598 c0 = 10000000000000000.0;
599 c1 = 10000000000000000.0;
602 NekDouble etap0 = 0.5 * c0 * (2.0 * p0 + 1.0) *
603 (ap0 * boost::math::tgamma(p0 + 1)) *
604 (ap0 * boost::math::tgamma(p0 + 1));
606 NekDouble etap1 = 0.5 * c1 * (2.0 * p1 + 1.0) *
607 (ap1 * boost::math::tgamma(p1 + 1)) *
608 (ap1 * boost::math::tgamma(p1 + 1));
610 NekDouble overeta0 = 1.0 / (1.0 + etap0);
611 NekDouble overeta1 = 1.0 / (1.0 + etap1);
630 for (i = 0; i < nquad0; ++i)
640 for (i = 0; i < nquad1; ++i)
650 for (i = 0; i < nquad0; ++i)
660 for (i = 0; i < nquad1; ++i)
680 for (n = 0; n < nElements; ++n)
682 base = pFields[0]->GetExp(n)->GetBase();
683 nquad0 = base[0]->GetNumPoints();
684 nquad1 = base[1]->GetNumPoints();
685 nquad2 = base[2]->GetNumPoints();
686 nmodes0 = base[0]->GetNumModes();
687 nmodes1 = base[1]->GetNumModes();
688 nmodes2 = base[2]->GetNumModes();
697 base[0]->GetZW(z0, w0);
698 base[1]->GetZW(z1, w1);
699 base[1]->GetZW(z2, w2);
721 int p0 = nmodes0 - 1;
722 int p1 = nmodes1 - 1;
723 int p2 = nmodes2 - 1;
731 NekDouble ap0 = boost::math::tgamma(2 * p0 + 1) /
732 (pow(2.0, p0) * boost::math::tgamma(p0 + 1) *
733 boost::math::tgamma(p0 + 1));
736 NekDouble ap1 = boost::math::tgamma(2 * p1 + 1) /
737 (pow(2.0, p1) * boost::math::tgamma(p1 + 1) *
738 boost::math::tgamma(p1 + 1));
741 NekDouble ap2 = boost::math::tgamma(2 * p2 + 1) /
742 (pow(2.0, p2) * boost::math::tgamma(p2 + 1) *
743 boost::math::tgamma(p2 + 1));
755 ((2.0 * p0 + 1.0) * (p0 + 1.0) *
756 (ap0 * boost::math::tgamma(p0 + 1)) *
757 (ap0 * boost::math::tgamma(p0 + 1)));
760 ((2.0 * p1 + 1.0) * (p1 + 1.0) *
761 (ap1 * boost::math::tgamma(p1 + 1)) *
762 (ap1 * boost::math::tgamma(p1 + 1)));
765 ((2.0 * p2 + 1.0) * (p2 + 1.0) *
766 (ap2 * boost::math::tgamma(p2 + 1)) *
767 (ap2 * boost::math::tgamma(p2 + 1)));
771 c0 = 2.0 * (p0 + 1.0) /
772 ((2.0 * p0 + 1.0) * p0 *
773 (ap0 * boost::math::tgamma(p0 + 1)) *
774 (ap0 * boost::math::tgamma(p0 + 1)));
776 c1 = 2.0 * (p1 + 1.0) /
777 ((2.0 * p1 + 1.0) * p1 *
778 (ap1 * boost::math::tgamma(p1 + 1)) *
779 (ap1 * boost::math::tgamma(p1 + 1)));
781 c2 = 2.0 * (p2 + 1.0) /
782 ((2.0 * p2 + 1.0) * p2 *
783 (ap2 * boost::math::tgamma(p2 + 1)) *
784 (ap2 * boost::math::tgamma(p2 + 1)));
788 c0 = -2.0 / ((2.0 * p0 + 1.0) *
789 (ap0 * boost::math::tgamma(p0 + 1)) *
790 (ap0 * boost::math::tgamma(p0 + 1)));
792 c1 = -2.0 / ((2.0 * p1 + 1.0) *
793 (ap1 * boost::math::tgamma(p1 + 1)) *
794 (ap1 * boost::math::tgamma(p1 + 1)));
796 c2 = -2.0 / ((2.0 * p2 + 1.0) *
797 (ap2 * boost::math::tgamma(p2 + 1)) *
798 (ap2 * boost::math::tgamma(p2 + 1)));
802 c0 = 10000000000000000.0;
803 c1 = 10000000000000000.0;
804 c2 = 10000000000000000.0;
807 NekDouble etap0 = 0.5 * c0 * (2.0 * p0 + 1.0) *
808 (ap0 * boost::math::tgamma(p0 + 1)) *
809 (ap0 * boost::math::tgamma(p0 + 1));
811 NekDouble etap1 = 0.5 * c1 * (2.0 * p1 + 1.0) *
812 (ap1 * boost::math::tgamma(p1 + 1)) *
813 (ap1 * boost::math::tgamma(p1 + 1));
815 NekDouble etap2 = 0.5 * c2 * (2.0 * p2 + 1.0) *
816 (ap2 * boost::math::tgamma(p2 + 1)) *
817 (ap2 * boost::math::tgamma(p2 + 1));
819 NekDouble overeta0 = 1.0 / (1.0 + etap0);
820 NekDouble overeta1 = 1.0 / (1.0 + etap1);
821 NekDouble overeta2 = 1.0 / (1.0 + etap2);
846 for (i = 0; i < nquad0; ++i)
856 for (i = 0; i < nquad1; ++i)
866 for (i = 0; i < nquad2; ++i)
876 for (i = 0; i < nquad0; ++i)
886 for (i = 0; i < nquad1; ++i)
896 for (i = 0; i < nquad2; ++i)
909 ASSERTL0(
false,
"Expansion dimension not recognised");
924 const std::size_t nConvectiveFields,
931 boost::ignore_unused(pFwd, pBwd);
941 Basis = fields[0]->GetExp(0)->GetBase();
943 int nElements = fields[0]->GetExpSize();
944 int nDim = fields[0]->GetCoordim(0);
945 int nScalars = inarray.size();
946 int nSolutionPts = fields[0]->GetTotPoints();
947 int nCoeffs = fields[0]->GetNcoeffs();
950 for (i = 0; i < nConvectiveFields; ++i)
963 for (i = 0; i < nScalars; ++i)
967 for (n = 0; n < nElements; n++)
969 phys_offset = fields[0]->GetPhys_Offset(n);
971 fields[i]->GetExp(n)->PhysDeriv(
972 0, auxArray1 = inarray[i] + phys_offset,
973 auxArray2 =
m_DU1[i][0] + phys_offset);
989 1, &
m_D1[i][0][0], 1);
1002 for (i = 0; i < nConvectiveFields; ++i)
1006 for (n = 0; n < nElements; n++)
1008 phys_offset = fields[0]->GetPhys_Offset(n);
1010 fields[i]->GetExp(n)->PhysDeriv(
1012 auxArray2 =
m_DD1[i][0] + phys_offset);
1028 1, &outarray[i][0], 1);
1031 if (!(
Basis[0]->Collocation()))
1033 fields[i]->FwdTrans(outarray[i], outarrayCoeff[i]);
1034 fields[i]->BwdTrans(outarrayCoeff[i], outarray[i]);
1042 for (i = 0; i < nScalars; ++i)
1044 for (j = 0; j < nDim; ++j)
1053 &
m_gmat[0][0], 1, &u1_hat[0], 1);
1059 &
m_gmat[1][0], 1, &u2_hat[0], 1);
1067 &
m_gmat[2][0], 1, &u1_hat[0], 1);
1073 &
m_gmat[3][0], 1, &u2_hat[0], 1);
1079 for (n = 0; n < nElements; n++)
1081 phys_offset = fields[0]->GetPhys_Offset(n);
1083 fields[i]->GetExp(n)->StdPhysDeriv(
1084 0, auxArray1 = u1_hat + phys_offset,
1085 auxArray2 =
m_tmp1[i][j] + phys_offset);
1087 fields[i]->GetExp(n)->StdPhysDeriv(
1088 1, auxArray1 = u2_hat + phys_offset,
1089 auxArray2 =
m_tmp2[i][j] + phys_offset);
1097 &
m_DU1[i][j][0], 1);
1107 for (j = 0; j < nSolutionPts; ++j)
1128 for (j = 0; j < nSolutionPts; j++)
1140 for (j = 0; j < nDim; ++j)
1150 for (i = 0; i < nScalars; ++i)
1165 for (i = 0; i < nConvectiveFields; ++i)
1171 for (j = 0; j < nSolutionPts; j++)
1182 for (n = 0; n < nElements; n++)
1184 phys_offset = fields[0]->GetPhys_Offset(n);
1186 fields[0]->GetExp(n)->StdPhysDeriv(
1187 0, auxArray1 = f_hat + phys_offset,
1188 auxArray2 =
m_DD1[i][0] + phys_offset);
1190 fields[0]->GetExp(n)->StdPhysDeriv(
1191 1, auxArray1 = g_hat + phys_offset,
1192 auxArray2 =
m_DD1[i][1] + phys_offset);
1200 if (
Basis[0]->GetPointsType() ==
1202 Basis[1]->GetPointsType() ==
1217 &outarray[i][0], 1);
1222 &outarray[i][0], 1);
1225 if (!(
Basis[0]->Collocation()))
1227 fields[i]->FwdTrans(outarray[i], outarrayCoeff[i]);
1228 fields[i]->BwdTrans(outarrayCoeff[i], outarray[i]);
1236 ASSERTL0(
false,
"3D FRDG case not implemented yet");
1252 int nTracePts = fields[0]->GetTrace()->GetTotPoints();
1253 int nScalars = inarray.size();
1254 int nDim = fields[0]->GetCoordim(0);
1260 for (i = 0; i < nDim; ++i)
1262 fields[0]->ExtractTracePhys(inarray[i],
m_traceVel[i]);
1272 for (i = 0; i < nScalars; ++i)
1277 fields[i]->GetFwdBwdTracePhys(inarray[i], Fwd[i], Bwd[i]);
1278 fields[0]->GetTrace()->Upwind(Vn, Fwd[i], Bwd[i], numflux[i]);
1282 if (fields[0]->GetBndCondExpansions().size())
1288 for (j = 0; j < nDim; ++j)
1290 for (i = 0; i < nScalars; ++i)
1292 Vmath::Vcopy(nTracePts, numflux[i], 1, numericalFluxO1[i][j], 1);
1310 int nBndEdgePts, nBndEdges, nBndRegions;
1312 int nTracePts = fields[0]->GetTrace()->GetTotPoints();
1313 int nScalars = inarray.size();
1323 for (i = 0; i < nScalars; ++i)
1328 fields[i]->ExtractTracePhys(inarray[i], uplus[i]);
1332 for (i = 0; i < nScalars - 1; ++i)
1337 nBndRegions = fields[i + 1]->GetBndCondExpansions().size();
1338 for (j = 0; j < nBndRegions; ++j)
1341 ->GetBndConditions()[j]
1347 nBndEdges = fields[i + 1]->GetBndCondExpansions()[j]->GetExpSize();
1348 for (e = 0; e < nBndEdges; ++e)
1350 nBndEdgePts = fields[i + 1]
1351 ->GetBndCondExpansions()[j]
1356 fields[i + 1]->GetBndCondExpansions()[j]->GetPhys_Offset(e);
1358 id2 = fields[0]->GetTrace()->GetPhys_Offset(
1359 fields[0]->GetTraceMap()->GetBndCondIDToGlobalTraceID(
1364 fields[i]->GetBndConditions()[j]->GetUserDefined(),
1367 fields[i]->GetBndConditions()[j]->GetUserDefined(),
1370 Vmath::Zero(nBndEdgePts, &scalarVariables[i][id2], 1);
1375 ->GetBndConditions()[j]
1376 ->GetBoundaryConditionType() ==
1381 ->GetBndCondExpansions()[j]
1382 ->UpdatePhys())[id1],
1385 ->GetBndCondExpansions()[j]
1386 ->UpdatePhys())[id1],
1387 1, &scalarVariables[i][id2], 1);
1392 ->GetBndConditions()[j]
1393 ->GetBoundaryConditionType() ==
1397 &penaltyfluxO1[i][id2], 1);
1401 else if ((fields[i]->GetBndConditions()[j])
1402 ->GetBoundaryConditionType() ==
1406 &penaltyfluxO1[i][id2], 1);
1410 Vmath::Vmul(nBndEdgePts, &scalarVariables[i][id2], 1,
1411 &scalarVariables[i][id2], 1, &tmp1[id2], 1);
1413 Vmath::Smul(nBndEdgePts, 0.5, &tmp1[id2], 1, &tmp1[id2], 1);
1415 Vmath::Vadd(nBndEdgePts, &tmp2[id2], 1, &tmp1[id2], 1,
1423 nBndRegions = fields[nScalars]->GetBndCondExpansions().size();
1424 for (j = 0; j < nBndRegions; ++j)
1426 nBndEdges = fields[nScalars]->GetBndCondExpansions()[j]->GetExpSize();
1428 if (fields[nScalars]
1429 ->GetBndConditions()[j]
1435 for (e = 0; e < nBndEdges; ++e)
1437 nBndEdgePts = fields[nScalars]
1438 ->GetBndCondExpansions()[j]
1443 fields[nScalars]->GetBndCondExpansions()[j]->GetPhys_Offset(e);
1445 id2 = fields[0]->GetTrace()->GetPhys_Offset(
1446 fields[0]->GetTraceMap()->GetBndCondIDToGlobalTraceID(cnt++));
1450 fields[i]->GetBndConditions()[j]->GetUserDefined(),
1454 &scalarVariables[nScalars - 1][id2], 1);
1459 ->GetBndConditions()[j]
1460 ->GetBoundaryConditionType() ==
1467 ->GetBndCondExpansions()[j]
1469 1, &(fields[0]->GetBndCondExpansions()[j]->GetPhys())[id1],
1470 1, &scalarVariables[nScalars - 1][id2], 1);
1473 Vmath::Vsub(nBndEdgePts, &scalarVariables[nScalars - 1][id2], 1,
1474 &tmp2[id2], 1, &scalarVariables[nScalars - 1][id2],
1479 &scalarVariables[nScalars - 1][id2], 1,
1480 &scalarVariables[nScalars - 1][id2], 1);
1484 if (fields[nScalars]
1485 ->GetBndConditions()[j]
1486 ->GetBoundaryConditionType() ==
1489 fields[nScalars]->GetBndConditions()[j]->GetUserDefined(),
1492 Vmath::Vcopy(nBndEdgePts, &scalarVariables[nScalars - 1][id2],
1493 1, &penaltyfluxO1[nScalars - 1][id2], 1);
1497 else if (((fields[nScalars]->GetBndConditions()[j])
1498 ->GetBoundaryConditionType() ==
1500 boost::iequals(fields[nScalars]
1501 ->GetBndConditions()[j]
1505 Vmath::Vcopy(nBndEdgePts, &uplus[nScalars - 1][id2], 1,
1506 &penaltyfluxO1[nScalars - 1][id2], 1);
1523 int nTracePts = fields[0]->GetTrace()->GetTotPoints();
1524 int nVariables = fields.size();
1525 int nDim = fields[0]->GetCoordim(0);
1536 for (i = 0; i < nDim; ++i)
1538 fields[0]->ExtractTracePhys(ufield[i],
m_traceVel[i]);
1546 for (i = 1; i < nVariables; ++i)
1549 for (j = 0; j < nDim; ++j)
1552 fields[i]->GetFwdBwdTracePhys(qfield[j][i], qFwd, qBwd);
1555 fields[i]->GetTrace()->Upwind(Vn, qBwd, qFwd, qfluxtemp);
1562 if (fields[0]->GetBndCondExpansions().size())
1568 Vmath::Vadd(nTracePts, qfluxtemp, 1, qflux[i], 1, qflux[i], 1);
1583 int nBndEdges, nBndEdgePts;
1587 int nTracePts = fields[0]->GetTrace()->GetTotPoints();
1588 int nBndRegions = fields[var]->GetBndCondExpansions().size();
1594 fields[var]->ExtractTracePhys(qfield, qtemp);
1597 for (i = 0; i < nBndRegions; ++i)
1600 nBndEdges = fields[var]->GetBndCondExpansions()[i]->GetExpSize();
1602 if (fields[var]->GetBndConditions()[i]->GetBoundaryConditionType() ==
1609 for (e = 0; e < nBndEdges; ++e)
1611 nBndEdgePts = fields[var]
1612 ->GetBndCondExpansions()[i]
1616 id2 = fields[0]->GetTrace()->GetPhys_Offset(
1617 fields[0]->GetTraceMap()->GetBndCondIDToGlobalTraceID(cnt++));
1622 ->GetBndConditions()[i]
1623 ->GetBoundaryConditionType() ==
1626 fields[var]->GetBndConditions()[i]->GetUserDefined(),
1630 &qtemp[id2], 1, &penaltyflux[id2], 1);
1634 else if ((fields[var]->GetBndConditions()[i])
1635 ->GetBoundaryConditionType() ==
1638 ASSERTL0(
false,
"Neumann bcs not implemented for LFRNS");
1640 else if (boost::iequals(
1641 fields[var]->GetBndConditions()[i]->GetUserDefined(),
1652 &qtemp[id2], 1, &penaltyflux[id2], 1);
1670 const int nConvectiveFields,
1675 boost::ignore_unused(nConvectiveFields);
1678 int nLocalSolutionPts, phys_offset;
1686 Basis = fields[0]->GetExp(0)->GetBasis(0);
1688 int nElements = fields[0]->GetExpSize();
1689 int nPts = fields[0]->GetTotPoints();
1700 fields[0]->GetTraceMap()->GetElmtToTrace();
1702 for (n = 0; n < nElements; ++n)
1704 nLocalSolutionPts = fields[0]->GetExp(n)->GetTotPoints();
1705 phys_offset = fields[0]->GetPhys_Offset(n);
1709 Vmath::Vcopy(nLocalSolutionPts, &flux[phys_offset], 1, &tmparrayX1[0],
1712 fields[0]->GetExp(n)->GetTracePhysVals(0, elmtToTrace[n][0], tmparrayX1,
1714 JumpL[n] = iFlux[n] - tmpFluxVertex[0];
1716 fields[0]->GetExp(n)->GetTracePhysVals(1, elmtToTrace[n][1], tmparrayX1,
1718 JumpR[n] = iFlux[n + 1] - tmpFluxVertex[0];
1721 for (n = 0; n < nElements; ++n)
1723 ptsKeys = fields[0]->GetExp(n)->GetPointsKeys();
1724 nLocalSolutionPts = fields[0]->GetExp(n)->GetTotPoints();
1725 phys_offset = fields[0]->GetPhys_Offset(n);
1733 JumpL[n] = JumpL[n] * jac[0];
1734 JumpR[n] = JumpR[n] * jac[0];
1745 Vmath::Vadd(nLocalSolutionPts, &DCL[0], 1, &DCR[0], 1,
1746 &derCFlux[phys_offset], 1);
1766 const int nConvectiveFields,
const int direction,
1771 boost::ignore_unused(nConvectiveFields);
1773 int n, e, i, j, cnt;
1777 int nElements = fields[0]->GetExpSize();
1778 int trace_offset, phys_offset;
1779 int nLocalSolutionPts;
1787 fields[0]->GetTraceMap()->GetElmtToTrace();
1790 for (n = 0; n < nElements; ++n)
1793 phys_offset = fields[0]->GetPhys_Offset(n);
1794 nLocalSolutionPts = fields[0]->GetExp(n)->GetTotPoints();
1795 ptsKeys = fields[0]->GetExp(n)->GetPointsKeys();
1804 base = fields[0]->GetExp(n)->GetBase();
1805 nquad0 = base[0]->GetNumPoints();
1806 nquad1 = base[1]->GetNumPoints();
1814 for (e = 0; e < fields[0]->GetExp(n)->GetNtraces(); ++e)
1817 nEdgePts = fields[0]->GetExp(n)->GetTraceNumPoints(e);
1823 trace_offset = fields[0]->GetTrace()->GetPhys_Offset(
1824 elmtToTrace[n][e]->GetElmtId());
1833 fields[0]->GetExp(n)->GetTracePhysVals(
1834 e, elmtToTrace[n][e], flux + phys_offset, auxArray1 = tmparray);
1844 Vmath::Vsub(nEdgePts, &iFlux[trace_offset], 1, &tmparray[0], 1,
1849 if (fields[0]->GetExp(n)->GetTraceOrient(e) ==
1858 ->as<LocalRegions::Expansion2D>()
1865 fields[0]->GetExp(n)->GetTracePhysVals(
1866 e, elmtToTrace[n][e], jac, auxArray1 = jacEdge);
1870 if (fields[0]->GetExp(n)->GetTraceOrient(e) ==
1878 for (j = 0; j < nEdgePts; j++)
1880 fluxJumps[j] = fluxJumps[j] * jacEdge[j];
1888 Vmath::Smul(nEdgePts, jac[0], fluxJumps, 1, fluxJumps, 1);
1897 for (i = 0; i < nquad0; ++i)
1902 for (j = 0; j < nquad1; ++j)
1904 cnt = i + j * nquad0;
1905 divCFluxE0[cnt] = fluxJumps[i] *
m_dGL_xi2[n][j];
1910 for (i = 0; i < nquad1; ++i)
1915 for (j = 0; j < nquad0; ++j)
1917 cnt = (nquad0)*i + j;
1918 divCFluxE1[cnt] = fluxJumps[i] *
m_dGR_xi1[n][j];
1923 for (i = 0; i < nquad0; ++i)
1928 for (j = 0; j < nquad1; ++j)
1930 cnt = j * nquad0 + i;
1931 divCFluxE2[cnt] = fluxJumps[i] *
m_dGR_xi2[n][j];
1936 for (i = 0; i < nquad1; ++i)
1940 for (j = 0; j < nquad0; ++j)
1942 cnt = j + i * nquad0;
1943 divCFluxE3[cnt] = fluxJumps[i] *
m_dGL_xi1[n][j];
1949 ASSERTL0(
false,
"edge value (< 3) is out of range");
1961 Vmath::Vadd(nLocalSolutionPts, &divCFluxE1[0], 1, &divCFluxE3[0], 1,
1962 &derCFlux[phys_offset], 1);
1964 else if (direction == 1)
1966 Vmath::Vadd(nLocalSolutionPts, &divCFluxE0[0], 1, &divCFluxE2[0], 1,
1967 &derCFlux[phys_offset], 1);
1986 const int nConvectiveFields,
1993 boost::ignore_unused(nConvectiveFields);
1995 int n, e, i, j, cnt;
1997 int nElements = fields[0]->GetExpSize();
1998 int nLocalSolutionPts;
2009 fields[0]->GetTraceMap()->GetElmtToTrace();
2012 for (n = 0; n < nElements; ++n)
2015 phys_offset = fields[0]->GetPhys_Offset(n);
2016 nLocalSolutionPts = fields[0]->GetExp(n)->GetTotPoints();
2018 base = fields[0]->GetExp(n)->GetBase();
2019 nquad0 = base[0]->GetNumPoints();
2020 nquad1 = base[1]->GetNumPoints();
2028 for (e = 0; e < fields[0]->GetExp(n)->GetNtraces(); ++e)
2031 nEdgePts = fields[0]->GetExp(n)->GetTraceNumPoints(e);
2040 trace_offset = fields[0]->GetTrace()->GetPhys_Offset(
2041 elmtToTrace[n][e]->GetElmtId());
2045 fields[0]->GetExp(n)->GetTraceNormal(e);
2049 fields[0]->GetExp(n)->GetTracePhysVals(e, elmtToTrace[n][e],
2050 fluxX1 + phys_offset,
2051 auxArray1 = tmparrayX1);
2055 fields[0]->GetExp(n)->GetTracePhysVals(e, elmtToTrace[n][e],
2056 fluxX2 + phys_offset,
2057 auxArray1 = tmparrayX2);
2060 for (i = 0; i < nEdgePts; ++i)
2067 Vmath::Vsub(nEdgePts, &numericalFlux[trace_offset], 1, &fluxN[0], 1,
2071 if (fields[0]->GetExp(n)->GetTraceOrient(e) ==
2075 auxArray2 = fluxJumps, 1);
2078 for (i = 0; i < nEdgePts; ++i)
2083 fluxJumps[i] = -fluxJumps[i];
2091 for (i = 0; i < nquad0; ++i)
2094 fluxJumps[i] = -(
m_Q2D_e0[n][i]) * fluxJumps[i];
2096 for (j = 0; j < nquad1; ++j)
2098 cnt = i + j * nquad0;
2099 divCFluxE0[cnt] = fluxJumps[i] *
m_dGL_xi2[n][j];
2104 for (i = 0; i < nquad1; ++i)
2107 fluxJumps[i] = (
m_Q2D_e1[n][i]) * fluxJumps[i];
2109 for (j = 0; j < nquad0; ++j)
2111 cnt = (nquad0)*i + j;
2112 divCFluxE1[cnt] = fluxJumps[i] *
m_dGR_xi1[n][j];
2117 for (i = 0; i < nquad0; ++i)
2120 fluxJumps[i] = (
m_Q2D_e2[n][i]) * fluxJumps[i];
2122 for (j = 0; j < nquad1; ++j)
2124 cnt = j * nquad0 + i;
2125 divCFluxE2[cnt] = fluxJumps[i] *
m_dGR_xi2[n][j];
2130 for (i = 0; i < nquad1; ++i)
2133 fluxJumps[i] = -(
m_Q2D_e3[n][i]) * fluxJumps[i];
2134 for (j = 0; j < nquad0; ++j)
2136 cnt = j + i * nquad0;
2137 divCFluxE3[cnt] = fluxJumps[i] *
m_dGL_xi1[n][j];
2143 ASSERTL0(
false,
"edge value (< 3) is out of range");
2149 Vmath::Vadd(nLocalSolutionPts, &divCFluxE0[0], 1, &divCFluxE1[0], 1,
2150 &divCFlux[phys_offset], 1);
2152 Vmath::Vadd(nLocalSolutionPts, &divCFlux[phys_offset], 1,
2153 &divCFluxE2[0], 1, &divCFlux[phys_offset], 1);
2155 Vmath::Vadd(nLocalSolutionPts, &divCFlux[phys_offset], 1,
2156 &divCFluxE3[0], 1, &divCFlux[phys_offset], 1);
2175 const int nConvectiveFields,
2182 boost::ignore_unused(nConvectiveFields);
2184 int n, e, i, j, cnt;
2186 int nElements = fields[0]->GetExpSize();
2187 int nLocalSolutionPts;
2198 fields[0]->GetTraceMap()->GetElmtToTrace();
2201 for (n = 0; n < nElements; ++n)
2204 phys_offset = fields[0]->GetPhys_Offset(n);
2205 nLocalSolutionPts = fields[0]->GetExp(n)->GetTotPoints();
2207 base = fields[0]->GetExp(n)->GetBase();
2208 nquad0 = base[0]->GetNumPoints();
2209 nquad1 = base[1]->GetNumPoints();
2217 for (e = 0; e < fields[0]->GetExp(n)->GetNtraces(); ++e)
2220 nEdgePts = fields[0]->GetExp(n)->GetTraceNumPoints(e);
2229 trace_offset = fields[0]->GetTrace()->GetPhys_Offset(
2230 elmtToTrace[n][e]->GetElmtId());
2234 fields[0]->GetExp(n)->GetTraceNormal(e);
2243 fields[0]->GetExp(n)->GetTracePhysVals(e, elmtToTrace[n][e],
2244 fluxX2 + phys_offset,
2245 auxArray1 = fluxN_D);
2250 Vmath::Vcopy(nEdgePts, &numericalFlux[trace_offset], 1,
2254 if (fields[0]->GetExp(n)->GetTraceOrient(e) ==
2258 auxArray2 = fluxN, 1);
2261 auxArray2 = fluxN_D, 1);
2265 for (i = 0; i < nquad0; ++i)
2268 fluxN_R[i] = (
m_Q2D_e0[n][i]) * fluxN[i];
2271 for (i = 0; i < nEdgePts; ++i)
2278 fluxN_R[i] = -fluxN_R[i];
2284 Vmath::Vsub(nEdgePts, &fluxN_R[0], 1, &fluxN_D[0], 1,
2289 for (i = 0; i < nquad0; ++i)
2291 for (j = 0; j < nquad1; ++j)
2293 cnt = i + j * nquad0;
2294 divCFluxE0[cnt] = -fluxJumps[i] *
m_dGL_xi2[n][j];
2302 fields[0]->GetExp(n)->GetTracePhysVals(e, elmtToTrace[n][e],
2303 fluxX1 + phys_offset,
2304 auxArray1 = fluxN_D);
2307 Vmath::Vcopy(nEdgePts, &numericalFlux[trace_offset], 1,
2311 if (fields[0]->GetExp(n)->GetTraceOrient(e) ==
2315 auxArray2 = fluxN, 1);
2318 auxArray2 = fluxN_D, 1);
2322 for (i = 0; i < nquad1; ++i)
2325 fluxN_R[i] = (
m_Q2D_e1[n][i]) * fluxN[i];
2328 for (i = 0; i < nEdgePts; ++i)
2335 fluxN_R[i] = -fluxN_R[i];
2341 Vmath::Vsub(nEdgePts, &fluxN_R[0], 1, &fluxN_D[0], 1,
2346 for (i = 0; i < nquad1; ++i)
2348 for (j = 0; j < nquad0; ++j)
2350 cnt = (nquad0)*i + j;
2351 divCFluxE1[cnt] = fluxJumps[i] *
m_dGR_xi1[n][j];
2361 fields[0]->GetExp(n)->GetTracePhysVals(e, elmtToTrace[n][e],
2362 fluxX2 + phys_offset,
2363 auxArray1 = fluxN_D);
2366 Vmath::Vcopy(nEdgePts, &numericalFlux[trace_offset], 1,
2370 if (fields[0]->GetExp(n)->GetTraceOrient(e) ==
2374 auxArray2 = fluxN, 1);
2377 auxArray2 = fluxN_D, 1);
2381 for (i = 0; i < nquad0; ++i)
2384 fluxN_R[i] = (
m_Q2D_e2[n][i]) * fluxN[i];
2387 for (i = 0; i < nEdgePts; ++i)
2394 fluxN_R[i] = -fluxN_R[i];
2401 Vmath::Vsub(nEdgePts, &fluxN_R[0], 1, &fluxN_D[0], 1,
2406 for (i = 0; i < nquad0; ++i)
2408 for (j = 0; j < nquad1; ++j)
2410 cnt = j * nquad0 + i;
2411 divCFluxE2[cnt] = fluxJumps[i] *
m_dGR_xi2[n][j];
2420 fields[0]->GetExp(n)->GetTracePhysVals(e, elmtToTrace[n][e],
2421 fluxX1 + phys_offset,
2422 auxArray1 = fluxN_D);
2426 Vmath::Vcopy(nEdgePts, &numericalFlux[trace_offset], 1,
2430 if (fields[0]->GetExp(n)->GetTraceOrient(e) ==
2434 auxArray2 = fluxN, 1);
2437 auxArray2 = fluxN_D, 1);
2441 for (i = 0; i < nquad1; ++i)
2444 fluxN_R[i] = (
m_Q2D_e3[n][i]) * fluxN[i];
2447 for (i = 0; i < nEdgePts; ++i)
2454 fluxN_R[i] = -fluxN_R[i];
2461 Vmath::Vsub(nEdgePts, &fluxN_R[0], 1, &fluxN_D[0], 1,
2466 for (i = 0; i < nquad1; ++i)
2468 for (j = 0; j < nquad0; ++j)
2470 cnt = j + i * nquad0;
2471 divCFluxE3[cnt] = -fluxJumps[i] *
m_dGL_xi1[n][j];
2476 ASSERTL0(
false,
"edge value (< 3) is out of range");
2482 Vmath::Vadd(nLocalSolutionPts, &divCFluxE0[0], 1, &divCFluxE1[0], 1,
2483 &divCFlux[phys_offset], 1);
2485 Vmath::Vadd(nLocalSolutionPts, &divCFlux[phys_offset], 1,
2486 &divCFluxE2[0], 1, &divCFlux[phys_offset], 1);
2488 Vmath::Vadd(nLocalSolutionPts, &divCFlux[phys_offset], 1,
2489 &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
DiffusionFluxVecCBNS m_fluxVectorNS
virtual void v_InitObject(LibUtilities::SessionReaderSharedPtr pSession, Array< OneD, MultiRegions::ExpListSharedPtr > pFields)
Initiliase DiffusionLFRNS objects and store them before starting the time-stepping.
virtual void v_WeakPenaltyO1(const Array< OneD, MultiRegions::ExpListSharedPtr > &fields, const Array< OneD, Array< OneD, NekDouble >> &inarray, Array< OneD, Array< OneD, NekDouble >> &penaltyfluxO1)
Imposes appropriate bcs for the 1st order derivatives.
virtual void v_NumericalFluxO2(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.
NekDouble m_thermalConductivity
static std::string type[]
Array< OneD, Array< OneD, NekDouble > > m_traceVel
virtual void v_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".
Array< OneD, Array< OneD, NekDouble > > m_divFD
Array< OneD, NekDouble > m_jac
virtual void v_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.
virtual void v_Diffuse(const std::size_t nConvective, 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)
Calculate FR Diffusion for the Navier-Stokes (NS) equations using an LDG interface flux.
Array< OneD, Array< OneD, NekDouble > > m_viscFlux
Array< OneD, Array< OneD, Array< OneD, NekDouble > > > m_tmp2
Array< OneD, Array< OneD, NekDouble > > m_Q2D_e1
Array< OneD, Array< OneD, Array< OneD, NekDouble > > > m_DFC2
virtual void v_NumericalFluxO1(const Array< OneD, MultiRegions::ExpListSharedPtr > &fields, const Array< OneD, Array< OneD, NekDouble >> &inarray, Array< OneD, Array< OneD, Array< OneD, NekDouble >>> &numericalFluxO1)
Builds the numerical flux for the 1st order derivatives.
Array< OneD, Array< OneD, NekDouble > > m_dGR_xi2
Array< OneD, Array< OneD, NekDouble > > m_divFC
Array< OneD, Array< OneD, Array< OneD, NekDouble > > > m_DFC1
Array< OneD, Array< OneD, NekDouble > > m_dGR_xi3
Array< OneD, Array< OneD, NekDouble > > m_gmat
Array< OneD, Array< OneD, NekDouble > > m_Q2D_e3
Array< OneD, Array< OneD, NekDouble > > m_traceNormals
Array< OneD, Array< OneD, NekDouble > > m_Q2D_e2
Array< OneD, Array< OneD, NekDouble > > m_dGL_xi2
virtual void v_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, Array< OneD, NekDouble > > > m_viscTensor
Array< OneD, Array< OneD, Array< OneD, NekDouble > > > m_tmp1
Array< OneD, Array< OneD, NekDouble > > m_dGL_xi3
Array< OneD, Array< OneD, NekDouble > > m_Q2D_e0
Array< OneD, Array< OneD, Array< OneD, NekDouble > > > m_IF1
Array< OneD, Array< OneD, Array< OneD, NekDouble > > > m_D1
DiffusionLFRNS(std::string diffType)
DiffusionLFRNS uses the Flux Reconstruction (FR) approach to compute the diffusion term....
LibUtilities::SessionReaderSharedPtr m_session
virtual void v_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...
Array< OneD, Array< OneD, NekDouble > > m_homoDerivs
virtual void v_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...
Array< OneD, Array< OneD, Array< OneD, NekDouble > > > m_BD1
virtual void v_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, NekDouble > > m_dGR_xi1
virtual void v_WeakPenaltyO2(const Array< OneD, MultiRegions::ExpListSharedPtr > &fields, const int var, const int dir, const Array< OneD, const NekDouble > &qfield, Array< OneD, NekDouble > &penaltyflux)
Imposes appropriate bcs for the 2nd order derivatives.
static DiffusionSharedPtr create(std::string diffType)
Array< OneD, Array< OneD, Array< OneD, NekDouble > > > m_DU1
Array< OneD, Array< OneD, Array< OneD, NekDouble > > > m_DD1
Array< OneD, Array< OneD, NekDouble > > m_dGL_xi1
std::string m_ViscosityType
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 Neg(int n, T *x, const int incx)
Negate x = -x.
void Vvtvp(int n, const T *w, const int incw, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
vvtvp (vector times vector plus vector): z = w*x + y
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 Zero(int n, T *x, const int incx)
Zero vector.
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.