11 int cnvars = u.
father->MatRowSize();
12 static const auto Seq012 = Eigen::seq(Eigen::fix<0>, Eigen::fix<dim - 1>);
13 static const auto SeqG012 = Eigen::seq(Eigen::fix<0>, Eigen::fix<dim - 1>);
14 static const auto SeqG123 = Eigen::seq(Eigen::fix<1>, Eigen::fix<dim>);
19 for (
index iCell = 0; iCell < mesh->NumCell(); iCell++)
25 uGradBuf.trans.startPersistentPull();
26 uGradBuf.trans.waitPersistentPull();
29 for (
index iFace = 0; iFace < mesh->NumFaceProc(); iFace++)
31 auto f2c = mesh->face2cell[iFace];
32 Elem::Quadrature gFace = direct2ndRec ? vfv->GetFaceQuadO1(iFace) : vfv->GetFaceQuad(iFace);
33 Eigen::Matrix<real, nVarsFixed, 1, Eigen::ColMajor> fluxEs(cnvars, 1);
36 auto faceBndID = mesh->GetFaceZone(iFace);
37 gFace.IntegrationSimple(
39 [&](
decltype(fluxEs) &finc,
int iG,
real w)
41 int iGQ = direct2ndRec ? -1 : iG;
42 TVec unitNorm = vfv->GetFaceNorm(iFace, iGQ)(Seq012);
43 TMat normBase = Geom::NormBuildLocalBaseV<dim>(unitNorm);
46 if (direct2ndRec && !direct2ndRec1stConv)
47 ULxy += uGradBuf[f2c[0]].transpose() * (vfv->GetFaceQuadraturePPhysFromCell(iFace, f2c[0], 0, -1) - vfv->GetCellQuadraturePPhys(f2c[0], -1))(SeqG012);
48 else if (!direct2ndRec1stConv)
49 ULxy += (vfv->GetIntPointDiffBaseValue(f2c[0], iFace, 0, iGQ, std::array<int, 1>{0}, 1) *
55 GradULxy.setZero(
dim, cnvars), GradURxy.setZero(
dim, cnvars);
57 if (direct2ndRec && !direct2ndRec1stConv)
58 GradULxy(SeqG012, EigenAll) = uGradBuf[f2c[0]];
59 else if (!direct2ndRec1stConv)
60 GradULxy(SeqG012, EigenAll) =
61 vfv->GetIntPointDiffBaseValue(f2c[0], iFace, 0, iGQ, SeqG123, 3) *
64 real minVol = vfv->GetCellVol(f2c[0]);
69 if (direct2ndRec && !direct2ndRec1stConv)
70 URxy += uGradBuf[f2c[1]].transpose() * (vfv->GetFaceQuadraturePPhysFromCell(iFace, f2c[1], 1, -1) - vfv->GetCellQuadraturePPhys(f2c[1], -1))(SeqG012);
71 else if (!direct2ndRec1stConv)
72 URxy += (vfv->GetIntPointDiffBaseValue(f2c[1], iFace, 1, iGQ, std::array<int, 1>{0}, 1) *
76 if (direct2ndRec && !direct2ndRec1stConv)
77 GradURxy(SeqG012, EigenAll) = uGradBuf[f2c[1]];
78 else if (!direct2ndRec1stConv)
79 GradURxy(SeqG012, EigenAll) =
80 vfv->GetIntPointDiffBaseValue(f2c[1], iFace, 1, iGQ, SeqG123, 3) *
82 distBary = (vfv->GetOtherCellBaryFromCell(f2c[0], f2c[1], iFace) - vfv->GetCellBary(f2c[0])).norm();
83 minVol = std::min(minVol, vfv->GetCellVol(f2c[1]));
89 ULxy, u[f2c[0]], f2c[0], iFace, iGQ,
92 vfv->GetFaceQuadraturePPhys(iFace, iGQ),
94 mesh->GetFaceZone(iFace),
true, 0);
95 distBary = (vfv->GetFaceQuadraturePPhysFromCell(iFace, f2c[0], 0, -1) - vfv->GetCellBary(f2c[0])).norm() * 2.;
98 real distGRP = minVol / vfv->GetFaceArea(iFace) * 2;
100 if (direct2ndRec1stConv)
102 TDiffU GradUMeanXy = (GradURxy + GradULxy) * 0.5;
103 GradUMeanXy += (1.0 / distGRP) *
104 (unitNorm * (URxy - ULxy).transpose());
105 real an = unitNorm(0) * settings.
ax + unitNorm(1) * settings.
ay;
106 finc = -(an * URxy + an * ULxy) * 0.5 + 0.5 * std::abs(an) * (URxy - ULxy);
108 finc += GradUMeanXy.transpose() * unitNorm * settings.
sigma;
109 finc *= vfv->GetFaceJacobiDet(iFace, iG);
111 rhs[f2c[0]] += fluxEs / vfv->GetCellVol(f2c[0]);
113 rhs[f2c[1]] += -fluxEs / vfv->GetCellVol(f2c[1]);