5 #ifndef _KINETICBOUNDARYCONDITIONS_H_
6 #define _KINETICBOUNDARYCONDITIONS_H_
23 template<
class X,
class Diag,
class OffDiag>
87 const X uwall = WallVelocity[0];
88 const X vwall = WallVelocity[1];
89 const X wwall = WallVelocity[2];
91 const X Twall = WallTemperature;
97 temperature[c1]=Twall;
101 for (
int j=0; j<numDirections; j++)
106 const X c_dot_en = cx[j]*en[0]+cy[j]*en[1]+cz[j]*en[2];
107 const X wallV_dot_en = uwall*en[0]+vwall*en[1]+wwall*en[2];
108 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);
109 if (c_dot_en -wallV_dot_en <
T_Scalar(epsilon))
111 Dmr = Dmr - fwall*wts[j]*(c_dot_en-wallV_dot_en);
112 incomFlux=incomFlux-dsf[c0]*wts[j]*(c_dot_en -wallV_dot_en);
116 Nmr = Nmr + dsf[c0]*wts[j]*(c_dot_en -wallV_dot_en);
119 const X nwall = Nmr/Dmr;
122 for (
int j=0; j<numDirections; j++)
127 const X c_dot_en = cx[j]*en[0]+cy[j]*en[1]+cz[j]*en[2];
128 const X wallV_dot_en = uwall*en[0]+vwall*en[1]+wwall*en[2];
130 if (c_dot_en-wallV_dot_en <
T_Scalar(epsilon))
132 dsf[c1] = 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);
158 void applyRealWallBC(
int f,
const VectorX3& WallVelocity,
const X& WallTemperature,
const X& accommodationCoefficient,
const vector<int>& vecReflection)
const
179 const X uwall = WallVelocity[0];
180 const X vwall = WallVelocity[1];
181 const X wwall = WallVelocity[2];
182 const X Twall = WallTemperature;
183 const X alpha = accommodationCoefficient;
189 temperature[c1]=Twall;
193 for (
int j=0; j<numDirections; j++)
198 const X c_dot_en = cx[j]*en[0]+cy[j]*en[1]+cz[j]*en[2];
199 const X wallV_dot_en = uwall*en[0]+vwall*en[1]+wwall*en[2];
200 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);
201 if (c_dot_en -wallV_dot_en <
T_Scalar(0.0))
203 Dmr = Dmr - fwall*wts[j]*(c_dot_en-wallV_dot_en);
204 incomFlux=incomFlux-dsf[c0]*wts[j]*(c_dot_en-wallV_dot_en);
208 Nmr = Nmr + dsf[c0]*wts[j]*(c_dot_en-wallV_dot_en);
211 const X nwall = Nmr/Dmr;
217 for (
int j=0; j<numDirections; j++)
222 const X c_dot_en = cx[j]*en[0]+cy[j]*en[1]+cz[j]*en[2];
223 const X wallV_dot_en = uwall*en[0]+vwall*en[1]+wwall*en[2];
233 if (c_dot_en-wallV_dot_en <
T_Scalar(0.0))
258 const int direction_incident = vecReflection[j];
262 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];
273 void applyRealWallBC(
const VectorX3& bVelocity,
const X& bTemperature,
const X& accomCoeff,
const vector<int>& vecReflection)
const
283 applyRealWallBC(i,bVelocity[i],bTemperature[i],accomCoeff[i],vecReflection);
301 for (
int j=0; j<numDirections; j++)
305 const X c_dot_en = cx[j]*en[0]+cy[j]*en[1]+cz[j]*en[2];
311 const int direction_incident = vecReflection[j];
352 for (
int j=0; j<numDirections; j++)
356 const X c_dot_en = cx[j]*en[0]+cy[j]*en[1]+cz[j]*en[2];
363 const X cx_incident = cx[j] - 2.0*c_dot_en*en[0];
364 const X cy_incident = cy[j] - 2.0*c_dot_en*en[1];
365 const X cz_incident = cz[j] - 2.0*c_dot_en*en[2];
367 const X i_incident = int((cx_incident-cx[0])/dcx+0.5);
368 const X j_incident = int((cy_incident-cy[0])/dcy+0.5);
369 const X k_incident = int((cz_incident-cz[0])/dcz+0.5);
370 const int direction_incident = k_incident+N3*j_incident+N3*N2*i_incident;
395 for (
int j=0; j<numDirections; j++)
432 const X Tin = inletTemperature;
433 const X Pin = inletPressure;
434 const X nin = Pin/Tin;
437 temperature[c1]=inletTemperature;
438 pressure[c1]=inletPressure;
448 for (
int j=0; j<numDirections; j++)
452 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);
454 const X c_dot_en = cx[j]*en[0]+cy[j]*en[1]+cz[j]*en[2];
460 uwallnew=uwallnew+cx[j]*dsf[c0]*wts[j];
462 else {uwallnew=uwallnew+cx[j]*dsf[c1]*wts[j];}
464 else if (abs(en[1]) ==
T_Scalar(1.0))
468 uwallnew=uwallnew+cy[j]*dsf[c0]*wts[j];
470 else {uwallnew=uwallnew+cy[j]*dsf[c1]*wts[j];}
472 else if (abs(en[2]) ==
T_Scalar(1.0))
476 uwallnew=uwallnew+cz[j]*dsf[c0]*wts[j];
478 else {uwallnew=uwallnew+cz[j]*dsf[c1]*wts[j];}
492 for (
int j=0; j<numDirections; j++)
497 const X c_dot_en = cx[j]*en[0]+cy[j]*en[1]+cz[j]*en[2];
500 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);
503 else{dsf[c1]=dsf[c0];}
522 void applyInletBC(
int f,
const VectorX3& InletVelocity,
const X& InletTemperature,
const X& InletMdot,
const vector<int>& vecReflection)
const
543 const X uin = InletVelocity[0];
544 const X vin = InletVelocity[1];
545 const X win = InletVelocity[2];
546 const X Tin = InletTemperature;
547 const X mdot = InletMdot;
556 const X rho_init=
_options[
"rho_init"];
558 const X R=8314.0/
_options[
"molecularWeight"];
559 const X u_init=pow(2.0*R*T_init,0.5);
561 for (
int j=0; j<numDirections; j++)
564 const X c_dot_en = cx[j]*en[0]+cy[j]*en[1]+cz[j]*en[2];
565 const X fwall = 1.0/pow(pi*Tin,1.5)*exp(-(pow(cx[j]-uin,2.0)+pow(cy[j]-vin,2.0)+pow(cz[j]-win,2.0))/Tin);
566 if (c_dot_en <
T_Scalar(0.0)){Dmr = Dmr + fwall*wts[j]*c_dot_en;}
567 Nmr=mdot/(rho_init*u_init);
570 const X nin = Nmr/Dmr;
573 for (
int j=0; j<numDirections; j++)
578 const X c_dot_en = cx[j]*en[0]+cy[j]*en[1]+cz[j]*en[2];
582 const int direction_incident = vecReflection[j];
586 dsf[c1] = nin/pow(pi*Tin,1.5)*exp(-(pow(cx[j]-uin,2.0)+pow(cy[j]-vin,2.0)+pow(cz[j]-win,2.0))/Tin)+dsfi[c0];
593 void applyInletBC(
const VectorX3& bVelocity,
const X& bTemperature,
const X& Mdot,
const vector<int>& vecReflection)
const
596 applyInletBC(i,bVelocity,bTemperature,Mdot,vecReflection);
603 applyInletBC(i,bVelocity[i],bTemperature[i],Mdot[i],vecReflection);
631 const X Pout = outletPressure;
632 X Pcell= pressure[c0];
638 const X avel2 =gamma*Pcell/density[c0];
639 nout =density[c0]-(Pcell-Pout)/avel2;
640 X ubulk=pow(pow(v[c0][0],2.0)+pow(v[c0][1],2.0)+pow(v[c0][2],2.0),0.5);
641 X ucoeff=1.0/ubulk*(ubulk+(Pcell-Pout)/(pow(2.0*avel2,0.5)*density[c0]));
643 v[c1][0] = v[c0][0]*ucoeff;
646 v[c1][1] = v[c0][1]*ucoeff;
648 v[c1][2] = v[c0][2]*ucoeff;
650 density[c1]=nout; pressure[c1]=Pout;
651 temperature[c1]=Pout/nout;
655 density[c1]=density[c0];
656 pressure[c1]=pressure[c0];
657 temperature[c1]=temperature[c0];
660 for (
int j=0; j<numDirections; j++)
665 const X c_dot_en = cx[j]*en[0]+cy[j]*en[1]+cz[j]*en[2];
668 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]);
671 else{dsf[c1]=dsf[c0];}
681 applyPressureOutletWallBC(i,bTemperature,bPressure);
736 const X Tin = temperature[c0];
737 const X Pin = IntPress[f];
738 const X nin = Pin/Tin;
741 const X u_in=IntVel[f][0];
742 const X v_in=IntVel[f][1];
743 const X w_in=IntVel[f][2];
748 const X rho_init=
_options[
"rho_init"];
750 const X R=8314.0/
_options[
"molecularWeight"];
751 const X nondim_length=
_options[
"nonDimLt"];
752 const X mu0=rho_init*R* T_init*nondim_length/pow(2*R* T_init,0.5);
755 for (
int j=0; j<numDirections; j++)
764 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)
765 *(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])
766 +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]);
void applyDiffuseWallBC(const VectorX3 &bVelocity, const X &bTemperature) const
void applyPressureOutletBC(int f, const X &outletTemperature, const X &outletPressure) const
void applyRealWallBC(const VectorX3 &bVelocity, const X &bTemperature, const X &accomCoeff, const vector< int > &vecReflection) const
const StorageSite & _cells
void applyNSInterfaceBC() const
void applyInletBC(int f, const VectorX3 &InletVelocity, const X &InletTemperature, const X &InletMdot, const vector< int > &vecReflection) const
const Field & _areaMagField
const VectorT3Array & _faceArea
void applyDiffuseWallBC(int f, const VectorX3 &WallVelocity, const X &WallTemperature) const
Vector< T_Scalar, 3 > VectorT3
void applyZeroGradientBC(int f) const
void applyZeroGradientBC() const
void applyPressureOutletBC(const X &bTemperature, const X &bPressure) const
void applyPressureInletBC(int f, const X &inletTemperature, const X &inletPressure) const
void applyRealWallBC(int f, const VectorX3 &WallVelocity, const X &WallTemperature, const X &accommodationCoefficient, const vector< int > &vecReflection) const
Array< VectorX3 > VectorX3Array
KineticModelOptions< X > _options
void applyNSInterfaceBC(int f) const
KineticBoundaryConditions(const StorageSite &faces, const Mesh &mesh, const GeomFields &geomFields, const Quadrature< X > &quadrature, MacroFields ¯oFields, DistFunctFields< X > &dsfPtr)
Array< VectorT3 > VectorT3Array
const StorageSite & _faces
void applySpecularWallBC(int f, const vector< int > &vecReflection) const
const CRConnectivity & _faceCells
void applyPressureOutletBC(const FloatValEvaluator< X > &bTemperature, const FloatValEvaluator< X > &bPresssure) const
void applyInletBC(const VectorX3 &bVelocity, const X &bTemperature, const X &Mdot, const vector< int > &vecReflection) const
const TArray & _faceAreaMag
NumTypeTraits< X >::T_Scalar T_Scalar
StressTensor< X > StressTensorX6
void applyInletBC(const FloatValEvaluator< VectorX3 > &bVelocity, const FloatValEvaluator< X > &bTemperature, const FloatValEvaluator< X > &Mdot, const vector< int > &vecReflection) const
const DistFunctFields< X > & _dsfPtr
void applyRealWallBC(const FloatValEvaluator< VectorX3 > &bVelocity, const FloatValEvaluator< X > &bTemperature, const FloatValEvaluator< X > &accomCoeff, const vector< int > &vecReflection) const
MacroFields & _macroFields
const Quadrature< X > & _quadrature
const Array< int > & _ibType
std::vector< Field * > dsf
int getNthetaCount() const
void applyPressureInletBC(const FloatValEvaluator< X > &bTemperature, const FloatValEvaluator< X > &bPresssure) const
void applySpecularWallBC(const vector< int > &vecReflection) const
void applyDiffuseWallBC(const FloatValEvaluator< VectorX3 > &bVelocity, const FloatValEvaluator< X > &bTemperature) const
Array< StressTensorX6 > StressTensorArray
KineticModelOptions< X > & getOptions()
void applySpecularWallBC_Cartesian(int f) const