5 #ifndef _COMETBOUNDARYCONDITIONS_H_
6 #define _COMETBOUNDARYCONDITIONS_H_
26 template<
class X,
class Diag,
class OffDiag>
112 for(
int j=0;j<neibcount;j++)
121 if(cell2==c1)surface=face;
127 Grads[dir].accumulate(Gcoeff,dsf[cell2]-dsf[c0]);
128 if(min1[dir]>dsf[cell2])min1[dir]=dsf[cell2];
129 if(max1[dir]<dsf[cell2])max1[dir]=dsf[cell2];
133 for(
int j=0;j<neibcount;j++)
143 VectorT3 fVec=faceCoords[face]-cellCoords[c0];
144 T_Scalar SOU=(grad[0]*fVec[0]+grad[1]*fVec[1]+grad[2]*fVec[2]);
163 const X Tin = inletTemperature;
164 const X Pin = inletPressure;
165 const X nin = Pin/Tin;
168 temperature[c1]=inletTemperature;
169 pressure[c1]=inletPressure;
179 for (
int j=0; j<numDirections; j++)
183 dsf[c1] = nin/pow(pi*Tin,1.5)*exp(-(pow(cx[j]-v[c1][0],2.0)+pow(cy[j]-v[c1][1],2.0)+pow(cz[j]-v[c1][2],2.0))/Tin);
185 const X c_dot_en = cx[j]*en[0]+cy[j]*en[1]+cz[j]*en[2];
191 uwallnew=uwallnew+cx[j]*dsf[c0]*wts[j];
193 else {uwallnew=uwallnew+cx[j]*dsf[c1]*wts[j];}
195 else if (abs(en[1]) ==
T_Scalar(1.0))
199 uwallnew=uwallnew+cy[j]*dsf[c0]*wts[j];
201 else {uwallnew=uwallnew+cy[j]*dsf[c1]*wts[j];}
203 else if (abs(en[2]) ==
T_Scalar(1.0))
207 uwallnew=uwallnew+cz[j]*dsf[c0]*wts[j];
209 else {uwallnew=uwallnew+cz[j]*dsf[c1]*wts[j];}
223 for (
int j=0; j<numDirections; j++)
228 const X c_dot_en = cx[j]*en[0]+cy[j]*en[1]+cz[j]*en[2];
231 dsf[c1] = nin/pow(pi*Tin,1.5)*exp(-(pow(cx[j]-v[c1][0],2.0)+pow(cy[j]-v[c1][1],2.0)+pow(cz[j]-v[c1][2],2.0))/Tin);
237 VectorT3 fVec=faceCoords[surface]-cellCoords[c0];
238 VectorT3 rVec=cellCoords[c1]-cellCoords[c0];
240 T_Scalar SOU=(grad[0]*fVec[0]+grad[1]*fVec[1]+grad[2]*fVec[2]);
243 dsf[c1]=dsf[c0]+limitCoeff1[j]*SOU;
278 const X Pout = outletPressure;
279 X Pcell= pressure[c0];
285 const X avel2 =gamma*Pcell/density[c0];
286 nout =density[c0]-(Pcell-Pout)/avel2;
287 X ubulk=pow(pow(v[c0][0],2.0)+pow(v[c0][1],2.0)+pow(v[c0][2],2.0),0.5);
288 X ucoeff=1.0/ubulk*(ubulk+(Pcell-Pout)/(pow(2.0*avel2,0.5)*density[c0]));
290 v[c1][0] = v[c0][0]*ucoeff;
293 v[c1][1] = v[c0][1]*ucoeff;
295 v[c1][2] = v[c0][2]*ucoeff;
297 density[c1]=nout; pressure[c1]=Pout;
298 temperature[c1]=Pout/nout;
302 density[c1]=density[c0];
303 pressure[c1]=pressure[c0];
304 temperature[c1]=temperature[c0];
307 for (
int j=0; j<numDirections; j++)
312 const X c_dot_en = cx[j]*en[0]+cy[j]*en[1]+cz[j]*en[2];
315 dsf[c1] = nout/pow(pi*temperature[c1],1.5)*exp(-(pow(cx[j]-v[c1][0],2.0)+pow(cy[j]-v[c1][1],2.0)+pow(cz[j]-v[c1][2],2.0))/temperature[c1]);
318 else{dsf[c1]=dsf[c0];}
328 applyPressureOutletWallBC(i,bTemperature,bPressure);
375 for(
int j=0;j<neibcount;j++)
384 if(cell2==c1)surface=face;
390 Grads[dir].accumulate(Gcoeff,dsf[cell2]-dsf[c0]);
391 if(min1[dir]>dsf[cell2])min1[dir]=dsf[cell2];
392 if(max1[dir]<dsf[cell2])max1[dir]=dsf[cell2];
396 for(
int j=0;j<neibcount;j++)
406 VectorT3 fVec=faceCoords[face]-cellCoords[c0];
407 T_Scalar SOU=(grad[0]*fVec[0]+grad[1]*fVec[1]+grad[2]*fVec[2]);
420 const X uwall = WallVelocity[0];
421 const X vwall = WallVelocity[1];
422 const X wwall = WallVelocity[2];
423 const X Twall = WallTemperature;
424 const X alpha = accommodationCoefficient;
430 temperature[c1]=Twall;
434 for (
int j=0; j<numDirections; j++)
439 const X c_dot_en = cx[j]*en[0]+cy[j]*en[1]+cz[j]*en[2];
440 const X wallV_dot_en = uwall*en[0]+vwall*en[1]+wwall*en[2];
441 const X fwall = 1.0/pow(pi*Twall,1.5)*exp(-(pow(cx[j]-uwall,2.0)+pow(cy[j]-vwall,2.0)+pow(cz[j]-wwall,2.0))/Twall);
442 if (c_dot_en -wallV_dot_en <
T_Scalar(0.0))
444 Dmr = Dmr - fwall*wts[j]*(c_dot_en-wallV_dot_en);
449 VectorT3 fVec=faceCoords[surface]-cellCoords[c0];
450 VectorT3 rVec=cellCoords[c1]-cellCoords[c0];
452 T_Scalar SOU=(grad[0]*fVec[0]+grad[1]*fVec[1]+grad[2]*fVec[2]);
453 Nmr = Nmr + (dsf[c0]+limitCoeff1[j]*SOU)*wts[j]*(c_dot_en-wallV_dot_en);
457 const X nwall = Nmr/Dmr;
460 for (
int j=0; j<numDirections; j++)
465 const X c_dot_en = cx[j]*en[0]+cy[j]*en[1]+cz[j]*en[2];
466 const X wallV_dot_en = uwall*en[0]+vwall*en[1]+wwall*en[2];
468 if (c_dot_en-wallV_dot_en <
T_Scalar(0.0))
470 const int direction_incident = vecReflection[j];
474 dsf[c1] = alpha*nwall/pow(pi*Twall,1.5)*exp(-(pow(cx[j]-uwall,2.0)+pow(cy[j]-vwall,2.0)+pow(cz[j]-wwall,2.0))/Twall)+m1alpha*dsfi[c0];
479 VectorT3 fVec=faceCoords[surface]-cellCoords[c0];
480 VectorT3 rVec=cellCoords[c1]-cellCoords[c0];
482 T_Scalar SOU=(grad[0]*fVec[0]+grad[1]*fVec[1]+grad[2]*fVec[2]);
483 dsf[c1]=dsf[c0]+limitCoeff1[j]*SOU;
488 void applyRealWallBC(
const VectorX3& bVelocity,
const X& bTemperature,
const X& accomCoeff,
const vector<int>& vecReflection)
const
492 applyRealWallBC(i,bVelocity,bTemperature,accomCoeff,vecReflection,gradMatrix);
500 applyRealWallBC(i,bVelocity[i],bTemperature[i],accomCoeff[i],vecReflection,gradMatrix);
537 for(
int j=0;j<neibcount;j++)
547 if(cell2==c1)surface=face;
553 Grads[dir].accumulate(Gcoeff,dsf[cell2]-dsf[c0]);
554 if(min1[dir]>dsf[cell2])min1[dir]=dsf[cell2];
555 if(max1[dir]<dsf[cell2])max1[dir]=dsf[cell2];
559 for(
int j=0;j<neibcount;j++)
570 VectorT3 fVec=faceCoords[face]-cellCoords[c0];
571 T_Scalar SOU=(grad[0]*fVec[0]+grad[1]*fVec[1]+grad[2]*fVec[2]);
579 for (
int j=0; j<numDirections; j++)
584 VectorT3 fVec=faceCoords[surface]-cellCoords[c0];
585 VectorT3 rVec=cellCoords[c1]-cellCoords[c0];
587 T_Scalar SOU=(grad[0]*fVec[0]+grad[1]*fVec[1]+grad[2]*fVec[2]);
588 dsf[c1]=dsf[c0]+limitCoeff1[j]*SOU;
641 const X Tin = temperature[c0];
642 const X Pin = IntPress[f];
643 const X nin = Pin/Tin;
646 const X u_in=IntVel[f][0];
647 const X v_in=IntVel[f][1];
648 const X w_in=IntVel[f][2];
653 const X rho_init=
_options[
"rho_init"];
655 const X R=8314.0/
_options[
"molecularWeight"];
656 const X nondim_length=
_options[
"nonDimLt"];
657 const X mu0=rho_init*R* T_init*nondim_length/pow(2*R* T_init,0.5);
660 for (
int j=0; j<numDirections; j++)
669 dsf[c1] = nin/pow(pi*Tin,1.5)*exp(-(pow(cx[j]-u_in,2.0)+pow(cy[j]-v_in,2.0)+pow(cz[j]-w_in,2.0))/Tin)
670 *(1-viscosity[c0]/mu0/(nin*pow(Tin,2.0))*(pow(cx[j]-u_in,2.0)*tau[f][0]+pow(cy[j]-v_in,2.0)*tau[f][1]+pow(cz[j]-w_in,2.0)*tau[f][2])
671 +2.0*(cx[j]-u_in)*(cy[j]-v_in)*tau[f][3]+2.0*(cy[j]-v_in)*(cz[j]-w_in)*tau[f][4]+2.0*(cz[j]-w_in)*(cx[j]-u_in)*tau[f][5]);
int getCount(const int i) const
void applyRealWallBC(const FloatValEvaluator< VectorX3 > &bVelocity, const FloatValEvaluator< X > &bTemperature, const FloatValEvaluator< X > &accomCoeff, const vector< int > &vecReflection) const
const VectorT3Array & _faceArea
const StorageSite & _faces
void applyRealWallBC(const VectorX3 &bVelocity, const X &bTemperature, const X &accomCoeff, const vector< int > &vecReflection) const
Array< VectorX3 > VectorX3Array
Array< StressTensorX6 > StressTensorArray
const CRConnectivity & _faceCells
COMETModelOptions< X > _options
const DistFunctFields< X > & _dsfPtr
const Field & _areaMagField
X computeR(const Gradient< X > &g, const Array< X > &x, const Coord dist, int i, int j) const
void applyPressureInletBC(const FloatValEvaluator< X > &bTemperature, const FloatValEvaluator< X > &bPresssure) const
COMETModelOptions< X > & getOptions()
void applyZeroGradientBC(int f, GradMatrix &gMat) const
StressTensor< X > StressTensorX6
Coord & getCoeff(const int i, const int j)
const GeomFields & _geomFields
void applyPressureOutletBC(const X &bTemperature, const X &bPressure) const
const Array< int > & _ibType
void computeLimitCoeff(T &lc, const T x, const T &dx, const T &min, const T &max, const LimitFunc &f)
Gradient< T_Scalar > GradType
Array< VectorT3 > VectorT3Array
const CRConnectivity & _cellFaces
void applyPressureOutletBC(int f, const X &outletTemperature, const X &outletPressure) const
void applyPressureOutletBC(const FloatValEvaluator< X > &bTemperature, const FloatValEvaluator< X > &bPresssure) const
MacroFields & _macroFields
const CRConnectivity & _cellCells
void applyNSInterfaceBC() const
const CRConnectivity & _allFaceCells
void applyRealWallBC(int f, const VectorX3 &WallVelocity, const X &WallTemperature, const X &accommodationCoefficient, const vector< int > &vecReflection, GradMatrix &gMat) const
NumTypeTraits< X >::T_Scalar T_Scalar
const StorageSite & _allFaces
void applyNSInterfaceBC(int f) const
static GradMatrixType & getGradientMatrix(const Mesh &mesh, const GeomFields &geomFields)
Vector< T_Scalar, 3 > VectorT3
const StorageSite & _cells
const Quadrature< X > & _quadrature
Array< GradType > GradArray
std::vector< Field * > dsf
void applyPressureInletBC(int f, const X &inletTemperature, const X &inletPressure, GradMatrix &gMat) const
void applyZeroGradientBC() const
const TArray & _faceAreaMag
GradModelType::GradMatrixType GradMatrix
COMETBoundaryConditions(const StorageSite &faces, const Mesh &mesh, const GeomFields &geomFields, const Quadrature< X > &quadrature, MacroFields ¯oFields, DistFunctFields< X > &dsfPtr)
GradientModel< T_Scalar > GradModelType