42 { 1.0, 0.0, 0.0},{ 2.0, -1.0, 0.0},{ 3.0, -3.0, 1.0}};
44 { 1.0, 0.0, 0.0},{ 2.0, -0.5, 0.0},{ 3.0, -1.5, 1.0/3.0}};
52 Loki::NoDestroy > Type;
53 return Type::Instance();
58 Array<OneD, MultiRegions::ExpListSharedPtr> pFields,
60 const Array<OneD, int> pVel,
62 : m_session(pSession),
64 m_pressure(pPressure),
66 m_advObject(advObject)
79 "StandardExtrapolate",
"StandardExtrapolate");
90 const Array<
OneD,
const Array<OneD, NekDouble> > &fields,
91 const Array<
OneD,
const Array<OneD, NekDouble> > &N,
96 Array<OneD, NekDouble> tmp;
97 Array<OneD, NekDouble> accelerationTerm;
119 for(cnt = n = 0; n <
m_PBndConds.num_elements(); ++n)
137 accelerationTerm, 1);
139 for(
int i = 0; i < acc_order; i++)
145 accelerationTerm, 1);
160 for(n = 0; n < nint-1; ++n)
169 for(cnt = n = 0; n <
m_PBndConds.num_elements(); ++n)
190 const Array<
OneD,
const Array<OneD, NekDouble> > &fields,
191 const Array<
OneD,
const Array<OneD, NekDouble> > &N,
194 Array<OneD, NekDouble> Pvals;
195 Array<OneD, NekDouble> Uvals;
199 Array<OneD, Array<OneD, const NekDouble> > Velocity(
m_curl_dim);
200 Array<OneD, Array<OneD, const NekDouble> > Advection(
m_bnd_dim);
202 Array<OneD, Array<OneD, NekDouble> > BndValues(
m_bnd_dim);
203 Array<OneD, Array<OneD, NekDouble> > Q(
m_bnd_dim);
211 for(
int j = 0 ; j <
m_HBCdata.num_elements() ; j++)
224 Velocity[i] = fields[i] +
m_HBCdata[j].m_physOffset;
225 Advection[i] = N[i] +
m_HBCdata[j].m_physOffset;
231 Velocity[2] = fields[2] +
m_HBCdata[j].m_assPhysOffset;
245 ->GetCoeff_Offset(
m_HBCdata[j].m_bndElmtOffset);
256 elmt->GetEdgePhysVals(
m_HBCdata[j].m_elmtTraceID, Pbc,
258 elmt->GetEdgePhysVals(
m_HBCdata[j].m_elmtTraceID, Pbc,
260 Pbc->NormVectorIProductWRTBase(BndValues[0], BndValues[1],
263 elmt->GetEdgePhysVals(
m_HBCdata[j].m_elmtTraceID, Pbc,
264 Velocity[0], BndValues[0]);
265 elmt->GetEdgePhysVals(
m_HBCdata[j].m_elmtTraceID, Pbc,
266 Velocity[1], BndValues[1]);
267 Pbc->NormVectorIProductWRTBase(BndValues[0], BndValues[1],
281 else if (
m_HBCdata[j].m_elmtTraceID == 1)
292 "In the 3D homogeneous 2D approach BCs edge "
293 "ID can be just 0 or 1 ");
299 elmt->GetFacePhysVals(
m_HBCdata[j].m_elmtTraceID, Pbc,
301 elmt->GetFacePhysVals(
m_HBCdata[j].m_elmtTraceID, Pbc,
303 elmt->GetFacePhysVals(
m_HBCdata[j].m_elmtTraceID, Pbc,
305 Pbc->NormVectorIProductWRTBase(BndValues[0], BndValues[1],
306 BndValues[2], Pvals);
308 elmt->GetFacePhysVals(
m_HBCdata[j].m_elmtTraceID, Pbc,
309 Velocity[0], BndValues[0]);
310 elmt->GetFacePhysVals(
m_HBCdata[j].m_elmtTraceID, Pbc,
311 Velocity[1], BndValues[1]);
312 elmt->GetFacePhysVals(
m_HBCdata[j].m_elmtTraceID, Pbc,
313 Velocity[2], BndValues[2]);
314 Pbc->NormVectorIProductWRTBase(BndValues[0], BndValues[1],
315 BndValues[2], Uvals);
319 ASSERTL0(0,
"Dimension not supported");
328 const Array<
OneD,
const Array<OneD, NekDouble> > &fields,
329 const Array<
OneD,
const Array<OneD, NekDouble> > &N,
333 static bool init =
true;
334 static bool noHOBC =
false;
345 for(
int n = 0; n <
m_PBndConds.num_elements(); ++n)
350 totbndpts +=
m_PBndExp[n]->GetTotPoints();
367 m_outflowVel[i][j] = Array<OneD, NekDouble>(totbndpts,0.0);
373 Array<OneD, Array<OneD, const SpatialDomains::BoundaryConditionShPtr> >
375 Array<OneD, Array<OneD, MultiRegions::ExpListSharedPtr> >
384 Array<OneD, Array<OneD, NekDouble> > BndValues(
m_bnd_dim);
385 Array<OneD, Array<OneD, NekDouble> > BndElmt (
m_bnd_dim);
386 Array<OneD, Array<OneD, NekDouble> > nGradu(
m_bnd_dim);
400 int nbc,cnt,cnt_start;
405 Array<OneD, NekDouble> PBCvals, UBCvals;
406 Array<OneD, Array<OneD, NekDouble> > ubc(m_curl_dim);
407 Array<OneD, Array<OneD, NekDouble> > normals;
410 for(
int n = 0; n <
m_PBndConds.num_elements(); ++n)
415 for(
int i = 0; i <
m_PBndExp[n]->GetExpSize(); ++i,cnt++)
417 cnt = max(cnt,
m_PBndExp[n]->GetTotPoints());
424 ubc[i] = Array<OneD, NekDouble>(cnt);
428 m_session->LoadParameter(
"U0_HighOrderBC",U0,1.0);
429 m_session->LoadParameter(
"Delta_HighOrderBC",delta,1/20.0);
432 for(
int n = 0; n <
m_PBndConds.num_elements(); ++n)
439 for(
int i = 0; i <
m_PBndExp[n]->GetExpSize(); ++i,cnt++)
447 int offset =
m_fields[0]->GetPhys_Offset(elmtid);
450 int nq = elmt->GetTotPoints();
460 int nbc =
m_PBndExp[n]->GetExp(i)->GetTotPoints();
463 Array<OneD, NekDouble> veltmp, ptmp(nbc,0.0),
464 normDotu(nbc,0.0), utot(nbc,0.0),
467 normals=elmt->GetSurfaceNormal(boundary);
476 BndElmt[j], gradtmp);
477 elmt->GetTracePhysVals(boundary, Bc, gradtmp,
480 nGradu[j], 1, nGradu[j],1);
491 elmt->GetTracePhysVals(boundary,Bc,BndElmt[j],
526 normDotu, 1, normDotu, 1);
534 for(
int k = 0; k < nbc; ++k)
536 NekDouble fac = 0.5*(1.0-tanh(normDotu[k]/(U0*delta)));
541 ptmp[k] = kinvis * ptmp[k] - 0.5 * utot[k] * fac
545 int u_offset = UBndExp[0][n]->GetPhys_Offset(i);
549 UBCvals = UBndExp[j][n]->GetPhys()
550 + UBndExp[j][n]->GetPhys_Offset(i);
552 for(
int k = 0; k < nbc; ++k)
554 NekDouble fac = 0.5 * (1.0 - tanh(normDotu[k]
556 ubc[j][k + u_offset] = (1.0 / kinvis)
557 * (UBCvals[k] + 0.5 * utot[k] * fac
565 m_PBndExp[n]->GetExp(i)->FwdTrans(ptmp,PBCvals);
573 if(UBndConds[j][n]->GetUserDefined()
578 for(
int i = 0; i < UBndExp[0][n]->GetExpSize();
584 (UBndExp[0][n]->GetExp(i));
586 nbc = UBndExp[0][n]->GetExp(i)->GetTotPoints();
589 Array<OneD, NekDouble> pb(nbc), ub(nbc);
594 normals = elmt->GetSurfaceNormal(boundary);
599 Pbc->BwdTrans(PBCvals,pb);
601 int u_offset = UBndExp[j][n]->GetPhys_Offset(i);
603 for(
int k = 0; k < nbc; ++k)
605 ub[k] = ubc[j][k + u_offset]
606 + pb[k] * normals[j][k] / kinvis;
609 UBCvals = UBndExp[j][n]->UpdateCoeffs()
610 + UBndExp[j][n]->GetCoeff_Offset(i);
611 Bc->IProductWRTBase(ub,UBCvals);
628 Array<
OneD, Array<OneD, const NekDouble> > &Vel,
629 Array<
OneD, Array<OneD, NekDouble> > &Q,
649 elmt->PhysDeriv(Dummy,Q[1],Q[0]);
672 Vel[0], 1, Dummy1, 1);
681 Vel[1], 1, Dummy2, 1);
734 elmt->PhysDeriv(Vel[0], Dummy, Uy, Uz);
735 elmt->PhysDeriv(Vel[1], Vx, Dummy, Vz);
736 elmt->PhysDeriv(Vel[2], Wx, Wy, Dummy);
742 elmt->PhysDeriv(Q[0], Dummy, Wy, Vx);
743 elmt->PhysDeriv(Q[1], Wx, Dummy, Uz);
744 elmt->PhysDeriv(Q[2], Vz, Uy, Dummy);
752 ASSERTL0(0,
"Dimension not supported");
766 int nlevels = input.num_elements();
768 Array<OneD, NekDouble> tmp;
770 tmp = input[nlevels-1];
772 for(
int n = nlevels-1; n > 0; --n)
774 input[n] = input[n-1];
798 for(cnt = n = 0; n <
m_PBndConds.num_elements(); ++n)
800 for(
int i = 0; i <
m_PBndExp[n]->GetExpSize(); ++i)
803 m_PBndExp[n]->GetExp(i)->GetTotPoints());
815 for(cnt = n = 0; n <
m_PBndConds.num_elements(); ++n)
825 int checkHBC = HBCnumber;
831 m_acceleration[0] = Array<OneD, NekDouble>(cnt, 0.0);
835 m_acceleration[n+1] = Array<OneD, NekDouble>(cnt, 0.0);
867 ASSERTL0(0,
"Dimension not supported");
872 m_HBCdata = Array<OneD, HBCInfo>(HBCnumber);
884 for(
int n = 0 ; n <
m_PBndConds.num_elements(); ++n)
891 for(
int i = 0; i < exp_size; ++i,cnt++)
898 elmt->GetTotPoints();
906 m_HBCdata[j].m_coeffOffset = coeff_count;
907 coeff_count += elmt->GetEdgeNcoeffs(
922 Array<OneD, unsigned int> planes;
924 int num_planes = planes.num_elements();
925 int num_elm_per_plane = (
m_pressure->GetExpSize())/num_planes;
931 int exp_size, exp_size_per_plane;
937 m_session->MatchSolverInfo(
"ModeType",
"SingleMode",
939 m_session->MatchSolverInfo(
"ModeType",
"HalfMode",
941 m_session->MatchSolverInfo(
"ModeType",
"MultipleModes",
946 if(
m_session->DefinesSolverInfo(
"ModeType"))
962 ASSERTL0(
false,
"SolverInfo ModeType not valid");
970 for(
int k = 0; k < num_planes; k++)
973 for(
int n = 0 ; n <
m_PBndConds.num_elements(); ++n)
976 exp_size_per_plane = exp_size/num_planes;
980 for(
int i = 0; i < exp_size_per_plane; ++i,cnt++)
984 m_HBCdata[j].m_ptsInElmt = elmt->GetTotPoints();
986 m_HBCdata[j].m_bndElmtOffset = i+k*exp_size_per_plane;
989 m_HBCdata[j].m_coeffOffset = coeff_count;
990 coeff_count += elmt->GetEdgeNcoeffs(
m_HBCdata[j].m_elmtTraceID);
1014 assElmtID =
m_HBCdata[j].m_globalElmtID;
1019 assElmtID =
m_HBCdata[j].m_globalElmtID + num_elm_per_plane;
1024 assElmtID =
m_HBCdata[j].m_globalElmtID - num_elm_per_plane;
1034 cnt += exp_size_per_plane;
1045 int exp_size, exp_size_per_line;
1052 for(
int n = 0 ; n <
m_PBndConds.num_elements(); ++n)
1056 exp_size_per_line = exp_size/(m_npointsZ*
m_npointsY);
1060 for(
int i = 0; i < exp_size_per_line; ++i,cnt++)
1065 m_HBCdata[j].m_ptsInElmt = elmt->GetTotPoints();
1067 m_HBCdata[j].m_bndElmtOffset = i+(k1*m_npointsY+k2)*exp_size_per_line;
1074 cnt += exp_size_per_line;
1082 ASSERTL0(0,
"Dimension not supported");
1091 const Array<
OneD, Array<OneD,NekDouble> > inarray)
1096 int n_points_0 =
m_fields[0]->GetExp(0)->GetTotPoints();
1097 int n_element =
m_fields[0]->GetExpSize();
1098 int nvel = inarray.num_elements();
1104 Array<OneD, Array<OneD, NekDouble> > stdVelocity(nvel);
1105 Array<OneD, NekDouble> maxV(n_element, 0.0);
1108 for (
int i = 0; i < nvel; ++i)
1110 stdVelocity[i] = Array<OneD, NekDouble>(n_points_0);
1116 for (
int el = 0; el < n_element; ++el)
1118 int n_points =
m_fields[0]->GetExp(el)->GetTotPoints();
1119 ptsKeys =
m_fields[0]->GetExp(el)->GetPointsKeys();
1122 if(n_points != n_points_0)
1124 for (
int j = 0; j < nvel; ++j)
1126 stdVelocity[j] = Array<OneD, NekDouble>(n_points);
1128 n_points_0 = n_points;
1131 Array<TwoD, const NekDouble> gmat =
1132 m_fields[0]->GetExp(el)->GetGeom()->GetMetricInfo()->GetDerivFactors(ptsKeys);
1134 if (
m_fields[0]->GetExp(el)->GetGeom()->GetMetricInfo()->GetGtype()
1137 for (
int i = 0; i < n_points; i++)
1139 stdVelocity[0][i] = gmat[0][i]*inarray[0][i+cnt]
1140 + gmat[2][i]*inarray[1][i+cnt];
1142 stdVelocity[1][i] = gmat[1][i]*inarray[0][i+cnt]
1143 + gmat[3][i]*inarray[1][i+cnt];
1148 for (
int i = 0; i < n_points; i++)
1150 stdVelocity[0][i] = gmat[0][0]*inarray[0][i+cnt]
1151 + gmat[2][0]*inarray[1][i+cnt];
1153 stdVelocity[1][i] = gmat[1][0]*inarray[0][i+cnt]
1154 + gmat[3][0]*inarray[1][i+cnt];
1161 for (
int i = 0; i < n_points; i++)
1163 pntVelocity = stdVelocity[0][i]*stdVelocity[0][i]
1164 + stdVelocity[1][i]*stdVelocity[1][i];
1166 if (pntVelocity>maxV[el])
1168 maxV[el] = pntVelocity;
1171 maxV[el] = sqrt(maxV[el]);
1177 for (
int el = 0; el < n_element; ++el)
1180 int n_points =
m_fields[0]->GetExp(el)->GetTotPoints();
1181 ptsKeys =
m_fields[0]->GetExp(el)->GetPointsKeys();
1184 if(n_points != n_points_0)
1186 for (
int j = 0; j < nvel; ++j)
1188 stdVelocity[j] = Array<OneD, NekDouble>(n_points);
1190 n_points_0 = n_points;
1193 Array<TwoD, const NekDouble> gmat =
1194 m_fields[0]->GetExp(el)->GetGeom()->GetMetricInfo()->GetDerivFactors(ptsKeys);
1196 if (
m_fields[0]->GetExp(el)->GetGeom()->GetMetricInfo()->GetGtype()
1199 for (
int i = 0; i < n_points; i++)
1201 stdVelocity[0][i] = gmat[0][i]*inarray[0][i+cnt]
1202 + gmat[3][i]*inarray[1][i+cnt]
1203 + gmat[6][i]*inarray[2][i+cnt];
1205 stdVelocity[1][i] = gmat[1][i]*inarray[0][i+cnt]
1206 + gmat[4][i]*inarray[1][i+cnt]
1207 + gmat[7][i]*inarray[2][i+cnt];
1209 stdVelocity[2][i] = gmat[2][i]*inarray[0][i+cnt]
1210 + gmat[5][i]*inarray[1][i+cnt]
1211 + gmat[8][i]*inarray[2][i+cnt];
1216 for (
int i = 0; i < n_points; i++)
1218 stdVelocity[0][i] = gmat[0][0]*inarray[0][i+cnt]
1219 + gmat[3][0]*inarray[1][i+cnt]
1220 + gmat[6][0]*inarray[2][i+cnt];
1222 stdVelocity[1][i] = gmat[1][0]*inarray[0][i+cnt]
1223 + gmat[4][0]*inarray[1][i+cnt]
1224 + gmat[7][0]*inarray[2][i+cnt];
1226 stdVelocity[2][i] = gmat[2][0]*inarray[0][i+cnt]
1227 + gmat[5][0]*inarray[1][i+cnt]
1228 + gmat[8][0]*inarray[2][i+cnt];
1234 for (
int i = 0; i < n_points; i++)
1236 pntVelocity = stdVelocity[0][i]*stdVelocity[0][i]
1237 + stdVelocity[1][i]*stdVelocity[1][i]
1238 + stdVelocity[2][i]*stdVelocity[2][i];
1240 if (pntVelocity > maxV[el])
1242 maxV[el] = pntVelocity;
1246 maxV[el] = sqrt(maxV[el]);