41 #include <boost/math/special_functions/gamma.hpp>
51 std::string DiffusionLFR::type[] = {
53 "LFRDG", DiffusionLFR::create),
55 "LFRSD", DiffusionLFR::create),
57 "LFRHU", DiffusionLFR::create),
59 "LFRcmin", DiffusionLFR::create),
61 "LFRcinf", DiffusionLFR::create)};
71 DiffusionLFR::DiffusionLFR(std::string diffType):m_diffType(diffType)
95 int nConvectiveFields = pFields.num_elements();
96 int nDim = pFields[0]->GetCoordim(0);
97 int nSolutionPts = pFields[0]->GetTotPoints();
98 int nTracePts = pFields[0]->GetTrace()->GetTotPoints();
125 for (i = 0; i < nConvectiveFields; ++i)
141 for (j = 0; j < nDim; ++j)
181 int nLocalSolutionPts;
182 int nElements = pFields[0]->GetExpSize();
183 int nDimensions = pFields[0]->GetCoordim(0);
184 int nSolutionPts = pFields[0]->GetTotPoints();
185 int nTracePts = pFields[0]->GetTrace()->GetTotPoints();
188 for (i = 0; i < nDimensions; ++i)
207 for (n = 0; n < nElements; ++n)
209 ptsKeys = pFields[0]->GetExp(n)->GetPointsKeys();
210 nLocalSolutionPts = pFields[0]->GetExp(n)->GetTotPoints();
211 phys_offset = pFields[0]->GetPhys_Offset(n);
212 jac = pFields[0]->GetExp(n)
215 for (i = 0; i < nLocalSolutionPts; ++i)
217 m_jac[i+phys_offset] = jac[0];
235 for (n = 0; n < nElements; ++n)
237 base = pFields[0]->GetExp(n)->GetBase();
238 nquad0 = base[0]->GetNumPoints();
239 nquad1 = base[1]->GetNumPoints();
247 pFields[0]->GetExp(n)->GetEdgeQFactors(
248 0, auxArray1 = m_Q2D_e0[n]);
249 pFields[0]->GetExp(n)->GetEdgeQFactors(
250 1, auxArray1 = m_Q2D_e1[n]);
251 pFields[0]->GetExp(n)->GetEdgeQFactors(
252 2, auxArray1 = m_Q2D_e2[n]);
253 pFields[0]->GetExp(n)->GetEdgeQFactors(
254 3, auxArray1 = m_Q2D_e3[n]);
256 ptsKeys = pFields[0]->GetExp(n)->GetPointsKeys();
257 nLocalSolutionPts = pFields[0]->GetExp(n)->GetTotPoints();
258 phys_offset = pFields[0]->GetPhys_Offset(n);
260 jac = pFields[0]->GetExp(n)
263 gmat = pFields[0]->GetExp(n)
267 if (pFields[0]->GetExp(n)
268 ->as<LocalRegions::Expansion2D>()->GetGeom2D()
269 ->GetMetricInfo()->GetGtype()
272 for (i = 0; i < nLocalSolutionPts; ++i)
274 m_jac[i+phys_offset] = jac[i];
275 m_gmat[0][i+phys_offset] = gmat[0][i];
276 m_gmat[1][i+phys_offset] = gmat[1][i];
277 m_gmat[2][i+phys_offset] = gmat[2][i];
278 m_gmat[3][i+phys_offset] = gmat[3][i];
283 for (i = 0; i < nLocalSolutionPts; ++i)
285 m_jac[i+phys_offset] = jac[0];
286 m_gmat[0][i+phys_offset] = gmat[0][0];
287 m_gmat[1][i+phys_offset] = gmat[1][0];
288 m_gmat[2][i+phys_offset] = gmat[2][0];
289 m_gmat[3][i+phys_offset] = gmat[3][0];
297 ASSERTL0(
false,
"3DFR Metric terms not implemented yet");
302 ASSERTL0(
false,
"Expansion dimension not recognised");
332 int nquad0, nquad1, nquad2;
333 int nmodes0, nmodes1, nmodes2;
336 int nElements = pFields[0]->GetExpSize();
337 int nDim = pFields[0]->GetCoordim(0);
346 for (n = 0; n < nElements; ++n)
348 base = pFields[0]->GetExp(n)->GetBase();
349 nquad0 = base[0]->GetNumPoints();
350 nmodes0 = base[0]->GetNumModes();
354 base[0]->GetZW(z0, w0);
366 int p0 = nmodes0 - 1;
372 NekDouble ap0 = boost::math::tgamma(2 * p0 + 1)
374 * boost::math::tgamma(p0 + 1)
375 * boost::math::tgamma(p0 + 1));
384 c0 = 2.0 * p0 / ((2.0 * p0 + 1.0) * (p0 + 1.0)
385 * (ap0 * boost::math::tgamma(p0 + 1))
386 * (ap0 * boost::math::tgamma(p0 + 1)));
390 c0 = 2.0 * (p0 + 1.0) / ((2.0 * p0 + 1.0) * p0
391 * (ap0 * boost::math::tgamma(p0 + 1))
392 * (ap0 * boost::math::tgamma(p0 + 1)));
396 c0 = -2.0 / ((2.0 * p0 + 1.0)
397 * (ap0 * boost::math::tgamma(p0 + 1))
398 * (ap0 * boost::math::tgamma(p0 + 1)));
402 c0 = 10000000000000000.0;
405 NekDouble etap0 = 0.5 * c0 * (2.0 * p0 + 1.0)
406 * (ap0 * boost::math::tgamma(p0 + 1))
407 * (ap0 * boost::math::tgamma(p0 + 1));
409 NekDouble overeta0 = 1.0 / (1.0 + etap0);
420 for(i = 0; i < nquad0; ++i)
426 m_dGL_xi1[n][i] = 0.5 * sign0 * m_dGL_xi1[n][i];
430 for(i = 0; i < nquad0; ++i)
432 m_dGR_xi1[n][i] = etap0 * dLpm0[i];
433 m_dGR_xi1[n][i] += dLpp0[i];
434 m_dGR_xi1[n][i] *= overeta0;
435 m_dGR_xi1[n][i] += dLp0[i];
436 m_dGR_xi1[n][i] = 0.5 * m_dGR_xi1[n][i];
453 for (n = 0; n < nElements; ++n)
455 base = pFields[0]->GetExp(n)->GetBase();
456 nquad0 = base[0]->GetNumPoints();
457 nquad1 = base[1]->GetNumPoints();
458 nmodes0 = base[0]->GetNumModes();
459 nmodes1 = base[1]->GetNumModes();
466 base[0]->GetZW(z0, w0);
467 base[1]->GetZW(z1, w1);
484 int p0 = nmodes0 - 1;
485 int p1 = nmodes1 - 1;
492 NekDouble ap0 = boost::math::tgamma(2 * p0 + 1)
494 * boost::math::tgamma(p0 + 1)
495 * boost::math::tgamma(p0 + 1));
497 NekDouble ap1 = boost::math::tgamma(2 * p1 + 1)
499 * boost::math::tgamma(p1 + 1)
500 * boost::math::tgamma(p1 + 1));
510 c0 = 2.0 * p0 / ((2.0 * p0 + 1.0) * (p0 + 1.0)
511 * (ap0 * boost::math::tgamma(p0 + 1))
512 * (ap0 * boost::math::tgamma(p0 + 1)));
514 c1 = 2.0 * p1 / ((2.0 * p1 + 1.0) * (p1 + 1.0)
515 * (ap1 * boost::math::tgamma(p1 + 1))
516 * (ap1 * boost::math::tgamma(p1 + 1)));
520 c0 = 2.0 * (p0 + 1.0) / ((2.0 * p0 + 1.0) * p0
521 * (ap0 * boost::math::tgamma(p0 + 1))
522 * (ap0 * boost::math::tgamma(p0 + 1)));
524 c1 = 2.0 * (p1 + 1.0) / ((2.0 * p1 + 1.0) * p1
525 * (ap1 * boost::math::tgamma(p1 + 1))
526 * (ap1 * boost::math::tgamma(p1 + 1)));
530 c0 = -2.0 / ((2.0 * p0 + 1.0)
531 * (ap0 * boost::math::tgamma(p0 + 1))
532 * (ap0 * boost::math::tgamma(p0 + 1)));
534 c1 = -2.0 / ((2.0 * p1 + 1.0)
535 * (ap1 * boost::math::tgamma(p1 + 1))
536 * (ap1 * boost::math::tgamma(p1 + 1)));
540 c0 = 10000000000000000.0;
541 c1 = 10000000000000000.0;
544 NekDouble etap0 = 0.5 * c0 * (2.0 * p0 + 1.0)
545 * (ap0 * boost::math::tgamma(p0 + 1))
546 * (ap0 * boost::math::tgamma(p0 + 1));
548 NekDouble etap1 = 0.5 * c1 * (2.0 * p1 + 1.0)
549 * (ap1 * boost::math::tgamma(p1 + 1))
550 * (ap1 * boost::math::tgamma(p1 + 1));
552 NekDouble overeta0 = 1.0 / (1.0 + etap0);
553 NekDouble overeta1 = 1.0 / (1.0 + etap1);
568 for(i = 0; i < nquad0; ++i)
574 m_dGL_xi1[n][i] = 0.5 * sign0 * m_dGL_xi1[n][i];
578 for(i = 0; i < nquad1; ++i)
580 m_dGL_xi2[n][i] = etap1 * dLpm1[i];
581 m_dGL_xi2[n][i] += dLpp1[i];
582 m_dGL_xi2[n][i] *= overeta1;
583 m_dGL_xi2[n][i] = dLp1[i] - m_dGL_xi2[n][i];
584 m_dGL_xi2[n][i] = 0.5 * sign1 * m_dGL_xi2[n][i];
588 for(i = 0; i < nquad0; ++i)
590 m_dGR_xi1[n][i] = etap0 * dLpm0[i];
591 m_dGR_xi1[n][i] += dLpp0[i];
592 m_dGR_xi1[n][i] *= overeta0;
593 m_dGR_xi1[n][i] += dLp0[i];
594 m_dGR_xi1[n][i] = 0.5 * m_dGR_xi1[n][i];
598 for(i = 0; i < nquad1; ++i)
600 m_dGR_xi2[n][i] = etap1 * dLpm1[i];
601 m_dGR_xi2[n][i] += dLpp1[i];
602 m_dGR_xi2[n][i] *= overeta1;
603 m_dGR_xi2[n][i] += dLp1[i];
604 m_dGR_xi2[n][i] = 0.5 * m_dGR_xi2[n][i];
618 for (n = 0; n < nElements; ++n)
620 base = pFields[0]->GetExp(n)->GetBase();
621 nquad0 = base[0]->GetNumPoints();
622 nquad1 = base[1]->GetNumPoints();
623 nquad2 = base[2]->GetNumPoints();
624 nmodes0 = base[0]->GetNumModes();
625 nmodes1 = base[1]->GetNumModes();
626 nmodes2 = base[2]->GetNumModes();
635 base[0]->GetZW(z0, w0);
636 base[1]->GetZW(z1, w1);
637 base[1]->GetZW(z2, w2);
659 int p0 = nmodes0 - 1;
660 int p1 = nmodes1 - 1;
661 int p2 = nmodes2 - 1;
669 NekDouble ap0 = boost::math::tgamma(2 * p0 + 1)
671 * boost::math::tgamma(p0 + 1)
672 * boost::math::tgamma(p0 + 1));
675 NekDouble ap1 = boost::math::tgamma(2 * p1 + 1)
677 * boost::math::tgamma(p1 + 1)
678 * boost::math::tgamma(p1 + 1));
681 NekDouble ap2 = boost::math::tgamma(2 * p2 + 1)
683 * boost::math::tgamma(p2 + 1)
684 * boost::math::tgamma(p2 + 1));
695 c0 = 2.0 * p0 / ((2.0 * p0 + 1.0) * (p0 + 1.0)
696 * (ap0 * boost::math::tgamma(p0 + 1))
697 * (ap0 * boost::math::tgamma(p0 + 1)));
699 c1 = 2.0 * p1 / ((2.0 * p1 + 1.0) * (p1 + 1.0)
700 * (ap1 * boost::math::tgamma(p1 + 1))
701 * (ap1 * boost::math::tgamma(p1 + 1)));
703 c2 = 2.0 * p2 / ((2.0 * p2 + 1.0) * (p2 + 1.0)
704 * (ap2 * boost::math::tgamma(p2 + 1))
705 * (ap2 * boost::math::tgamma(p2 + 1)));
709 c0 = 2.0 * (p0 + 1.0) / ((2.0 * p0 + 1.0) * p0
710 * (ap0 * boost::math::tgamma(p0 + 1))
711 * (ap0 * boost::math::tgamma(p0 + 1)));
713 c1 = 2.0 * (p1 + 1.0) / ((2.0 * p1 + 1.0) * p1
714 * (ap1 * boost::math::tgamma(p1 + 1))
715 * (ap1 * boost::math::tgamma(p1 + 1)));
717 c2 = 2.0 * (p2 + 1.0) / ((2.0 * p2 + 1.0) * p2
718 * (ap2 * boost::math::tgamma(p2 + 1))
719 * (ap2 * boost::math::tgamma(p2 + 1)));
723 c0 = -2.0 / ((2.0 * p0 + 1.0)
724 * (ap0 * boost::math::tgamma(p0 + 1))
725 * (ap0 * boost::math::tgamma(p0 + 1)));
727 c1 = -2.0 / ((2.0 * p1 + 1.0)
728 * (ap1 * boost::math::tgamma(p1 + 1))
729 * (ap1 * boost::math::tgamma(p1 + 1)));
731 c2 = -2.0 / ((2.0 * p2 + 1.0)
732 * (ap2 * boost::math::tgamma(p2 + 1))
733 * (ap2 * boost::math::tgamma(p2 + 1)));
737 c0 = 10000000000000000.0;
738 c1 = 10000000000000000.0;
739 c2 = 10000000000000000.0;
742 NekDouble etap0 = 0.5 * c0 * (2.0 * p0 + 1.0)
743 * (ap0 * boost::math::tgamma(p0 + 1))
744 * (ap0 * boost::math::tgamma(p0 + 1));
746 NekDouble etap1 = 0.5 * c1 * (2.0 * p1 + 1.0)
747 * (ap1 * boost::math::tgamma(p1 + 1))
748 * (ap1 * boost::math::tgamma(p1 + 1));
750 NekDouble etap2 = 0.5 * c2 * (2.0 * p2 + 1.0)
751 * (ap2 * boost::math::tgamma(p2 + 1))
752 * (ap2 * boost::math::tgamma(p2 + 1));
754 NekDouble overeta0 = 1.0 / (1.0 + etap0);
755 NekDouble overeta1 = 1.0 / (1.0 + etap1);
756 NekDouble overeta2 = 1.0 / (1.0 + etap2);
775 for(i = 0; i < nquad0; ++i)
781 m_dGL_xi1[n][i] = 0.5 * sign0 * m_dGL_xi1[n][i];
785 for(i = 0; i < nquad1; ++i)
787 m_dGL_xi2[n][i] = etap1 * dLpm1[i];
788 m_dGL_xi2[n][i] += dLpp1[i];
789 m_dGL_xi2[n][i] *= overeta1;
790 m_dGL_xi2[n][i] = dLp1[i] - m_dGL_xi2[n][i];
791 m_dGL_xi2[n][i] = 0.5 * sign1 * m_dGL_xi2[n][i];
795 for(i = 0; i < nquad2; ++i)
797 m_dGL_xi3[n][i] = etap2 * dLpm2[i];
798 m_dGL_xi3[n][i] += dLpp2[i];
799 m_dGL_xi3[n][i] *= overeta2;
800 m_dGL_xi3[n][i] = dLp2[i] - m_dGL_xi3[n][i];
801 m_dGL_xi3[n][i] = 0.5 * sign2 * m_dGL_xi3[n][i];
805 for(i = 0; i < nquad0; ++i)
807 m_dGR_xi1[n][i] = etap0 * dLpm0[i];
808 m_dGR_xi1[n][i] += dLpp0[i];
809 m_dGR_xi1[n][i] *= overeta0;
810 m_dGR_xi1[n][i] += dLp0[i];
811 m_dGR_xi1[n][i] = 0.5 * m_dGR_xi1[n][i];
815 for(i = 0; i < nquad1; ++i)
817 m_dGR_xi2[n][i] = etap1 * dLpm1[i];
818 m_dGR_xi2[n][i] += dLpp1[i];
819 m_dGR_xi2[n][i] *= overeta1;
820 m_dGR_xi2[n][i] += dLp1[i];
821 m_dGR_xi2[n][i] = 0.5 * m_dGR_xi2[n][i];
825 for(i = 0; i < nquad2; ++i)
827 m_dGR_xi3[n][i] = etap2 * dLpm2[i];
828 m_dGR_xi3[n][i] += dLpp2[i];
829 m_dGR_xi3[n][i] *= overeta2;
830 m_dGR_xi3[n][i] += dLp2[i];
831 m_dGR_xi3[n][i] = 0.5 * m_dGR_xi3[n][i];
838 ASSERTL0(
false,
"Expansion dimension not recognised");
850 const int nConvectiveFields,
862 Basis = fields[0]->GetExp(0)->GetBase();
864 int nElements = fields[0]->GetExpSize();
865 int nDim = fields[0]->GetCoordim(0);
866 int nSolutionPts = fields[0]->GetTotPoints();
867 int nCoeffs = fields[0]->GetNcoeffs();
870 for (i = 0; i < nConvectiveFields; ++i)
883 for (i = 0; i < nConvectiveFields; ++i)
887 for (n = 0; n < nElements; n++)
889 phys_offset = fields[0]->GetPhys_Offset(n);
891 fields[i]->GetExp(n)->PhysDeriv(0,
892 auxArray1 = inarray[i] + phys_offset,
893 auxArray2 =
m_DU1[i][0] + phys_offset);
919 for (i = 0; i < nConvectiveFields; ++i)
923 for (n = 0; n < nElements; n++)
925 phys_offset = fields[0]->GetPhys_Offset(n);
927 fields[i]->GetExp(n)->PhysDeriv(0,
928 auxArray1 =
m_D1[i][0] + phys_offset,
929 auxArray2 =
m_DD1[i][0] + phys_offset);
945 &
m_DD1[i][0][0], 1, &outarray[i][0], 1);
948 if (!(Basis[0]->Collocation()))
950 fields[i]->FwdTrans(outarray[i], outarrayCoeff[i]);
951 fields[i]->BwdTrans(outarrayCoeff[i], outarray[i]);
959 for(i = 0; i < nConvectiveFields; ++i)
961 for (j = 0; j < nDim; ++j)
970 &
m_gmat[0][0], 1, &u1_hat[0], 1);
973 &
m_jac[0], 1, &u1_hat[0], 1);
976 &
m_gmat[1][0], 1, &u2_hat[0], 1);
979 &
m_jac[0], 1, &u2_hat[0], 1);
984 &
m_gmat[2][0], 1, &u1_hat[0], 1);
987 &
m_jac[0], 1, &u1_hat[0], 1);
990 &
m_gmat[3][0], 1, &u2_hat[0], 1);
993 &
m_jac[0], 1, &u2_hat[0], 1);
996 for (n = 0; n < nElements; n++)
998 phys_offset = fields[0]->GetPhys_Offset(n);
1000 fields[i]->GetExp(n)->StdPhysDeriv(0,
1001 auxArray1 = u1_hat + phys_offset,
1002 auxArray2 =
m_tmp1[i][j] + phys_offset);
1004 fields[i]->GetExp(n)->StdPhysDeriv(1,
1005 auxArray1 = u2_hat + phys_offset,
1006 auxArray2 =
m_tmp2[i][j] + phys_offset);
1011 &
m_DU1[i][j][0], 1);
1020 inarray[i],
m_IF1[i][j],
1026 for (j = 0; j < nSolutionPts; ++j)
1049 for (j = 0; j < nSolutionPts; j++)
1058 m_gmat[0][j] * m_BD1[i][1][j] -
1059 m_gmat[1][j] * m_BD1[i][0][j];
1063 for (j = 0; j < nDim; ++j)
1077 for (i = 0; i < nConvectiveFields; ++i)
1082 for (j = 0; j < nSolutionPts; j++)
1091 for (n = 0; n < nElements; n++)
1093 phys_offset = fields[0]->GetPhys_Offset(n);
1095 fields[0]->GetExp(n)->StdPhysDeriv(0,
1096 auxArray1 = f_hat + phys_offset,
1097 auxArray2 =
m_DD1[i][0] + phys_offset);
1099 fields[0]->GetExp(n)->StdPhysDeriv(1,
1100 auxArray1 = g_hat + phys_offset,
1101 auxArray2 =
m_DD1[i][1] + phys_offset);
1111 if (Basis[0]->GetPointsType() ==
1113 Basis[1]->GetPointsType() ==
1129 &
m_divFC[i][0], 1, &outarray[i][0], 1);
1134 &
m_jac[0], 1, &outarray[i][0], 1);
1137 if (!(Basis[0]->Collocation()))
1139 fields[i]->FwdTrans(outarray[i], outarrayCoeff[i]);
1140 fields[i]->BwdTrans(outarrayCoeff[i], outarray[i]);
1148 ASSERTL0(
false,
"3D FRDG case not implemented yet");
1164 int nTracePts = fields[0]->GetTrace()->GetTotPoints();
1165 int nvariables = fields.num_elements();
1166 int nDim = fields[0]->GetCoordim(0);
1174 for (i = 0; i < nDim; ++i)
1183 for (j = 0; j < nDim; ++j)
1185 for (i = 0; i < nvariables ; ++i)
1188 fields[i]->GetFwdBwdTracePhys(ufield[i], Fwd, Bwd);
1198 fields[i]->GetTrace()->Upwind(Vn, Fwd, Bwd, fluxtemp);
1209 if(fields[0]->GetBndCondExpansions().num_elements())
1241 int nBndEdgePts, nBndEdges;
1243 int nBndRegions = fields[var]->GetBndCondExpansions().num_elements();
1244 int nTracePts = fields[0]->GetTrace()->GetTotPoints();
1248 fields[var]->ExtractTracePhys(ufield, uplus);
1251 for (i = 0; i < nBndRegions; ++i)
1254 nBndEdges = fields[var]->
1255 GetBndCondExpansions()[i]->GetExpSize();
1258 for (e = 0; e < nBndEdges ; ++e)
1261 nBndEdgePts = fields[var]->
1262 GetBndCondExpansions()[i]->GetExp(e)->GetTotPoints();
1266 GetBndCondExpansions()[i]->GetPhys_Offset(e);
1269 id2 = fields[0]->GetTrace()->
1270 GetPhys_Offset(fields[0]->GetTraceMap()->
1271 GetBndCondTraceToGlobalTraceMap(cnt++));
1274 if (fields[var]->GetBndConditions()[i]->
1279 GetBndCondExpansions()[i]->
1281 &penaltyflux[id2], 1);
1284 else if ((fields[var]->GetBndConditions()[i])->
1289 &penaltyflux[id2], 1);
1306 int nTracePts = fields[0]->GetTrace()->GetTotPoints();
1307 int nvariables = fields.num_elements();
1308 int nDim = fields[0]->GetCoordim(0);
1321 for(i = 0; i < nDim; ++i)
1329 for (i = 0; i < nvariables; ++i)
1332 for (j = 0; j < nDim; ++j)
1335 fields[i]->GetFwdBwdTracePhys(qfield[i][j], qFwd, qBwd);
1349 fields[i]->GetTrace()->Upwind(Vn, qBwd, qFwd, qfluxtemp);
1374 if (fields[0]->GetBndCondExpansions().num_elements())
1404 int nBndEdges, nBndEdgePts;
1405 int nBndRegions = fields[var]->GetBndCondExpansions().num_elements();
1406 int nTracePts = fields[0]->GetTrace()->GetTotPoints();
1412 fields[var]->ExtractTracePhys(qfield, qtemp);
1414 for (i = 0; i < nBndRegions; ++i)
1416 nBndEdges = fields[var]->
1417 GetBndCondExpansions()[i]->GetExpSize();
1420 for (e = 0; e < nBndEdges ; ++e)
1422 nBndEdgePts = fields[var]->
1423 GetBndCondExpansions()[i]->GetExp(e)->GetTotPoints();
1426 GetBndCondExpansions()[i]->GetPhys_Offset(e);
1428 id2 = fields[0]->GetTrace()->
1429 GetPhys_Offset(fields[0]->GetTraceMap()->
1430 GetBndCondTraceToGlobalTraceMap(cnt++));
1434 if (fields[var]->GetBndConditions()[i]->
1438 &qtemp[id2], 1, &penaltyflux[id2], 1);
1441 else if ((fields[var]->GetBndConditions()[i])->
1445 &(fields[var]->GetBndCondExpansions()[i]->
1446 GetPhys())[id1], 1, &penaltyflux[id2], 1);
1463 const int nConvectiveFields,
1470 int nLocalSolutionPts, phys_offset, t_offset;
1478 Basis = fields[0]->GetExp(0)->GetBasis(0);
1480 int nElements = fields[0]->GetExpSize();
1481 int nSolutionPts = fields[0]->GetTotPoints();
1494 &elmtToTrace = fields[0]->GetTraceMap()->GetElmtToTrace();
1496 for (n = 0; n < nElements; ++n)
1498 nLocalSolutionPts = fields[0]->GetExp(n)->GetTotPoints();
1499 phys_offset = fields[0]->GetPhys_Offset(n);
1504 &flux[phys_offset], 1,
1507 fields[0]->GetExp(n)->GetVertexPhysVals(0, tmparrayX1,
1510 t_offset = fields[0]->GetTrace()
1511 ->GetPhys_Offset(elmtToTrace[n][0]->GetElmtId());
1513 if(negatedFluxNormal[2*n])
1515 JumpL[n] = iFlux[t_offset] - tmpFluxVertex;
1519 JumpL[n] = -iFlux[t_offset] - tmpFluxVertex;
1522 t_offset = fields[0]->GetTrace()
1523 ->GetPhys_Offset(elmtToTrace[n][1]->GetElmtId());
1525 fields[0]->GetExp(n)->GetVertexPhysVals(1, tmparrayX1,
1527 if(negatedFluxNormal[2*n+1])
1529 JumpR[n] = -iFlux[t_offset] - tmpFluxVertex;
1533 JumpR[n] = iFlux[t_offset] - tmpFluxVertex;
1537 for (n = 0; n < nElements; ++n)
1539 ptsKeys = fields[0]->GetExp(n)->GetPointsKeys();
1540 nLocalSolutionPts = fields[0]->GetExp(n)->GetTotPoints();
1541 phys_offset = fields[0]->GetPhys_Offset(n);
1542 jac = fields[0]->GetExp(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,
1580 const int direction,
1586 int n, e, i, j, cnt;
1591 int nElements = fields[0]->GetExpSize();
1593 int trace_offset, phys_offset;
1594 int nLocalSolutionPts;
1602 &elmtToTrace = fields[0]->GetTraceMap()->GetElmtToTrace();
1605 for (n = 0; n < nElements; ++n)
1608 phys_offset = fields[0]->GetPhys_Offset(n);
1609 nLocalSolutionPts = fields[0]->GetExp(n)->GetTotPoints();
1610 ptsKeys = fields[0]->GetExp(n)->GetPointsKeys();
1615 base = fields[0]->GetExp(n)->GetBase();
1616 nquad0 = base[0]->GetNumPoints();
1617 nquad1 = base[1]->GetNumPoints();
1625 for (e = 0; e < fields[0]->GetExp(n)->GetNedges(); ++e)
1628 nEdgePts = fields[0]->GetExp(n)->GetEdgeNumPoints(e);
1634 trace_offset = fields[0]->GetTrace()->GetPhys_Offset(
1635 elmtToTrace[n][e]->GetElmtId());
1644 fields[0]->GetExp(n)->GetEdgePhysVals(e, elmtToTrace[n][e],
1646 auxArray1 = tmparray);
1652 &tmparray[0], 1, &fluxJumps[0], 1);
1656 if (fields[0]->GetExp(n)->GetEorient(e) ==
1665 if (fields[0]->GetExp(n)->as<LocalRegions::Expansion2D>()
1666 ->GetGeom2D()->GetMetricInfo()->GetGtype()
1672 fields[0]->GetExp(n)->GetEdgePhysVals(
1673 e, elmtToTrace[n][e],
1674 jac, auxArray1 = jacEdge);
1678 if (fields[0]->GetExp(n)->GetEorient(e) ==
1688 for (j = 0; j < nEdgePts; j++)
1690 fluxJumps[j] = fluxJumps[j] * jacEdge[j];
1708 for (i = 0; i < nquad0; ++i)
1713 for (j = 0; j < nquad1; ++j)
1716 divCFluxE0[cnt] = fluxJumps[i] *
m_dGL_xi2[n][j];
1721 for (i = 0; i < nquad1; ++i)
1726 for (j = 0; j < nquad0; ++j)
1728 cnt = (nquad0)*i + j;
1729 divCFluxE1[cnt] = fluxJumps[i] *
m_dGR_xi1[n][j];
1734 for (i = 0; i < nquad0; ++i)
1739 for (j = 0; j < nquad1; ++j)
1741 cnt = (nquad0 - 1) + j*nquad0 - i;
1742 divCFluxE2[cnt] = fluxJumps[i] *
m_dGR_xi2[n][j];
1747 for (i = 0; i < nquad1; ++i)
1751 for (j = 0; j < nquad0; ++j)
1753 cnt = (nquad0*nquad1 - nquad0) + j - i*nquad0;
1754 divCFluxE3[cnt] = fluxJumps[i] *
m_dGL_xi1[n][j];
1760 ASSERTL0(
false,
"edge value (< 3) is out of range");
1770 &divCFluxE3[0], 1, &derCFlux[phys_offset], 1);
1772 else if (direction == 1)
1775 &divCFluxE2[0], 1, &derCFlux[phys_offset], 1);
1794 const int nConvectiveFields,
1801 int n, e, i, j, cnt;
1803 int nElements = fields[0]->GetExpSize();
1805 int nLocalSolutionPts;
1816 &elmtToTrace = fields[0]->GetTraceMap()->GetElmtToTrace();
1819 for(n = 0; n < nElements; ++n)
1822 phys_offset = fields[0]->GetPhys_Offset(n);
1823 nLocalSolutionPts = fields[0]->GetExp(n)->GetTotPoints();
1825 base = fields[0]->GetExp(n)->GetBase();
1826 nquad0 = base[0]->GetNumPoints();
1827 nquad1 = base[1]->GetNumPoints();
1835 for(e = 0; e < fields[0]->GetExp(n)->GetNedges(); ++e)
1838 nEdgePts = fields[0]->GetExp(n)->GetEdgeNumPoints(e);
1847 trace_offset = fields[0]->GetTrace()->GetPhys_Offset(
1848 elmtToTrace[n][e]->GetElmtId());
1852 fields[0]->GetExp(n)->GetEdgeNormal(e);
1856 fields[0]->GetExp(n)->GetEdgePhysVals(
1857 e, elmtToTrace[n][e],
1858 fluxX1 + phys_offset,
1859 auxArray1 = tmparrayX1);
1863 fields[0]->GetExp(n)->GetEdgePhysVals(
1864 e, elmtToTrace[n][e],
1865 fluxX2 + phys_offset,
1866 auxArray1 = tmparrayX2);
1869 for (i = 0; i < nEdgePts; ++i)
1878 &numericalFlux[trace_offset], 1,
1879 &fluxN[0], 1, &fluxJumps[0], 1);
1882 if (fields[0]->GetExp(n)->GetEorient(e) ==
1886 auxArray1 = fluxJumps, 1,
1887 auxArray2 = fluxJumps, 1);
1890 NekDouble fac = fields[0]->GetExp(n)->EdgeNormalNegated(e) ?
1893 for (i = 0; i < nEdgePts; ++i)
1898 fluxJumps[i] = -fluxJumps[i];
1906 for (i = 0; i < nquad0; ++i)
1909 fluxJumps[i] = -(
m_Q2D_e0[n][i]) * fluxJumps[i];
1911 for (j = 0; j < nquad1; ++j)
1914 divCFluxE0[cnt] = fluxJumps[i] *
m_dGL_xi2[n][j];
1919 for (i = 0; i < nquad1; ++i)
1922 fluxJumps[i] = (
m_Q2D_e1[n][i]) * fluxJumps[i];
1924 for (j = 0; j < nquad0; ++j)
1926 cnt = (nquad0)*i + j;
1927 divCFluxE1[cnt] = fluxJumps[i] *
m_dGR_xi1[n][j];
1932 for (i = 0; i < nquad0; ++i)
1935 fluxJumps[i] = (
m_Q2D_e2[n][i]) * fluxJumps[i];
1937 for (j = 0; j < nquad1; ++j)
1939 cnt = (nquad0 - 1) + j*nquad0 - i;
1940 divCFluxE2[cnt] = fluxJumps[i] *
m_dGR_xi2[n][j];
1945 for (i = 0; i < nquad1; ++i)
1948 fluxJumps[i] = -(
m_Q2D_e3[n][i]) * fluxJumps[i];
1949 for (j = 0; j < nquad0; ++j)
1951 cnt = (nquad0*nquad1 - nquad0) + j - i*nquad0;
1952 divCFluxE3[cnt] = fluxJumps[i] *
m_dGL_xi1[n][j];
1958 ASSERTL0(
false,
"edge value (< 3) is out of range");
1965 &divCFluxE1[0], 1, &divCFlux[phys_offset], 1);
1967 Vmath::Vadd(nLocalSolutionPts, &divCFlux[phys_offset], 1,
1968 &divCFluxE2[0], 1, &divCFlux[phys_offset], 1);
1970 Vmath::Vadd(nLocalSolutionPts, &divCFlux[phys_offset], 1,
1971 &divCFluxE3[0], 1, &divCFlux[phys_offset], 1);
1990 const int nConvectiveFields,
1997 int n, e, i, j, cnt;
1999 int nElements = fields[0]->GetExpSize();
2000 int nLocalSolutionPts;
2011 &elmtToTrace = fields[0]->GetTraceMap()->GetElmtToTrace();
2014 for(n = 0; n < nElements; ++n)
2017 phys_offset = fields[0]->GetPhys_Offset(n);
2018 nLocalSolutionPts = fields[0]->GetExp(n)->GetTotPoints();
2020 base = fields[0]->GetExp(n)->GetBase();
2021 nquad0 = base[0]->GetNumPoints();
2022 nquad1 = base[1]->GetNumPoints();
2030 for(e = 0; e < fields[0]->GetExp(n)->GetNedges(); ++e)
2033 nEdgePts = fields[0]->GetExp(n)->GetEdgeNumPoints(e);
2042 trace_offset = fields[0]->GetTrace()->GetPhys_Offset(
2043 elmtToTrace[n][e]->GetElmtId());
2047 fields[0]->GetExp(n)->GetEdgeNormal(e);
2056 fields[0]->GetExp(n)->GetEdgePhysVals(
2057 e, elmtToTrace[n][e],
2058 fluxX2 + phys_offset,
2059 auxArray1 = fluxN_D);
2065 &numericalFlux[trace_offset], 1,
2069 if (fields[0]->GetExp(n)->GetEorient(e) ==
2073 auxArray1 = fluxN, 1,
2074 auxArray2 = fluxN, 1);
2077 auxArray1 = fluxN_D, 1,
2078 auxArray2 = fluxN_D, 1);
2082 for (i = 0; i < nquad0; ++i)
2085 fluxN_R[i] = (
m_Q2D_e0[n][i]) * fluxN[i];
2088 for (i = 0; i < nEdgePts; ++i)
2095 fluxN_R[i] = -fluxN_R[i];
2103 &fluxN_D[0], 1, &fluxJumps[0], 1);
2107 for (i = 0; i < nquad0; ++i)
2109 for (j = 0; j < nquad1; ++j)
2121 fields[0]->GetExp(n)->GetEdgePhysVals(
2122 e, elmtToTrace[n][e],
2123 fluxX1 + phys_offset,
2124 auxArray1 = fluxN_D);
2128 &numericalFlux[trace_offset], 1,
2132 if (fields[0]->GetExp(n)->GetEorient(e) ==
2136 auxArray1 = fluxN, 1,
2137 auxArray2 = fluxN, 1);
2140 auxArray1 = fluxN_D, 1,
2141 auxArray2 = fluxN_D, 1);
2145 for (i = 0; i < nquad1; ++i)
2148 fluxN_R[i] = (
m_Q2D_e1[n][i]) * fluxN[i];
2151 for (i = 0; i < nEdgePts; ++i)
2158 fluxN_R[i] = -fluxN_R[i];
2166 &fluxN_D[0], 1, &fluxJumps[0], 1);
2170 for (i = 0; i < nquad1; ++i)
2172 for (j = 0; j < nquad0; ++j)
2174 cnt = (nquad0)*i + j;
2186 fields[0]->GetExp(n)->GetEdgePhysVals(
2187 e, elmtToTrace[n][e],
2188 fluxX2 + phys_offset,
2189 auxArray1 = fluxN_D);
2193 &numericalFlux[trace_offset], 1,
2197 if (fields[0]->GetExp(n)->GetEorient(e) ==
2201 auxArray1 = fluxN, 1,
2202 auxArray2 = fluxN, 1);
2205 auxArray1 = fluxN_D, 1,
2206 auxArray2 = fluxN_D, 1);
2210 for (i = 0; i < nquad0; ++i)
2213 fluxN_R[i] = (
m_Q2D_e2[n][i]) * fluxN[i];
2216 for (i = 0; i < nEdgePts; ++i)
2223 fluxN_R[i] = -fluxN_R[i];
2232 &fluxN_D[0], 1, &fluxJumps[0], 1);
2236 for (i = 0; i < nquad0; ++i)
2238 for (j = 0; j < nquad1; ++j)
2240 cnt = (nquad0 - 1) + j*nquad0 - i;
2251 fields[0]->GetExp(n)->GetEdgePhysVals(
2252 e, elmtToTrace[n][e],
2253 fluxX1 + phys_offset,
2254 auxArray1 = fluxN_D);
2259 &numericalFlux[trace_offset], 1,
2263 if (fields[0]->GetExp(n)->GetEorient(e) ==
2267 auxArray1 = fluxN, 1,
2268 auxArray2 = fluxN, 1);
2271 auxArray1 = fluxN_D, 1,
2272 auxArray2 = fluxN_D, 1);
2276 for (i = 0; i < nquad1; ++i)
2279 fluxN_R[i] = (
m_Q2D_e3[n][i]) * fluxN[i];
2282 for (i = 0; i < nEdgePts; ++i)
2289 fluxN_R[i] = -fluxN_R[i];
2298 &fluxN_D[0], 1, &fluxJumps[0], 1);
2302 for (i = 0; i < nquad1; ++i)
2304 for (j = 0; j < nquad0; ++j)
2306 cnt = (nquad0*nquad1 - nquad0) + j
2314 ASSERTL0(
false,
"edge value (< 3) is out of range");
2322 &divCFluxE1[0], 1, &divCFlux[phys_offset], 1);
2324 Vmath::Vadd(nLocalSolutionPts, &divCFlux[phys_offset], 1,
2325 &divCFluxE2[0], 1, &divCFlux[phys_offset], 1);
2327 Vmath::Vadd(nLocalSolutionPts, &divCFlux[phys_offset], 1,
2328 &divCFluxE3[0], 1, &divCFlux[phys_offset], 1);
Array< OneD, Array< OneD, NekDouble > > m_dGL_xi1
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, NekDouble > > m_dGL_xi3
#define ASSERTL0(condition, msg)
Array< OneD, Array< OneD, NekDouble > > m_Q2D_e2
std::vector< PointsKey > PointsKeyVector
Array< OneD, Array< OneD, NekDouble > > m_Q2D_e3
Array< OneD, Array< OneD, NekDouble > > m_dGR_xi1
virtual void v_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.
DiffusionFactory & GetDiffusionFactory()
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
Array< OneD, Array< OneD, Array< OneD, NekDouble > > > m_DU1
Array< OneD, Array< OneD, NekDouble > > m_dGL_xi2
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.
boost::shared_ptr< SessionReader > SessionReaderSharedPtr
Array< OneD, Array< OneD, NekDouble > > m_dGR_xi3
1D Gauss-Gauss-Legendre quadrature points
Array< OneD, NekDouble > m_jac
Array< OneD, Array< OneD, NekDouble > > m_divFC
Array< OneD, Array< OneD, NekDouble > > m_traceNormals
Array< OneD, Array< OneD, NekDouble > > m_dGR_xi2
virtual void v_InitObject(LibUtilities::SessionReaderSharedPtr pSession, Array< OneD, MultiRegions::ExpListSharedPtr > pFields)
Initiliase DiffusionLFR objects and store them before starting the time-stepping. ...
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–7...
void Reverse(int n, const T *x, const int incx, T *y, const int incy)
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*y.
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.
Array< OneD, Array< OneD, NekDouble > > m_Q2D_e1
virtual void v_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.
virtual void v_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.
This class is the abstraction of a global discontinuous two- dimensional spectral/hp element expansio...
void Neg(int n, T *x, const int incx)
Negate x = -x.
Array< OneD, Array< OneD, Array< OneD, NekDouble > > > m_DFC1
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...
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.
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.
Array< OneD, Array< OneD, NekDouble > > m_gmat
Array< OneD, Array< OneD, NekDouble > > m_Q2D_e0
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.
Array< OneD, Array< OneD, Array< OneD, NekDouble > > > m_DFC2
Array< OneD, Array< OneD, Array< OneD, NekDouble > > > m_tmp1
Array< OneD, Array< OneD, Array< OneD, NekDouble > > > m_tmp2
Array< OneD, Array< OneD, Array< OneD, NekDouble > > > m_IF1
virtual void v_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.
virtual void v_Diffuse(const int nConvectiveFields, const Array< OneD, MultiRegions::ExpListSharedPtr > &fields, const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray)
Calculate FR Diffusion for the linear problems using an LDG interface flux.
const boost::shared_ptr< SpatialDomains::GeomFactors > & GetMetricInfo(void) const
Array< OneD, Array< OneD, Array< OneD, NekDouble > > > m_DD1
boost::shared_ptr< Basis > BasisSharedPtr
Array< OneD, Array< OneD, NekDouble > > m_divFD
Array< OneD, Array< OneD, Array< OneD, NekDouble > > > m_D1
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Geometry is curved or has non-constant factors.
Array< OneD, Array< OneD, Array< OneD, NekDouble > > > m_BD1
LibUtilities::SessionReaderSharedPtr m_session
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 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.
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_IF2
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, tDescription pDesc="")
Register a class with the factory.