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);
1101 DerCFlux_2D(nConvectiveFields, j, fields, inarray[i],
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() ==
1216 &outarray[i][0], 1);
1221 &outarray[i][0], 1);
1224 if (!(
Basis[0]->Collocation()))
1226 fields[i]->FwdTrans(outarray[i], outarrayCoeff[i]);
1227 fields[i]->BwdTrans(outarrayCoeff[i], outarray[i]);
1235 ASSERTL0(
false,
"3D FRDG case not implemented yet");
1251 int nTracePts = fields[0]->GetTrace()->GetTotPoints();
1252 int nScalars = inarray.size();
1253 int nDim = fields[0]->GetCoordim(0);
1259 for (i = 0; i < nDim; ++i)
1261 fields[0]->ExtractTracePhys(inarray[i],
m_traceVel[i]);
1271 for (i = 0; i < nScalars; ++i)
1276 fields[i]->GetFwdBwdTracePhys(inarray[i], Fwd[i], Bwd[i]);
1277 fields[0]->GetTrace()->Upwind(Vn, Fwd[i], Bwd[i], numflux[i]);
1281 if (fields[0]->GetBndCondExpansions().size())
1287 for (j = 0; j < nDim; ++j)
1289 for (i = 0; i < nScalars; ++i)
1291 Vmath::Vcopy(nTracePts, numflux[i], 1, numericalFluxO1[i][j], 1);
1309 int nBndEdgePts, nBndEdges, nBndRegions;
1311 int nTracePts = fields[0]->GetTrace()->GetTotPoints();
1312 int nScalars = inarray.size();
1322 for (i = 0; i < nScalars; ++i)
1327 fields[i]->ExtractTracePhys(inarray[i], uplus[i]);
1331 for (i = 0; i < nScalars - 1; ++i)
1336 nBndRegions = fields[i + 1]->GetBndCondExpansions().size();
1337 for (j = 0; j < nBndRegions; ++j)
1340 ->GetBndConditions()[j]
1346 nBndEdges = fields[i + 1]->GetBndCondExpansions()[j]->GetExpSize();
1347 for (e = 0; e < nBndEdges; ++e)
1349 nBndEdgePts = fields[i + 1]
1350 ->GetBndCondExpansions()[j]
1355 fields[i + 1]->GetBndCondExpansions()[j]->GetPhys_Offset(e);
1357 id2 = fields[0]->GetTrace()->GetPhys_Offset(
1358 fields[0]->GetTraceMap()->GetBndCondIDToGlobalTraceID(
1363 fields[i]->GetBndConditions()[j]->GetUserDefined(),
1366 fields[i]->GetBndConditions()[j]->GetUserDefined(),
1369 Vmath::Zero(nBndEdgePts, &scalarVariables[i][id2], 1);
1374 ->GetBndConditions()[j]
1375 ->GetBoundaryConditionType() ==
1380 ->GetBndCondExpansions()[j]
1381 ->UpdatePhys())[id1],
1384 ->GetBndCondExpansions()[j]
1385 ->UpdatePhys())[id1],
1386 1, &scalarVariables[i][id2], 1);
1391 ->GetBndConditions()[j]
1392 ->GetBoundaryConditionType() ==
1396 &penaltyfluxO1[i][id2], 1);
1400 else if ((fields[i]->GetBndConditions()[j])
1401 ->GetBoundaryConditionType() ==
1405 &penaltyfluxO1[i][id2], 1);
1409 Vmath::Vmul(nBndEdgePts, &scalarVariables[i][id2], 1,
1410 &scalarVariables[i][id2], 1, &tmp1[id2], 1);
1412 Vmath::Smul(nBndEdgePts, 0.5, &tmp1[id2], 1, &tmp1[id2], 1);
1414 Vmath::Vadd(nBndEdgePts, &tmp2[id2], 1, &tmp1[id2], 1,
1422 nBndRegions = fields[nScalars]->GetBndCondExpansions().size();
1423 for (j = 0; j < nBndRegions; ++j)
1425 nBndEdges = fields[nScalars]->GetBndCondExpansions()[j]->GetExpSize();
1427 if (fields[nScalars]
1428 ->GetBndConditions()[j]
1434 for (e = 0; e < nBndEdges; ++e)
1436 nBndEdgePts = fields[nScalars]
1437 ->GetBndCondExpansions()[j]
1442 fields[nScalars]->GetBndCondExpansions()[j]->GetPhys_Offset(e);
1444 id2 = fields[0]->GetTrace()->GetPhys_Offset(
1445 fields[0]->GetTraceMap()->GetBndCondIDToGlobalTraceID(cnt++));
1449 fields[i]->GetBndConditions()[j]->GetUserDefined(),
1453 &scalarVariables[nScalars - 1][id2], 1);
1458 ->GetBndConditions()[j]
1459 ->GetBoundaryConditionType() ==
1466 ->GetBndCondExpansions()[j]
1468 1, &(fields[0]->GetBndCondExpansions()[j]->GetPhys())[id1],
1469 1, &scalarVariables[nScalars - 1][id2], 1);
1472 Vmath::Vsub(nBndEdgePts, &scalarVariables[nScalars - 1][id2], 1,
1473 &tmp2[id2], 1, &scalarVariables[nScalars - 1][id2],
1478 &scalarVariables[nScalars - 1][id2], 1,
1479 &scalarVariables[nScalars - 1][id2], 1);
1483 if (fields[nScalars]
1484 ->GetBndConditions()[j]
1485 ->GetBoundaryConditionType() ==
1488 fields[nScalars]->GetBndConditions()[j]->GetUserDefined(),
1491 Vmath::Vcopy(nBndEdgePts, &scalarVariables[nScalars - 1][id2],
1492 1, &penaltyfluxO1[nScalars - 1][id2], 1);
1496 else if (((fields[nScalars]->GetBndConditions()[j])
1497 ->GetBoundaryConditionType() ==
1499 boost::iequals(fields[nScalars]
1500 ->GetBndConditions()[j]
1504 Vmath::Vcopy(nBndEdgePts, &uplus[nScalars - 1][id2], 1,
1505 &penaltyfluxO1[nScalars - 1][id2], 1);
1522 int nTracePts = fields[0]->GetTrace()->GetTotPoints();
1523 int nVariables = fields.size();
1524 int nDim = fields[0]->GetCoordim(0);
1535 for (i = 0; i < nDim; ++i)
1537 fields[0]->ExtractTracePhys(ufield[i],
m_traceVel[i]);
1545 for (i = 1; i < nVariables; ++i)
1548 for (j = 0; j < nDim; ++j)
1551 fields[i]->GetFwdBwdTracePhys(qfield[j][i], qFwd, qBwd);
1554 fields[i]->GetTrace()->Upwind(Vn, qBwd, qFwd, qfluxtemp);
1561 if (fields[0]->GetBndCondExpansions().size())
1567 Vmath::Vadd(nTracePts, qfluxtemp, 1, qflux[i], 1, qflux[i], 1);
1582 int nBndEdges, nBndEdgePts;
1586 int nTracePts = fields[0]->GetTrace()->GetTotPoints();
1587 int nBndRegions = fields[var]->GetBndCondExpansions().size();
1593 fields[var]->ExtractTracePhys(qfield, qtemp);
1596 for (i = 0; i < nBndRegions; ++i)
1599 nBndEdges = fields[var]->GetBndCondExpansions()[i]->GetExpSize();
1601 if (fields[var]->GetBndConditions()[i]->GetBoundaryConditionType() ==
1608 for (e = 0; e < nBndEdges; ++e)
1610 nBndEdgePts = fields[var]
1611 ->GetBndCondExpansions()[i]
1615 id2 = fields[0]->GetTrace()->GetPhys_Offset(
1616 fields[0]->GetTraceMap()->GetBndCondIDToGlobalTraceID(cnt++));
1621 ->GetBndConditions()[i]
1622 ->GetBoundaryConditionType() ==
1625 fields[var]->GetBndConditions()[i]->GetUserDefined(),
1629 &qtemp[id2], 1, &penaltyflux[id2], 1);
1633 else if ((fields[var]->GetBndConditions()[i])
1634 ->GetBoundaryConditionType() ==
1637 ASSERTL0(
false,
"Neumann bcs not implemented for LFRNS");
1639 else if (boost::iequals(
1640 fields[var]->GetBndConditions()[i]->GetUserDefined(),
1651 &qtemp[id2], 1, &penaltyflux[id2], 1);
1669 const int nConvectiveFields,
1674 boost::ignore_unused(nConvectiveFields);
1677 int nLocalSolutionPts, phys_offset;
1685 Basis = fields[0]->GetExp(0)->GetBasis(0);
1687 int nElements = fields[0]->GetExpSize();
1688 int nPts = fields[0]->GetTotPoints();
1699 fields[0]->GetTraceMap()->GetElmtToTrace();
1701 for (n = 0; n < nElements; ++n)
1703 nLocalSolutionPts = fields[0]->GetExp(n)->GetTotPoints();
1704 phys_offset = fields[0]->GetPhys_Offset(n);
1708 Vmath::Vcopy(nLocalSolutionPts, &flux[phys_offset], 1, &tmparrayX1[0],
1711 fields[0]->GetExp(n)->GetTracePhysVals(0, elmtToTrace[n][0], tmparrayX1,
1713 JumpL[n] = iFlux[n] - tmpFluxVertex[0];
1715 fields[0]->GetExp(n)->GetTracePhysVals(1, elmtToTrace[n][1], tmparrayX1,
1717 JumpR[n] = iFlux[n + 1] - tmpFluxVertex[0];
1720 for (n = 0; n < nElements; ++n)
1722 ptsKeys = fields[0]->GetExp(n)->GetPointsKeys();
1723 nLocalSolutionPts = fields[0]->GetExp(n)->GetTotPoints();
1724 phys_offset = fields[0]->GetPhys_Offset(n);
1732 JumpL[n] = JumpL[n] * jac[0];
1733 JumpR[n] = JumpR[n] * jac[0];
1744 Vmath::Vadd(nLocalSolutionPts, &DCL[0], 1, &DCR[0], 1,
1745 &derCFlux[phys_offset], 1);
1765 const int nConvectiveFields,
const int direction,
1770 boost::ignore_unused(nConvectiveFields);
1772 int n, e, i, j, cnt;
1776 int nElements = fields[0]->GetExpSize();
1777 int trace_offset, phys_offset;
1778 int nLocalSolutionPts;
1786 fields[0]->GetTraceMap()->GetElmtToTrace();
1789 for (n = 0; n < nElements; ++n)
1792 phys_offset = fields[0]->GetPhys_Offset(n);
1793 nLocalSolutionPts = fields[0]->GetExp(n)->GetTotPoints();
1794 ptsKeys = fields[0]->GetExp(n)->GetPointsKeys();
1803 base = fields[0]->GetExp(n)->GetBase();
1804 nquad0 = base[0]->GetNumPoints();
1805 nquad1 = base[1]->GetNumPoints();
1813 for (e = 0; e < fields[0]->GetExp(n)->GetNtraces(); ++e)
1816 nEdgePts = fields[0]->GetExp(n)->GetTraceNumPoints(e);
1822 trace_offset = fields[0]->GetTrace()->GetPhys_Offset(
1823 elmtToTrace[n][e]->GetElmtId());
1832 fields[0]->GetExp(n)->GetTracePhysVals(
1833 e, elmtToTrace[n][e], flux + phys_offset, auxArray1 = tmparray);
1843 Vmath::Vsub(nEdgePts, &iFlux[trace_offset], 1, &tmparray[0], 1,
1848 if (fields[0]->GetExp(n)->GetTraceOrient(e) ==
1857 ->as<LocalRegions::Expansion2D>()
1864 fields[0]->GetExp(n)->GetTracePhysVals(
1865 e, elmtToTrace[n][e], jac, auxArray1 = jacEdge);
1869 if (fields[0]->GetExp(n)->GetTraceOrient(e) ==
1877 for (j = 0; j < nEdgePts; j++)
1879 fluxJumps[j] = fluxJumps[j] * jacEdge[j];
1887 Vmath::Smul(nEdgePts, jac[0], fluxJumps, 1, fluxJumps, 1);
1896 for (i = 0; i < nquad0; ++i)
1901 for (j = 0; j < nquad1; ++j)
1903 cnt = i + j * nquad0;
1904 divCFluxE0[cnt] = fluxJumps[i] *
m_dGL_xi2[n][j];
1909 for (i = 0; i < nquad1; ++i)
1914 for (j = 0; j < nquad0; ++j)
1916 cnt = (nquad0)*i + j;
1917 divCFluxE1[cnt] = fluxJumps[i] *
m_dGR_xi1[n][j];
1922 for (i = 0; i < nquad0; ++i)
1927 for (j = 0; j < nquad1; ++j)
1929 cnt = j * nquad0 + i;
1930 divCFluxE2[cnt] = fluxJumps[i] *
m_dGR_xi2[n][j];
1935 for (i = 0; i < nquad1; ++i)
1939 for (j = 0; j < nquad0; ++j)
1941 cnt = j + i * nquad0;
1942 divCFluxE3[cnt] = fluxJumps[i] *
m_dGL_xi1[n][j];
1948 ASSERTL0(
false,
"edge value (< 3) is out of range");
1960 Vmath::Vadd(nLocalSolutionPts, &divCFluxE1[0], 1, &divCFluxE3[0], 1,
1961 &derCFlux[phys_offset], 1);
1963 else if (direction == 1)
1965 Vmath::Vadd(nLocalSolutionPts, &divCFluxE0[0], 1, &divCFluxE2[0], 1,
1966 &derCFlux[phys_offset], 1);
1985 const int nConvectiveFields,
1992 boost::ignore_unused(nConvectiveFields);
1994 int n, e, i, j, cnt;
1996 int nElements = fields[0]->GetExpSize();
1997 int nLocalSolutionPts;
2008 fields[0]->GetTraceMap()->GetElmtToTrace();
2011 for (n = 0; n < nElements; ++n)
2014 phys_offset = fields[0]->GetPhys_Offset(n);
2015 nLocalSolutionPts = fields[0]->GetExp(n)->GetTotPoints();
2017 base = fields[0]->GetExp(n)->GetBase();
2018 nquad0 = base[0]->GetNumPoints();
2019 nquad1 = base[1]->GetNumPoints();
2027 for (e = 0; e < fields[0]->GetExp(n)->GetNtraces(); ++e)
2030 nEdgePts = fields[0]->GetExp(n)->GetTraceNumPoints(e);
2039 trace_offset = fields[0]->GetTrace()->GetPhys_Offset(
2040 elmtToTrace[n][e]->GetElmtId());
2044 fields[0]->GetExp(n)->GetTraceNormal(e);
2048 fields[0]->GetExp(n)->GetTracePhysVals(e, elmtToTrace[n][e],
2049 fluxX1 + phys_offset,
2050 auxArray1 = tmparrayX1);
2054 fields[0]->GetExp(n)->GetTracePhysVals(e, elmtToTrace[n][e],
2055 fluxX2 + phys_offset,
2056 auxArray1 = tmparrayX2);
2059 for (i = 0; i < nEdgePts; ++i)
2066 Vmath::Vsub(nEdgePts, &numericalFlux[trace_offset], 1, &fluxN[0], 1,
2070 if (fields[0]->GetExp(n)->GetTraceOrient(e) ==
2074 auxArray2 = fluxJumps, 1);
2077 for (i = 0; i < nEdgePts; ++i)
2082 fluxJumps[i] = -fluxJumps[i];
2090 for (i = 0; i < nquad0; ++i)
2093 fluxJumps[i] = -(
m_Q2D_e0[n][i]) * fluxJumps[i];
2095 for (j = 0; j < nquad1; ++j)
2097 cnt = i + j * nquad0;
2098 divCFluxE0[cnt] = fluxJumps[i] *
m_dGL_xi2[n][j];
2103 for (i = 0; i < nquad1; ++i)
2106 fluxJumps[i] = (
m_Q2D_e1[n][i]) * fluxJumps[i];
2108 for (j = 0; j < nquad0; ++j)
2110 cnt = (nquad0)*i + j;
2111 divCFluxE1[cnt] = fluxJumps[i] *
m_dGR_xi1[n][j];
2116 for (i = 0; i < nquad0; ++i)
2119 fluxJumps[i] = (
m_Q2D_e2[n][i]) * fluxJumps[i];
2121 for (j = 0; j < nquad1; ++j)
2123 cnt = j * nquad0 + i;
2124 divCFluxE2[cnt] = fluxJumps[i] *
m_dGR_xi2[n][j];
2129 for (i = 0; i < nquad1; ++i)
2132 fluxJumps[i] = -(
m_Q2D_e3[n][i]) * fluxJumps[i];
2133 for (j = 0; j < nquad0; ++j)
2135 cnt = j + i * nquad0;
2136 divCFluxE3[cnt] = fluxJumps[i] *
m_dGL_xi1[n][j];
2142 ASSERTL0(
false,
"edge value (< 3) is out of range");
2148 Vmath::Vadd(nLocalSolutionPts, &divCFluxE0[0], 1, &divCFluxE1[0], 1,
2149 &divCFlux[phys_offset], 1);
2151 Vmath::Vadd(nLocalSolutionPts, &divCFlux[phys_offset], 1,
2152 &divCFluxE2[0], 1, &divCFlux[phys_offset], 1);
2154 Vmath::Vadd(nLocalSolutionPts, &divCFlux[phys_offset], 1,
2155 &divCFluxE3[0], 1, &divCFlux[phys_offset], 1);
2174 const int nConvectiveFields,
2181 boost::ignore_unused(nConvectiveFields);
2183 int n, e, i, j, cnt;
2185 int nElements = fields[0]->GetExpSize();
2186 int nLocalSolutionPts;
2197 fields[0]->GetTraceMap()->GetElmtToTrace();
2200 for (n = 0; n < nElements; ++n)
2203 phys_offset = fields[0]->GetPhys_Offset(n);
2204 nLocalSolutionPts = fields[0]->GetExp(n)->GetTotPoints();
2206 base = fields[0]->GetExp(n)->GetBase();
2207 nquad0 = base[0]->GetNumPoints();
2208 nquad1 = base[1]->GetNumPoints();
2216 for (e = 0; e < fields[0]->GetExp(n)->GetNtraces(); ++e)
2219 nEdgePts = fields[0]->GetExp(n)->GetTraceNumPoints(e);
2228 trace_offset = fields[0]->GetTrace()->GetPhys_Offset(
2229 elmtToTrace[n][e]->GetElmtId());
2233 fields[0]->GetExp(n)->GetTraceNormal(e);
2242 fields[0]->GetExp(n)->GetTracePhysVals(e, elmtToTrace[n][e],
2243 fluxX2 + phys_offset,
2244 auxArray1 = fluxN_D);
2249 Vmath::Vcopy(nEdgePts, &numericalFlux[trace_offset], 1,
2253 if (fields[0]->GetExp(n)->GetTraceOrient(e) ==
2257 auxArray2 = fluxN, 1);
2260 auxArray2 = fluxN_D, 1);
2264 for (i = 0; i < nquad0; ++i)
2267 fluxN_R[i] = (
m_Q2D_e0[n][i]) * fluxN[i];
2270 for (i = 0; i < nEdgePts; ++i)
2277 fluxN_R[i] = -fluxN_R[i];
2283 Vmath::Vsub(nEdgePts, &fluxN_R[0], 1, &fluxN_D[0], 1,
2288 for (i = 0; i < nquad0; ++i)
2290 for (j = 0; j < nquad1; ++j)
2292 cnt = i + j * nquad0;
2293 divCFluxE0[cnt] = -fluxJumps[i] *
m_dGL_xi2[n][j];
2301 fields[0]->GetExp(n)->GetTracePhysVals(e, elmtToTrace[n][e],
2302 fluxX1 + phys_offset,
2303 auxArray1 = fluxN_D);
2306 Vmath::Vcopy(nEdgePts, &numericalFlux[trace_offset], 1,
2310 if (fields[0]->GetExp(n)->GetTraceOrient(e) ==
2314 auxArray2 = fluxN, 1);
2317 auxArray2 = fluxN_D, 1);
2321 for (i = 0; i < nquad1; ++i)
2324 fluxN_R[i] = (
m_Q2D_e1[n][i]) * fluxN[i];
2327 for (i = 0; i < nEdgePts; ++i)
2334 fluxN_R[i] = -fluxN_R[i];
2340 Vmath::Vsub(nEdgePts, &fluxN_R[0], 1, &fluxN_D[0], 1,
2345 for (i = 0; i < nquad1; ++i)
2347 for (j = 0; j < nquad0; ++j)
2349 cnt = (nquad0)*i + j;
2350 divCFluxE1[cnt] = fluxJumps[i] *
m_dGR_xi1[n][j];
2360 fields[0]->GetExp(n)->GetTracePhysVals(e, elmtToTrace[n][e],
2361 fluxX2 + phys_offset,
2362 auxArray1 = fluxN_D);
2365 Vmath::Vcopy(nEdgePts, &numericalFlux[trace_offset], 1,
2369 if (fields[0]->GetExp(n)->GetTraceOrient(e) ==
2373 auxArray2 = fluxN, 1);
2376 auxArray2 = fluxN_D, 1);
2380 for (i = 0; i < nquad0; ++i)
2383 fluxN_R[i] = (
m_Q2D_e2[n][i]) * fluxN[i];
2386 for (i = 0; i < nEdgePts; ++i)
2393 fluxN_R[i] = -fluxN_R[i];
2400 Vmath::Vsub(nEdgePts, &fluxN_R[0], 1, &fluxN_D[0], 1,
2405 for (i = 0; i < nquad0; ++i)
2407 for (j = 0; j < nquad1; ++j)
2409 cnt = j * nquad0 + i;
2410 divCFluxE2[cnt] = fluxJumps[i] *
m_dGR_xi2[n][j];
2419 fields[0]->GetExp(n)->GetTracePhysVals(e, elmtToTrace[n][e],
2420 fluxX1 + phys_offset,
2421 auxArray1 = fluxN_D);
2425 Vmath::Vcopy(nEdgePts, &numericalFlux[trace_offset], 1,
2429 if (fields[0]->GetExp(n)->GetTraceOrient(e) ==
2433 auxArray2 = fluxN, 1);
2436 auxArray2 = fluxN_D, 1);
2440 for (i = 0; i < nquad1; ++i)
2443 fluxN_R[i] = (
m_Q2D_e3[n][i]) * fluxN[i];
2446 for (i = 0; i < nEdgePts; ++i)
2453 fluxN_R[i] = -fluxN_R[i];
2460 Vmath::Vsub(nEdgePts, &fluxN_R[0], 1, &fluxN_D[0], 1,
2465 for (i = 0; i < nquad1; ++i)
2467 for (j = 0; j < nquad0; ++j)
2469 cnt = j + i * nquad0;
2470 divCFluxE3[cnt] = -fluxJumps[i] *
m_dGL_xi1[n][j];
2475 ASSERTL0(
false,
"edge value (< 3) is out of range");
2481 Vmath::Vadd(nLocalSolutionPts, &divCFluxE0[0], 1, &divCFluxE1[0], 1,
2482 &divCFlux[phys_offset], 1);
2484 Vmath::Vadd(nLocalSolutionPts, &divCFlux[phys_offset], 1,
2485 &divCFluxE2[0], 1, &divCFlux[phys_offset], 1);
2487 Vmath::Vadd(nLocalSolutionPts, &divCFlux[phys_offset], 1,
2488 &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
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...
NekDouble m_thermalConductivity
static std::string type[]
Array< OneD, Array< OneD, NekDouble > > m_traceVel
Array< OneD, Array< OneD, NekDouble > > m_divFD
Array< OneD, NekDouble > m_jac
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) override
Calculate FR Diffusion for the Navier-Stokes (NS) equations using an LDG interface flux.
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, 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
void 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.
Array< OneD, Array< OneD, NekDouble > > m_dGR_xi2
void 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.
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
Array< OneD, Array< OneD, Array< OneD, NekDouble > > > m_viscTensor
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...
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
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.
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.
Array< OneD, Array< OneD, Array< OneD, NekDouble > > > m_IF1
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".
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
Array< OneD, Array< OneD, NekDouble > > m_homoDerivs
Array< OneD, Array< OneD, Array< OneD, NekDouble > > > m_BD1
Array< OneD, Array< OneD, NekDouble > > m_dGR_xi1
static DiffusionSharedPtr create(std::string diffType)
Array< OneD, Array< OneD, Array< OneD, NekDouble > > > m_DU1
Array< OneD, Array< OneD, Array< OneD, NekDouble > > > m_DD1
void 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.
void 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.
virtual void v_InitObject(LibUtilities::SessionReaderSharedPtr pSession, Array< OneD, MultiRegions::ExpListSharedPtr > pFields) override
Initiliase DiffusionLFRNS objects and store them before starting the time-stepping.
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.