5 #ifndef _KINETICMODEL_H_
6 #define _KINETICMODEL_H_
96 const int numMeshes =
_meshes.size();
97 for (
int n=0; n<numMeshes; n++)
125 const int numMeshes =
_meshes.size();
126 for (
int n=0; n<numMeshes; n++)
138 initialVelocity[0] =
_options[
"initialXVelocity"];
139 initialVelocity[1] =
_options[
"initialYVelocity"];
140 initialVelocity[2] =
_options[
"initialZVelocity"];
141 *vCell = initialVelocity;
145 shared_ptr<TArray> pCell(
new TArray(nCells));
146 *pCell =
_options[
"operatingPressure"];
150 shared_ptr<TArray> rhoCell(
new TArray(nCells));
151 *rhoCell = vc[
"density"];
154 shared_ptr<TArray> muCell(
new TArray(nCells));
155 *muCell = vc[
"viscosity"];
159 *tempCell =
_options[
"operatingTemperature"];
163 *collFreqCell = vc[
"viscosity"];
170 initialCoeff[0] = 1.0;
171 initialCoeff[1] = 1.0;
172 initialCoeff[2] = 0.0;
173 initialCoeff[3] = 0.0;
174 initialCoeff[4] = 0.0;
175 *coeffCell = initialCoeff;
181 initialCoeffg[0] = 1.0;
182 initialCoeffg[1] = 1.0;
183 initialCoeffg[2] = 0.0;
184 initialCoeffg[3] = 1.0;
185 initialCoeffg[4] = 0.0;
186 initialCoeffg[5] = 1.0;
187 initialCoeffg[6] = 0.0;
188 initialCoeffg[7] = 0.0;
189 initialCoeffg[8] = 0.0;
190 initialCoeffg[9] = 0.0;
191 *coeffgCell = initialCoeffg;
196 *tempxxCell =
_options[
"operatingTemperature"]/3;
200 *tempyyCell =
_options[
"operatingTemperature"]/3;
204 *tempzzCell =
_options[
"operatingTemperature"]/3;
225 *EntropyGenRateCell = 0.0;
229 *EntropyGenRateColl = 0.0;
234 shared_ptr<VectorT6Array> stressCell(
new VectorT6Array(nCells));
236 initialstress[0] = 1.0;
237 initialstress[1] = 1.0;
238 initialstress[2] = 1.0;
239 initialstress[3] = 0.0;
240 initialstress[4] = 0.0;
241 initialstress[5] = 0.0;
242 *stressCell = initialstress;
270 const int numDirections =
_quadrature.getDirCount();
284 const TArray& faceAreaMag =
dynamic_cast<const TArray &
>(areaMagField[faces]);
288 const VectorT3 en = faceArea[0]/faceAreaMag[0];
289 vector<int> tempVec(numDirections);
291 for (
int j=0; j<numDirections; j++){
292 const T c_dot_en = cx[j]*en[0]+cy[j]*en[1]+cz[j]*en[2];
293 const T cx_incident = cx[j] - 2.0*c_dot_en*en[0];
294 const T cy_incident = cy[j] - 2.0*c_dot_en*en[1];
295 const T cz_incident = cz[j] - 2.0*c_dot_en*en[2];
296 int direction_incident=0;
299 for (
int js=0; js<numDirections; js++){
300 dotprod=pow(cx_incident-cx[js],2)+pow(cy_incident-cy[js],2)+pow(cz_incident-cz[js],2);
301 if (dotprod< Rdotprod){
303 direction_incident=js;}
305 tempVec[j] = direction_incident;
309 const int fgid=fg.
id;
320 InterfaceVelFace ->zero();
324 InterfaceStressFace ->zero();
327 shared_ptr<TArray> InterfacePressFace(
new TArray(Intfaces.
getCount()));
328 *InterfacePressFace =
_options[
"operatingPressure"];
331 shared_ptr<TArray> InterfaceDensityFace(
new TArray(Intfaces.
getCount()));
332 *InterfaceDensityFace =vc[
"density"];
350 {
const int numMeshes =
_meshes.size();
351 for (
int n=0; n<numMeshes; n++)
377 for(
int c=0; c<nCells;c++)
384 pressure[c]=temperature[c]*density[c];
387 coeff[c][0]=density[c]/pow((pi*temperature[c]),1.5);
388 coeff[c][1]=1/temperature[c];
389 coeff[c][2]=0.0;coeff[c][3]=0.0;coeff[c][4]=0.0;
394 coeffg[c][0]=coeff[c][0];
395 coeffg[c][1]=coeff[c][1];
396 coeffg[c][2]=coeff[c][2];
397 coeffg[c][3]=coeff[c][1];
398 coeffg[c][4]=coeff[c][3];
399 coeffg[c][5]=coeff[c][1];
400 coeffg[c][6]=coeff[c][4];
419 const int numMeshes =
_meshes.size();
420 for (
int n=0; n<numMeshes; n++)
439 for(
int c=0; c<nCells;c++)
443 coeff[c][0]=density[c]/pow((pi*temperature[c]),1.5);
444 coeff[c][1]=1/temperature[c];
445 coeff[c][2]=0.0;coeff[c][3]=0.0;coeff[c][4]=0.0;
449 coeffg[c][0]=coeff[c][0];
450 coeffg[c][1]=coeff[c][1];
451 coeffg[c][2]=coeff[c][2];
452 coeffg[c][3]=coeff[c][1];
453 coeffg[c][4]=coeff[c][3];
454 coeffg[c][5]=coeff[c][1];
455 coeffg[c][6]=coeff[c][4];
460 Txx[c]=0.5*temperature[c];
461 Tyy[c]=0.5*temperature[c];
462 Tzz[c]=0.5*temperature[c];
475 const int numMeshes =
_meshes.size();
476 for (
int n=0; n<numMeshes; n++)
498 for(
int c=0; c<nCells;c++)
505 stress[c][0]=0.0;stress[c][1]=0.0;stress[c][2]=0.0;
506 stress[c][3]=0.0;stress[c][4]=0.0;stress[c][5]=0.0;
511 for(
int j=0;j<N123;j++){
514 const TArray& f =
dynamic_cast<const TArray&
>(fnd[cells]);
518 for(
int c=0; c<nCells;c++){
519 density[c] = density[c]+wts[j]*f[c];
520 v[c][0]= v[c][0]+(cx[j]*f[c])*wts[j];
521 v[c][1]= v[c][1]+(cy[j]*f[c])*wts[j];
522 v[c][2]= v[c][2]+(cz[j]*f[c])*wts[j];
523 temperature[c]= temperature[c]+(pow(cx[j],2.0)+pow(cy[j],2.0)
524 +pow(cz[j],2.0))*f[c]*wts[j];
532 for(
int c=0; c<nCells;c++){
533 v[c][0]=v[c][0]/density[c];
534 v[c][1]=v[c][1]/density[c];
535 v[c][2]=v[c][2]/density[c];
536 temperature[c]=temperature[c]-(pow(v[c][0],2.0)
538 +pow(v[c][2],2.0))*density[c];
539 temperature[c]=temperature[c]/(1.5*density[c]);
540 pressure[c]=density[c]*temperature[c];
545 for(
int j=0;j<N123;j++){
547 const TArray& f =
dynamic_cast<const TArray&
>(fnd[cells]);
548 for(
int c=0; c<nCells;c++){
549 stress[c][0] +=pow((cx[j]-v[c][0]),2.0)*f[c]*wts[j];
550 stress[c][1] +=pow((cy[j]-v[c][1]),2.0)*f[c]*wts[j];
551 stress[c][2] +=pow((cz[j]-v[c][2]),2.0)*f[c]*wts[j];
552 stress[c][3] +=(cx[j]-v[c][0])*(cy[j]-v[c][1])*f[c]*wts[j];
553 stress[c][4] +=(cy[j]-v[c][1])*(cz[j]-v[c][2])*f[c]*wts[j];
554 stress[c][5] +=(cz[j]-v[c][2])*(cx[j]-v[c][0])*f[c]*wts[j];
568 const int numMeshes =
_meshes.size();
569 for (
int n=0; n<numMeshes; n++)
596 for(
int c=0; c<nCells;c++)
605 for(
int j=0;j<N123;j++){
608 const TArray& f =
dynamic_cast<const TArray&
>(fnd[cells]);
610 const TArray& fgam =
dynamic_cast<const TArray&
>(fndEq[cells]);
611 for(
int c=0; c<nCells;c++){
612 Txx[c]=Txx[c]+pow(cx[j]-v[c][0],2)*((1-1/Pr)*f[c]+1/Pr*fgam[c])*wts[j];
613 Tyy[c]=Tyy[c]+pow(cy[j]-v[c][1],2)*((1-1/Pr)*f[c]+1/Pr*fgam[c])*wts[j] ;
614 Tzz[c]=Tzz[c]+pow(cz[j]-v[c][2],2)*((1-1/Pr)*f[c]+1/Pr*fgam[c])*wts[j];
619 Txy[c]=Txy[c]+(cx[j]-v[c][0])*(cy[j]-v[c][1])*((1-1/Pr)*f[c]+1/Pr*fgam[c])*wts[j];
620 Tyz[c]=Tyz[c]+(cy[j]-v[c][1])*(cz[j]-v[c][2])*((1-1/Pr)*f[c]+1/Pr*fgam[c])*wts[j];
621 Tzx[c]=Tzx[c]+(cz[j]-v[c][2])*(cx[j]-v[c][0])*((1-1/Pr)*f[c]+1/Pr*fgam[c])*wts[j];
625 for(
int c=0; c<nCells;c++){
626 Txx[c]=Txx[c]/density[c];
627 Tyy[c]=Tyy[c]/density[c];
628 Tzz[c]=Tzz[c]/density[c];
629 Txy[c]=Txy[c]/density[c];
630 Tyz[c]=Tyz[c]/density[c];
631 Tzx[c]=Tzx[c]/density[c];
646 const int numMeshes =
_meshes.size();
647 for (
int n=0; n<numMeshes; n++)
650 const T rho_init=
_options[
"rho_init"];
655 const T R=8314.0/
_options[
"molecularWeight"];
656 const T nondim_length=
_options[
"nonDimLt"];
658 const T mu0=rho_init*R* T_init*nondim_length/pow(2*R* T_init,0.5);
670 for(
int c=0; c<nCells;c++)
672 viscosity[c]= muref*pow(temperature[c]*T_init/ Tmuref,mu_w);
673 collisionFrequency[c]=density[c]*temperature[c]/viscosity[c]*mu0;
677 for(
int c=0; c<nCells;c++)
678 collisionFrequency[c]=
_options.Prandtl*collisionFrequency[c];
685 const int numMeshes =
_meshes.size();
686 for (
int n=0; n<numMeshes; n++)
688 const int Knq_dir=
_options.Knq_direction;
698 const int num_directions =
_quadrature.getDirCount();
700 for(
int j=0;j<num_directions;j++){
702 const TArray& f =
dynamic_cast<const TArray&
>(fnd[cells]);
703 for(
int c=0; c<nCells;c++){
704 Knq[c]=Knq[c]+0.5*f[c]*wts[j]*(pow(cx[j]-v[c][0],3.0)+(cx[j]-v[c][0])*pow(cy[j]-v[c][1],2.0)+(cx[j]-v[c][0])*pow(cz[j]-v[c][2],2.0));
707 else if(Knq_dir ==1){
708 for(
int j=0;j<num_directions;j++){
710 const TArray& f =
dynamic_cast<const TArray&
>(fnd[cells]);
711 for(
int c=0; c<nCells;c++){
712 Knq[c]=Knq[c]+0.5*f[c]*wts[j]*(pow(cy[j]-v[c][1],3.0)+(cy[j]-v[c][1])*pow(cx[j]-v[c][0],2.0)+(cy[j]-v[c][1])*pow(cz[j]-v[c][2],2.0));
716 else if(Knq_dir ==2){
717 for(
int j=0;j<num_directions;j++){
719 const TArray& f =
dynamic_cast<const TArray&
>(fnd[cells]);
720 for(
int c=0; c<nCells;c++){
721 Knq[c]=Knq[c]+0.5*f[c]*wts[j]*(pow(cz[j]-v[c][2],3.0)+(cz[j]-v[c][2])*pow(cx[j]-v[c][0],2.0)+(cz[j]-v[c][2])*pow(cy[j]-v[c][1],2.0));
727 const int numMeshes =
_meshes.size();
728 for (
int n=0; n<numMeshes; n++)
730 const T rho_init=
_options[
"rho_init"];
732 const T molwt=
_options[
"molecularWeight"]*1E-26/6.023;
733 const T R=8314.0/
_options[
"molecularWeight"];
734 const T u_init=pow(2.0*R*T_init,0.5);
736 const T h3bm4u3=pow(Planck,3)/ pow(molwt,4)*rho_init/pow(u_init,3);
746 for(
int c=0; c<nCells;c++){
747 Entropy[c]=0.0;EntropyGenRate_Collisional[c]=0.0;
749 const int num_directions =
_quadrature.getDirCount();
751 for(
int j=0;j<num_directions;j++){
754 const TArray& f =
dynamic_cast<const TArray&
>(fnd[cells]);
755 const TArray& fgam =
dynamic_cast<const TArray&
>(feqES[cells]);
756 for(
int c=0; c<nCells;c++){
757 Entropy[c]=Entropy[c]+f[c]*wts[j]*(1-log(h3bm4u3*f[c]));
758 EntropyGenRate_Collisional[c]+= (f[c]-fgam[c])*collisionFrequency[c]*log(h3bm4u3*f[c])*wts[j];
763 for(
int j=0;j<num_directions;j++){
766 const TArray& f =
dynamic_cast<const TArray&
>(fnd[cells]);
767 const TArray& fgam =
dynamic_cast<const TArray&
>(feq[cells]);
768 for(
int c=0; c<nCells;c++){
769 Entropy[c]=Entropy[c]+f[c]*wts[j]*(1-log(h3bm4u3*f[c]));
770 EntropyGenRate_Collisional[c]+=(f[c]-fgam[c])*collisionFrequency[c]*(log(h3bm4u3*f[c]))*wts[j];
781 const int numMeshes =
_meshes.size();
782 for (
int n=0; n<numMeshes; n++)
796 for(
int j=0;j< numFields;j++){
799 for(
int c=0; c<nCells;c++){
800 fEq[c]=coeff[c][0]*exp(-coeff[c][1]*(pow(cx[j]-v[c][0],2)+pow(cy[j]-v[c][1],2)
801 +pow(cz[j]-v[c][2],2))+coeff[c][2]*(cx[j]-v[c][0])
802 +coeff[c][3]*(cy[j]-v[c][1])+coeff[c][4]*(cz[j]-v[c][2]));
808 for(
int j=0;j< numFields;j++){
811 for(
int c=0; c<nCells;c++){
812 T Cc1=(cx[j]-v[c][0]);
813 T Cc2=(cy[j]-v[c][1]);
814 T Cc3=(cz[j]-v[c][2]);
815 fEqES[c]=coeffg[c][0]*exp(-coeffg[c][1]*pow(Cc1,2)+coeffg[c][2]*Cc1
816 -coeffg[c][3]*pow(Cc2,2)+coeffg[c][4]*Cc2
817 -coeffg[c][5]*pow(Cc3,2)+coeffg[c][6]*Cc3
818 +coeffg[c][7]*cx[j]*cy[j]+coeffg[c][8]*cy[j]*cz[j]
819 +coeffg[c][9]*cz[j]*cx[j]);
831 const int numMeshes =
_meshes.size();
832 for (
int n=0; n<numMeshes; n++)
835 const T tolx=
_options[
"ToleranceX"];
836 const T tolf=
_options[
"ToleranceF"];
848 for(
int c=0; c<nCells;c++){
850 for (
int trial=0;trial<ktrial;trial ++){
857 fvec[1]=density[c]*v[c][0];
858 fvec[2]=density[c]*v[c][1];
859 fvec[3]=density[c]*v[c][2];
860 fvec[4]=1.5*density[c]*temperature[c]+density[c]*(pow(v[c][0],2)+pow(v[c][1],2)+pow(v[c][2],2.0));
867 for (
int row=0;row<sizeC;row++){errf+=
fabs(fvec[row]);}
872 for (
int row=0;row<sizeC;row++){pvec[row]=-fvec[row];}
882 for (
int row=0;row<sizeC;row++){
884 for (
int col=0;col<sizeC;col++){
885 xvec[row]+=fjacinv(row,col)*pvec[col];}
890 for (
int row=0;row<sizeC;row++){
891 errx +=
fabs(xvec[row]);
892 coeff[c][row]+= xvec[row];
909 const int ktrial=
_options.NewtonsMethod_ktrial;
910 const int numMeshes =
_meshes.size();
911 for (
int n=0; n<numMeshes; n++)
944 for(
int j=0;j< numFields;j++){
947 for(
int c=0; c<nCells;c++){
948 fEq[c]=coeff[c][0]*exp(-coeff[c][1]*(pow(cx[j]-v[c][0],2)+pow(cy[j]-v[c][1],2)
949 +pow(cz[j]-v[c][2],2))+coeff[c][2]*(cx[j]-v[c][0])
950 +coeff[c][3]*(cy[j]-v[c][1])+coeff[c][4]*(cz[j]-v[c][2]));
971 for(
int j=0;j< numFields;j++){
972 T Cconst=pow(cx[j]-v[0],2.0)+pow(cy[j]-v[1],2.0)+pow(cz[j]-v[2],2.0);
973 T Econst=xn[0]*exp(-xn[1]*Cconst+xn[2]*(cx[j]-v[0])+xn[3]*(cy[j]-v[1])+xn[4]*(cz[j]-v[2]))*wts[j];
975 for (
int row=0;row<5;row++){
976 fvec[row]+= -Econst*malphaBGK(j,row);
981 mexp[0]=-Econst/xn[0];
982 mexp[1]=Econst*Cconst;
983 mexp[2]=-Econst*(cx[j]-v[0]);
984 mexp[3]=-Econst*(cy[j]-v[1]);
985 mexp[4]=-Econst*(cz[j]-v[2]);
986 for (
int row=0;row<5;row++){
987 for (
int col=0;col<5;col++){
988 fjac(row,col)+=malphaBGK(j,row)*mexp[col];
1002 const int numMeshes =
_meshes.size();
1003 for (
int n=0; n<numMeshes; n++)
1005 const T tolx=
_options[
"ToleranceX"];
1006 const T tolf=
_options[
"ToleranceF"];
1025 for(
int c=0; c<nCells;c++){
1027 for (
int trial=0;trial<ktrial;trial ++){
1034 fvec[1]=density[c]*v[c][0];
1035 fvec[2]=density[c]*v[c][1];
1036 fvec[3]=density[c]*v[c][2];
1037 fvec[4]=density[c]*(pow(v[c][0],2)+Txx[c]);
1038 fvec[5]=density[c]*(pow(v[c][1],2)+Tyy[c]);
1039 fvec[6]=density[c]*(pow(v[c][2],2)+Tzz[c]);
1040 fvec[7]=density[c]*(v[c][0]*v[c][1]+Txy[c]);
1041 fvec[8]=density[c]*(v[c][1]*v[c][2]+Tyz[c]);
1042 fvec[9]=density[c]*(v[c][2]*v[c][0]+Tzx[c]);
1050 for (
int row=0;row<sizeC;row++){errf+=
fabs(fvec[row]);}
1054 for (
int row=0;row<sizeC;row++){pvec[row]=-fvec[row];}
1061 for (
int row=0;row<sizeC;row++){
1063 for (
int col=0;col<sizeC;col++){
1064 xvec[row]+=fjacinv(row,col)*pvec[col];
1099 for (
int row=0;row<sizeC;row++){
1100 errx +=
fabs(xvec[row]);
1101 coeffg[c][row]+= xvec[row];
1115 const int ktrial=
_options.NewtonsMethod_ktrial;
1116 const int numMeshes =
_meshes.size();
1117 for (
int n=0; n<numMeshes; n++)
1149 for(
int j=0;j< numFields;j++){
1151 TArray& fEqES =
dynamic_cast< TArray&
>(fndEqES[cells]);
1152 for(
int c=0; c<nCells;c++){
1153 T Cc1=(cx[j]-v[c][0]);
1154 T Cc2=(cy[j]-v[c][1]);
1155 T Cc3=(cz[j]-v[c][2]);
1156 fEqES[c]=coeffg[c][0]*exp(-coeffg[c][1]*pow(Cc1,2)+coeffg[c][2]*Cc1
1157 -coeffg[c][3]*pow(Cc2,2)+coeffg[c][4]*Cc2
1158 -coeffg[c][5]*pow(Cc3,2)+coeffg[c][6]*Cc3
1159 +coeffg[c][7]*cx[j]*cy[j]+coeffg[c][8]*cy[j]*cz[j]
1160 +coeffg[c][9]*cz[j]*cx[j]);
1178 for(
int j=0;j< numFields;j++){
1182 T Econst=xn[0]*exp(-xn[1]*pow(Cc1,2)+xn[2]*Cc1-xn[3]*pow(Cc2,2)+ xn[4]*Cc2
1183 -xn[5]*pow(Cc3,2)+xn[6]*Cc3
1184 +xn[7]*cx[j]*cy[j]+xn[8]*cy[j]*cz[j]+xn[9]*cz[j]*cx[j])*wts[j];
1186 for (
int row=0;row<10;row++){
1187 fvec[row]+= -Econst*malphaESBGK(j,row);
1190 mexp[0]=-Econst/xn[0];
1191 mexp[1]=Econst*pow(Cc1,2);
1192 mexp[2]=-Econst*Cc1;
1193 mexp[3]=Econst*pow(Cc2,2);
1194 mexp[4]=-Econst*Cc2;
1195 mexp[5]=Econst*pow(Cc3,2);
1196 mexp[6]=-Econst*Cc3;
1198 mexp[7]=-Econst*cx[j]*cy[j];
1199 mexp[8]=-Econst*cy[j]*cz[j];
1200 mexp[9]=-Econst*cz[j]*cx[j];
1202 for (
int row=0;row<10;row++){
1203 for (
int col=0;col<10;col++){
1204 fjac(row,col)+=malphaESBGK(j,row)*mexp[col];
1218 const int numMeshes =
_meshes.size();
1219 for (
int n=0; n<numMeshes; n++)
1235 for(
int j=0;j< numFields;j++){
1238 for(
int c=0; c<nCells;c++){
1239 f[c]=density[c]/pow((pi*temperature[c]),1.5)*
1240 exp(-(pow((cx[j]-v[c][0]),2.0)+pow((cy[j]-v[c][1]),2.0)+
1241 pow((cz[j]-v[c][2]),2.0))/temperature[c]);
1252 for (
int c=0;c<nCells;c++)
1255 if (
_options.timeDiscretizationOrder > 1)
1259 for (
int c=0;c<nCells;c++)
1269 void weightedMaxwellian(
double weight1,
double uvel1,
double vvel1,
double wvel1,
double uvel2,
double vvel2,
double wvel2,
double temp1,
double temp2)
1271 const int numMeshes =
_meshes.size();
1272 for (
int n=0; n<numMeshes; n++)
1284 for(
int j=0;j< numFields;j++){
1287 for(
int c=0; c<nCells;c++){
1288 f[c]=weight1*1.0/pow((pi*1.0),1.5)*exp(-(pow((cx[j]-uvel1),2.0)+pow((cy[j]-vvel1),2.0)+pow((cz[j]-wvel1),2.0))/temp1)
1289 +(1-weight1)*1.0/pow((pi*1.0),1.5)*exp(-(pow((cx[j]-uvel2),2.0)+pow((cy[j]-vvel2),2.0)+pow((cz[j]-wvel2),2.0))/temp2);
1295 for (
int c=0;c<nCells;c++)
1298 if (
_options.timeDiscretizationOrder > 1)
1302 for (
int c=0;c<nCells;c++)
1311 const double vvel1=0.0;
1312 const double wvel1=0.0;
1313 const double vvel2=0.0;
1314 const double wvel2=0.0;
1315 const int numMeshes =
_meshes.size();
1316 for (
int n=0; n<numMeshes; n++)
1328 for(
int j=0;j< numFields;j++){
1331 for(
int c=0; c<nCells;c++){
1332 f[c]=weight1*1.0/pow((pi*1.0),1.5)*exp(-(pow((cx[j]-uvel1),2.0)+pow((cy[j]-vvel1),2.0)+pow((cz[j]-wvel1),2.0))/temp1)
1333 +(1-weight1)*1.0/pow((pi*1.0),1.5)*exp(-(pow((cx[j]-uvel2),2.0)+pow((cy[j]-vvel2),2.0)+pow((cz[j]-wvel2),2.0))/temp2);
1339 for (
int c=0;c<nCells;c++)
1342 if (
_options.timeDiscretizationOrder > 1)
1346 for (
int c=0;c<nCells;c++)
1362 map<string,shared_ptr<ArrayBase> >&
1410 const int numMeshes =
_meshes.size();
1411 for (
int n=0; n<numMeshes; n++)
1432 bc->
bcType =
"RealWallBC";
1434 else if (fg.
groupType ==
"velocity-inlet")
1436 bc->
bcType =
"VelocityInletBC";
1438 else if (fg.
groupType ==
"pressure-inlet")
1440 bc->
bcType =
"PressureInletBC";
1442 else if (fg.
groupType ==
"pressure-outlet")
1444 bc->
bcType =
"PressureOutletBC";
1448 bc->
bcType =
"SymmetryBC";
1451 else if((fg.
groupType ==
"zero-gradient "))
1453 bc->
bcType =
"ZeroGradBC";
1456 throw CException(
"KineticModel: unknown face group type "
1482 const int numMeshes =
_meshes.size();
1483 for (
int n=0; n<numMeshes; n++)
1522 shared_ptr<Discretization>
1527 discretizations.push_back(sdEQ);}
1530 shared_ptr<Discretization>
1535 discretizations.push_back(sd);
1539 shared_ptr<Discretization>
1551 discretizations.push_back(cd);
1561 shared_ptr<Discretization>
1567 _options.timeDiscretizationOrder));
1569 discretizations.push_back(td);
1573 shared_ptr<Discretization>
1580 discretizations.push_back(ibm);
1590 const int numMeshes =
_meshes.size();
1591 for (
int n=0; n<numMeshes; n++)
1600 const int nFaces = faces.
getCount();
1614 const TArray& faceAreaMag =
dynamic_cast<const TArray &
>(areaMagField[faces]);
1619 bVelocity(bc.
getVal(
"specifiedXVelocity"),
1620 bc.
getVal(
"specifiedYVelocity"),
1621 bc.
getVal(
"specifiedZVelocity"),
1624 if (( bc.
bcType ==
"ZeroGradBC"))
1626 for(
int f=0; f< nFaces; f++)
1627 {
const int c1= faceCells(f,1);
1629 gkbc.applyDirichletBC(f,bvalue);
1633 else if (( bc.
bcType ==
"VelocityInletBC")){
1634 for(
int f=0; f< nFaces; f++)
1636 const VectorT3 en = faceArea[f]/faceAreaMag[f];
1637 const T c_dot_en = cx[direction]*en[0]+cy[direction]*en[1]+cz[direction]*en[2];
1640 {
const int c1= faceCells(f,1);
1642 gkbc.applyDirichletBC(f,bvalue);
1646 gkbc.applyExtrapolationBC(f);
1653 for(
int f=0; f< nFaces; f++)
1655 const VectorT3 en = faceArea[f]/faceAreaMag[f];
1656 const T c_dot_en = cx[direction]*en[0]+cy[direction]*en[1]+cz[direction]*en[2];
1657 const VectorT3 WallVelocity = bVelocity[f];
1658 const T uwall = WallVelocity[0];
const T vwall = WallVelocity[1];
1659 const T wwall = WallVelocity[2];
const T wallV_dot_en = uwall*en[0]+vwall*en[1]+wwall*en[2];
1660 if(c_dot_en -wallV_dot_en <
T_Scalar(epsilon))
1662 {
const int c1= faceCells(f,1);
1664 gkbc.applyDirichletBC(f,bvalue);
1668 gkbc.applyExtrapolationBC(f);
1682 const int nFaces = faces.
getCount();
1691 for(
int f=0; f< nFaces; f++)
1706 const int numMeshes =
_meshes.size();
1708 for (
int direction = 0; direction < numFields; direction++)
1712 dynamic_cast<const TArray&
>(fnd[solidFaces]);
1714 MPI::COMM_WORLD.Allreduce( MPI::IN_PLACE,pV.
getData(),solidFaces.
getCount() , MPI::DOUBLE, MPI::SUM);
1717 for (
int n=0; n<numMeshes; n++)
1726 const IMatrix& mIC =
1727 dynamic_cast<const IMatrix&
>
1734 const IMatrix& mIP =
1735 dynamic_cast<const IMatrix&
>
1744 dynamic_cast<const TArray&
>(fnd[cells]);
1748 mICV.multiplyAndAdd(*ibV,cV);
1749 mIPV.multiplyAndAdd(*ibV,pV);
1753 stringstream ss(stringstream::in | stringstream::out);
1754 ss << MPI::COMM_WORLD.Get_rank();
1755 string fname1 =
"IBVelocity_proc" + ss.str() +
".dat";
1756 debugFile.open(fname1.c_str());
1763 const double angV = 1.0;
1769 for(
int f=0; f<ibFaces.
getCount();f++){
1770 int fID = ibFaceList[f];
1771 debugFile <<
"f=" << f << setw(10) <<
" fID = " << fID <<
" faceCentroid = " << faceCentroid[fID] <<
" ibV = " << (*ibV)[f] << endl;
1781 for (
int n=0; n<numMeshes; n++)
1790 const IMatrix& mIC =
1791 dynamic_cast<const IMatrix&
>
1794 IMatrixV3 mICV3(mIC);
1797 const IMatrix& mIP =
1798 dynamic_cast<const IMatrix&
>
1801 IMatrixV3 mIPV3(mIP);
1814 mICV3.multiplyAndAdd(*ibVvel,cVel);
1815 mIPV3.multiplyAndAdd(*ibVvel,sVel);
1824 const int numMeshes =
_meshes.size();
1825 const int nSolidFaces = solidFaces.
getCount();
1827 shared_ptr<TArray> muSolid(
new TArray(nSolidFaces));
1831 shared_ptr<TArray> nueSolid(
new TArray(nSolidFaces));
1835 const T rho_init=
_options[
"rho_init"];
1836 const T T_init=
_options[
"T_init"];
1838 const T Tmuref=
_options[
"Tmuref"];
1840 const T R=8314.0/
_options[
"molecularWeight"];
1841 const T nondim_length=
_options[
"nonDimLt"];
1843 const T mu0=rho_init*R* T_init*nondim_length/pow(2*R* T_init,0.5);
1850 for(
int c=0; c<nSolidFaces;c++)
1852 viscosity[c]= muref*pow(temperature[c]*T_init/ Tmuref,mu_w);
1853 collisionFrequency[c]=density[c]*temperature[c]/viscosity[c]*mu0;
1857 for(
int c=0; c<nSolidFaces;c++)
1858 collisionFrequency[c]=
_options.Prandtl*collisionFrequency[c];
1864 for (
int n=0; n<numMeshes; n++)
1873 const IMatrix& mIC =
1874 dynamic_cast<const IMatrix&
>
1878 IMatrixV3 mICV3(mIC);
1881 const IMatrix& mIP =
1882 dynamic_cast<const IMatrix&
>
1886 IMatrixV3 mIPV3(mIP);
1916 mICV.multiplyAndAdd(*ibVnue,cNue);
1917 mIPV.multiplyAndAdd(*ibVnue,sNue);
1920 mICV.multiplyAndAdd(*ibVtemp,cTemp);
1921 mIPV.multiplyAndAdd(*ibVtemp,sTemp);
1924 mICV.multiplyAndAdd(*ibVdensity,cDensity);
1925 mIPV.multiplyAndAdd(*ibVdensity,sDensity);
1928 mICV3.multiplyAndAdd(*ibVvel,cVel);
1929 mIPV3.multiplyAndAdd(*ibVvel,sVel);
1936 const int f_out = 3;
1939 const int numMeshes =
_meshes.size();
1940 for (
int n=0; n<numMeshes; n++)
1944 const int numDirections =
_quadrature.getDirCount();
1946 const int nibFaces=ibFaces.
getCount();
1952 const TArray& ibDensity =
1955 for (
int j=0; j<numDirections; j++)
1957 shared_ptr<TArray> ibFndPtrEqES(
new TArray(nibFaces));
1958 TArray& ibFndEqES= *ibFndPtrEqES;
1959 ibFndPtrEqES->
zero();
1962 for (
int i=0; i<nibFaces; i++)
1967 const T ibu = ibVel[i][0];
1968 const T ibv = ibVel[i][1];
1969 const T ibw = ibVel[i][2];
1970 ibFndEqES[i]=ibDensity[i]/pow(pi*ibTemp[i],1.5)*exp(-(pow(cx[j]-ibu,2.0)+pow(cy[j]-ibv,2.0)+pow(cz[j]-ibw,2.0))/ibTemp[i]);
1972 fndEqES.
addArray(ibFaces,ibFndPtrEqES);
1980 for (
int n=0; n<numMeshes; n++)
1983 for (
int direction = 0; direction < numFields; direction++)
1993 const IMatrix& mIC =
1994 dynamic_cast<const IMatrix&
>
2000 const IMatrix& mIP =
2001 dynamic_cast<const IMatrix&
>
2009 dynamic_cast<const TArray&
>(fndEqES[cells]);
2014 mICV.multiplyAndAdd(*ibVf,cf);
2022 for (
int n=0; n<numMeshes; n++)
2024 const int numDirections =
_quadrature.getDirCount();
2025 for (
int j=0; j<numDirections; j++)
2038 TArray& dsfEqES =
dynamic_cast< TArray&
>(fndEqES[ibFaces]);
2048 const int nibFaces = ibFaces.
getCount();
2049 const int nFaces = faces.
getCount();
2055 for(
int f=0; f<nibFaces; f++)
2058 double distIBSolidInvSum(0.0);
2059 for(
int nc = sFCRow[f]; nc<sFCRow[f+1]; nc++)
2061 const int c = sFCCol[nc];
2062 const int faceIB= ibFaceIndices[f];
2068 double distIBSolid (0.0);
2070 distIBSolid =
sqrt(pow((faceCentroid[faceIB][0]-solidFaceCentroid[c][0]),2)+
2071 pow((faceCentroid[faceIB][1]-solidFaceCentroid[c][1]),2)+
2072 pow((faceCentroid[faceIB][2]-solidFaceCentroid[c][2]),2));
2073 distIBSolidInvSum += 1/pow(distIBSolid,RelaxDistribution);
2075 for(
int nc = sFCRow[f]; nc<sFCRow[f+1]; nc++)
2077 const int c = sFCCol[nc];
2084 const int faceIB= ibFaceIndices[f];
2086 double time_to_wall (0.0);
2087 double distIBSolid (0.0);
2088 const T uwall = v[c][0];
2089 const T vwall = v[c][1];
2090 const T wwall = v[c][2];
2092 distIBSolid =
sqrt(pow((faceCentroid[faceIB][0]-solidFaceCentroid[c][0]),2)+
2093 pow((faceCentroid[faceIB][1]-solidFaceCentroid[c][1]),2)+
2094 pow((faceCentroid[faceIB][2]-solidFaceCentroid[c][2]),2));
2095 time_to_wall = -1*(pow(distIBSolid,2)/((cx[j]-uwall)*(faceCentroid[faceIB][0]-solidFaceCentroid[c][0])+(cy[j]-vwall)*(faceCentroid[faceIB][1]-solidFaceCentroid[c][1])+(cz[j]-wwall)*(faceCentroid[faceIB][2]-solidFaceCentroid[c][2])));
2099 dsfIB[f] += (dsfEqES[f]-(dsfEqES[f]-dsf[c])*exp(-time_to_wall*nue[f]))/(pow(distIBSolid,RelaxDistribution)*distIBSolidInvSum);
2109 const int numMeshes =
_meshes.size();
2110 for (
int n=0; n<numMeshes; n++)
2119 const IMatrix& mIC =
2120 dynamic_cast<const IMatrix&
>
2123 IMatrixV3 mICV3(mIC);
2126 const IMatrix& mIP =
2127 dynamic_cast<const IMatrix&
>
2130 IMatrixV3 mIPV3(mIP);
2143 mICV3.multiplyAndAdd(*ibVvel,cVel);
2144 mIPV3.multiplyAndAdd(*ibVvel,sVel);
2150 const int nSolidFaces = solidFaces.
getCount();
2152 shared_ptr<TArray> muSolid(
new TArray(nSolidFaces));
2156 shared_ptr<TArray> nueSolid(
new TArray(nSolidFaces));
2160 const T rho_init=
_options[
"rho_init"];
2161 const T T_init=
_options[
"T_init"];
2163 const T Tmuref=
_options[
"Tmuref"];
2165 const T R=8314.0/
_options[
"molecularWeight"];
2166 const T nondim_length=
_options[
"nonDimLt"];
2168 const T mu0=rho_init*R* T_init*nondim_length/pow(2*R* T_init,0.5);
2175 for(
int c=0; c<nSolidFaces;c++)
2177 viscosity[c]= muref*pow(temperature[c]*T_init/ Tmuref,mu_w);
2178 collisionFrequency[c]=density[c]*temperature[c]/viscosity[c]*mu0;
2182 for(
int c=0; c<nSolidFaces;c++)
2183 collisionFrequency[c]=
_options.Prandtl*collisionFrequency[c];
2188 for (
int direction = 0; direction < numFields; direction++)
2193 for (
int n=0; n<numMeshes; n++)
2202 const IMatrix& mIC =
2203 dynamic_cast<const IMatrix&
>
2209 dynamic_cast<const TArray&
>(fndEqES[cells]);
2214 mICV.multiplyAndAdd(*ibVf,cf);
2219 for (
int n=0; n<numMeshes; n++)
2221 const int numDirections =
_quadrature.getDirCount();
2222 for (
int j=0; j<numDirections; j++)
2227 TArray& dsfEqES =
dynamic_cast< TArray&
>(fndEqES[solidFaces]);
2229 MPI::COMM_WORLD.Allreduce( MPI::IN_PLACE,dsf.
getData(),solidFaces.
getCount() , MPI::DOUBLE, MPI::SUM);
2230 MPI::COMM_WORLD.Allreduce( MPI::IN_PLACE,dsfEqES.
getData(),solidFaces.
getCount() , MPI::DOUBLE, MPI::SUM);
2245 const int nibFaces = ibFaces.
getCount();
2246 const int nFaces = faces.
getCount();
2254 for(
int f=0; f<nibFaces; f++)
2256 double distIBSolidInvSum(0.0);
2257 for(
int nc = sFCRow[f]; nc<sFCRow[f+1]; nc++)
2259 const int c = sFCCol[nc];
2260 const int faceIB= ibFaceIndices[f];
2266 double distIBSolid (0.0);
2268 distIBSolid =
sqrt(pow((faceCentroid[faceIB][0]-solidFaceCentroid[c][0]),2)+
2269 pow((faceCentroid[faceIB][1]-solidFaceCentroid[c][1]),2)+
2270 pow((faceCentroid[faceIB][2]-solidFaceCentroid[c][2]),2));
2271 distIBSolidInvSum += 1/pow(distIBSolid,RelaxDistribution);
2273 for(
int nc = sFCRow[f]; nc<sFCRow[f+1]; nc++)
2275 const int c = sFCCol[nc];
2284 const int faceIB= ibFaceIndices[f];
2285 const T uwall = v[c][0];
2286 const T vwall = v[c][1];
2287 const T wwall = v[c][2];
2289 double time_to_wall (0.0);
2290 double distIBSolid (0.0);
2292 distIBSolid =
sqrt(pow((faceCentroid[faceIB][0]-solidFaceCentroid[c][0]),2)+
2293 pow((faceCentroid[faceIB][1]-solidFaceCentroid[c][1]),2)+
2294 pow((faceCentroid[faceIB][2]-solidFaceCentroid[c][2]),2));
2295 time_to_wall = -1*(pow(distIBSolid,2)/((cx[j]-uwall)*(faceCentroid[faceIB][0]-solidFaceCentroid[c][0])+(cy[j]-vwall)*(faceCentroid[faceIB][1]-solidFaceCentroid[c][1])+(cz[j]-wwall)*(faceCentroid[faceIB][2]-solidFaceCentroid[c][2])));
2298 ibVfA[f] += (dsfEqES[c]-(dsfEqES[c]-dsf[c])*exp(-time_to_wall*nue[c]))/(pow(distIBSolid,RelaxDistribution)*distIBSolidInvSum);
2313 const int numMeshes =
_meshes.size();
2314 for (
int n=0; n<numMeshes; n++)
2324 const IMatrix& mIC =
2325 dynamic_cast<const IMatrix&
>
2337 mICV.multiplyAndAdd(*ibP,cP);
2343 MPI::COMM_WORLD.Allreduce( MPI::IN_PLACE,pressure.
getData(),solidFaces.
getCount() , MPI::DOUBLE, MPI::SUM);
2353 const int numMeshes =
_meshes.size();
2354 for (
int direction = 0; direction < numFields; direction++) {
2358 for (
int n=0; n<numMeshes; n++)
2367 const IMatrix& mIC =
2368 dynamic_cast<const IMatrix&
>
2373 dynamic_cast<const TArray&
>(fnd[cells]);
2377 mICV.multiplyAndAdd(*ibV,cV);
2380 stringstream ss(stringstream::in | stringstream::out);
2381 ss << MPI::COMM_WORLD.Get_rank();
2382 string fname1 =
"IBVelocity_proc" + ss.str() +
".dat";
2383 debugFile.open(fname1.c_str());
2390 const double angV = 1.0;
2396 for(
int f=0; f<ibFaces.getCount();f++){
2397 int fID = ibFaceList[f];
2398 debugFile <<
"f=" << f << setw(10) <<
" fID = " << fID <<
" faceCentroid = " << faceCentroid[fID] <<
" ibV = " << (*ibV)[f] << endl;
2412 const int numMeshes =
_meshes.size();
2413 for (
int n=0; n<numMeshes; n++)
2418 for (
int direction = 0; direction < numFields; direction++)
2430 const IMatrix& mIC =
2431 dynamic_cast<const IMatrix&
>
2437 dynamic_cast<const TArray&
>(fnd[cells]);
2439 dynamic_cast<const TArray&
>(fndEqES[cells]);
2447 mICV.multiplyAndAdd(*ibVfEq,cfEq);
2450 mICV.multiplyAndAdd(*ibVf,cf);
2456 const int nSolidFaces = solidFaces.
getCount();
2458 shared_ptr<TArray> muSolid(
new TArray(nSolidFaces));
2462 shared_ptr<TArray> nueSolid(
new TArray(nSolidFaces));
2466 const T rho_init=
_options[
"rho_init"];
2467 const T T_init=
_options[
"T_init"];
2469 const T Tmuref=
_options[
"Tmuref"];
2471 const T R=8314.0/
_options[
"molecularWeight"];
2472 const T nondim_length=
_options[
"nonDimLt"];
2474 const T mu0=rho_init*R* T_init*nondim_length/pow(2*R* T_init,0.5);
2481 for(
int c=0; c<nSolidFaces;c++)
2483 viscosity[c]= muref*pow(temperature[c]*T_init/ Tmuref,mu_w);
2484 collisionFrequency[c]=density[c]*temperature[c]/viscosity[c]*mu0;
2488 for(
int c=0; c<nSolidFaces;c++)
2489 collisionFrequency[c]=
_options.Prandtl*collisionFrequency[c];
2493 for (
int n=0; n<numMeshes; n++)
2502 const IMatrix& mIC =
2503 dynamic_cast<const IMatrix&
>
2507 IMatrixV3 mICV3(mIC);
2510 const IMatrix& mIP =
2511 dynamic_cast<const IMatrix&
>
2515 IMatrixV3 mIPV3(mIP);
2545 mICV.multiplyAndAdd(*ibVnue,cNue);
2546 mIPV.multiplyAndAdd(*ibVnue,sNue);
2549 mICV.multiplyAndAdd(*ibVtemp,cTemp);
2550 mIPV.multiplyAndAdd(*ibVtemp,sTemp);
2553 mICV.multiplyAndAdd(*ibVdensity,cDensity);
2554 mIPV.multiplyAndAdd(*ibVdensity,sDensity);
2557 mICV3.multiplyAndAdd(*ibVvel,cVel);
2558 mIPV3.multiplyAndAdd(*ibVvel,sVel);
2567 const int numMeshes =
_meshes.size();
2568 for (
int n=0; n<numMeshes; n++)
2572 const int numDirections =
_quadrature.getDirCount();
2574 const int nibFaces=ibFaces.
getCount();
2580 const TArray& ibDensity =
2583 for (
int j=0; j<numDirections; j++)
2585 shared_ptr<TArray> ibFndPtrEqES(
new TArray(nibFaces));
2586 TArray& ibFndEqES= *ibFndPtrEqES;
2588 ibFndPtrEqES->
zero();
2592 for (
int i=0; i<nibFaces; i++)
2597 const T ibu = ibVel[i][0];
2598 const T ibv = ibVel[i][1];
2599 const T ibw = ibVel[i][2];
2600 ibFndEqES[i]=ibDensity[i]/pow(pi*ibTemp[i],1.5)*exp(-(pow(cx[j]-ibu,2.0)+pow(cy[j]-ibv,2.0)+pow(cz[j]-ibw,2.0))/ibTemp[i]);
2602 fndEqES.
addArray(ibFaces,ibFndPtrEqES);
2609 const int numDirections =
_quadrature.getDirCount();
2610 for (
int j=0; j<numDirections; j++)
2612 const int nSolidFaces = solidFaces.
getCount();
2613 shared_ptr<TArray> solidFndPtr(
new TArray(nSolidFaces));
2614 solidFndPtr->zero();
2615 TArray& solidFnd= *solidFndPtr;
2621 for (
int n=0; n<numMeshes; n++)
2632 TArray& dsfEqES =
dynamic_cast< TArray&
>(fndEqES[ibFaces]);
2635 for(
int f=0; f<nSolidFaces; f++)
2637 double distIBSolidInvSum(0.0);
2638 for(
int nc = sFCRow[f]; nc<sFCRow[f+1]; nc++)
2641 const int c = sFCCol[nc];
2642 const int faceIB= ibFaceIndices[c];
2648 double distIBSolid (0.0);
2650 distIBSolid =
sqrt(pow((faceCentroid[faceIB][0]-solidFaceCentroid[f][0]),2)+
2651 pow((faceCentroid[faceIB][1]-solidFaceCentroid[f][1]),2)+
2652 pow((faceCentroid[faceIB][2]-solidFaceCentroid[f][2]),2));
2653 distIBSolidInvSum += 1/pow(distIBSolid,RelaxDistribution);
2655 for(
int nc = sFCRow[f]; nc<sFCRow[f+1]; nc++)
2657 const int c = sFCCol[nc];
2663 const int faceIB= ibFaceIndices[c];
2664 T time_to_wall (0.0);
2665 T distIBSolid (0.0);
2666 distIBSolid =
sqrt(pow((faceCentroid[faceIB][0]-solidFaceCentroid[f][0]),2)+
2667 pow((faceCentroid[faceIB][1]-solidFaceCentroid[f][1]),2)+
2668 pow((faceCentroid[faceIB][2]-solidFaceCentroid[f][2]),2));
2670 const T uwall = v[f][0];
2671 const T vwall = v[f][1];
2672 const T wwall = v[f][2];
2675 time_to_wall = (pow(distIBSolid,2)/((cx[j]-uwall)*(faceCentroid[faceIB][0]-solidFaceCentroid[f][0])+(cy[j]-vwall)*(faceCentroid[faceIB][1]-solidFaceCentroid[f][1])+(cz[j]-wwall)*(faceCentroid[faceIB][2]-solidFaceCentroid[f][2])));
2679 solidFnd[f] += (dsfEqES[c]-(dsfEqES[c]-dsf[c])*exp(-time_to_wall*nue[c]))/(pow(distIBSolid,RelaxDistribution)*distIBSolidInvSum);
2685 fnd.
addArray(solidFaces,solidFndPtr);
2689 const int numDirections =
_quadrature.getDirCount();
2690 for (
int j=0; j<numDirections; j++)
2692 const int nSolidFaces = solidFaces.
getCount();
2693 shared_ptr<TArray> solidFndPtr(
new TArray(nSolidFaces));
2694 solidFndPtr->zero();
2695 TArray& solidFnd= *solidFndPtr;
2701 const int numMeshes =
_meshes.size();
2702 for (
int n=0; n<numMeshes; n++)
2713 TArray& dsfEqES =
dynamic_cast< TArray&
>(fndEqES[cells]);
2716 for(
int f=0; f<nSolidFaces; f++)
2718 double distIBSolidInvSum(0.0);
2719 for(
int nc = sFCRow[f]; nc<sFCRow[f+1]; nc++)
2722 const int c = sFCCol[nc];
2728 double distIBSolid (0.0);
2730 distIBSolid =
sqrt(pow((faceCentroid[c][0]-solidFaceCentroid[f][0]),2)+
2731 pow((faceCentroid[c][1]-solidFaceCentroid[f][1]),2)+
2732 pow((faceCentroid[c][2]-solidFaceCentroid[f][2]),2));
2733 distIBSolidInvSum += 1/pow(distIBSolid,RelaxDistribution);
2735 for(
int nc = sFCRow[f]; nc<sFCRow[f+1]; nc++)
2737 const int c = sFCCol[nc];
2743 T time_to_wall (0.0);
2744 T distIBSolid (0.0);
2745 const T uwall = v[f][0];
2746 const T vwall = v[f][1];
2747 const T wwall = v[f][2];
2748 distIBSolid =
sqrt(pow((faceCentroid[c][0]-solidFaceCentroid[f][0]),2)+
2749 pow((faceCentroid[c][1]-solidFaceCentroid[f][1]),2)+
2750 pow((faceCentroid[c][2]-solidFaceCentroid[f][2]),2));
2755 time_to_wall = (pow(distIBSolid,2)/((cx[j]-uwall)*(faceCentroid[c][0]-solidFaceCentroid[f][0])+(cy[j]-vwall)*(faceCentroid[c][1]-solidFaceCentroid[f][1])+(cz[j]-wwall)*(faceCentroid[c][2]-solidFaceCentroid[f][2])));
2759 solidFnd[f] += (dsfEqES[c]-(dsfEqES[c]-dsf[c])*exp(-time_to_wall*nue[c]))/(pow(distIBSolid,RelaxDistribution)*distIBSolidInvSum);
2765 fnd.
addArray(solidFaces,solidFndPtr);
2777 const int numMeshes =
_meshes.size();
2780 for (
int n=0; n<numMeshes; n++)
2791 const int numDirections =
_quadrature.getDirCount();
2795 const TArray& faceAreaMag =
2798 const int nibFaces = ibFaces.
getCount();
2800 for(
int f=0; f<nibFaces; f++)
2802 const int c0 = faceCells(f,0);
2803 const int c1 = faceCells(f,1);
2807 const int ibFace = ibFaceIndex[f];
2812 const VectorT3 en = faceArea[f]/faceAreaMag[f];
2813 for (
int j=0; j<numDirections; j++)
2815 const T c_dot_en = cx[j]*en[0]+cy[j]*en[1]+cz[j]*en[2];
2819 netFlux -= dsf[f]*c_dot_en*wts[j]/abs(c_dot_en);
2825 const VectorT3 en = faceArea[f]/faceAreaMag[f];
2826 for (
int j=0; j<numDirections; j++)
2828 const T c_dot_en = cx[j]*en[0]+cy[j]*en[1]+cz[j]*en[2];
2832 netFlux += dsf[f]*c_dot_en*wts[j]/abs(c_dot_en);
2840 MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &netFlux, 1, MPI::DOUBLE, MPI::SUM);
2845 for (
int n=0; n<numMeshes; n++)
2853 volumeSum += cellVolume[c];
2856 MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &volumeSum, 1, MPI::DOUBLE, MPI::SUM);
2859 netFlux /= volumeSum;
2860 for (
int n=0; n<numMeshes; n++)
2871 const int numDirections =
_quadrature.getDirCount();
2873 for (
int j=0; j<numDirections; j++)
2877 cellMass += wts[j]*dsf[c];
2880 for (
int j=0; j<numDirections; j++)
2886 fgam[c] = fgam[c]*(1+netFlux*cellVolume[c]/cellMass);
2887 dsf[c] = dsf[c]*(1+netFlux*cellVolume[c]/cellMass);
2898 const int numMeshes =
_meshes.size();
2905 for (
int n=0; n<numMeshes; n++)
2913 volumeSum += cellVolume[c];
2916 MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &volumeSum, 1, MPI::DOUBLE, MPI::SUM);
2919 netFlux /= volumeSum;
2920 for (
int n=0; n<numMeshes; n++)
2931 const int numDirections =
_quadrature.getDirCount();
2933 for (
int j=0; j<numDirections; j++)
2937 cellMass += wts[j]*dsf[c];
2940 for (
int j=0; j<numDirections; j++)
2946 fgam[c] = fgam[c]*(1+netFlux*cellVolume[c]/cellMass);
2947 dsf[c] = dsf[c]*(1+netFlux*cellVolume[c]/cellMass);
2956 const int numMeshes =
_meshes.size();
2959 for (
int n=0; n<numMeshes; n++)
2966 const int numDirections =
_quadrature.getDirCount();
2970 const TArray& faceAreaMag =
2973 const int nFaces = faces.
getCount();
2979 for (
int j=0; j<numDirections; j++)
2983 ndens_tot += wts[j]*dsf[c];
2988 cout <<
"Hello, I have" << ndens_tot <<
"number density";
3004 shared_ptr<TArray> TemperatureIB(
new TArray(solidFaces.
getCount()));
3005 TemperatureIB->zero();
3010 const int nSolidFaces = solidFaces.
getCount();
3011 for (
int i=0; i<nSolidFaces; i++)
3013 const int numDirections =
_quadrature.getDirCount();
3021 const TArray& solidFaceAreaMag =
3034 const T uwall = v[i][0];
3035 const T vwall = v[i][1];
3036 const T wwall = v[i][2];
3037 const T Twall = temperature[i];
3045 for (
int j=0; j<numDirections; j++)
3049 const VectorT3 en = solidFaceArea[i]/solidFaceAreaMag[i];
3050 const T c_dot_en = cx[j]*en[0]+cy[j]*en[1]+cz[j]*en[2];
3051 const T wallV_dot_en = uwall*en[0]+vwall*en[1]+wwall*en[2];
3052 const T 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);
3054 if (c_dot_en-wallV_dot_en > 0)
3056 Dmr = Dmr - fwall*wts[j]*(c_dot_en-wallV_dot_en);
3057 incomFlux=incomFlux-dsf[i]*wts[j]*(c_dot_en-wallV_dot_en);
3061 Nmr = Nmr + dsf[i]*wts[j]*(c_dot_en-wallV_dot_en);
3063 TempWall = TempWall + dsf[i]*(pow(cx[j]-uwall,2.0)+pow(cy[j]-vwall,2.0)+pow(cz[j]-wwall,2.0))*wts[j]*0.5;
3064 density[i] = density[i] + dsf[i]*wts[j]*0.5;
3065 stress[i][0] +=pow((cx[j]-uwall),2.0)*dsf[i]*wts[j]*0.5;
3066 stress[i][1] +=pow((cy[j]-vwall),2.0)*dsf[i]*wts[j]*0.5;
3067 stress[i][2] +=pow((cz[j]-wwall),2.0)*dsf[i]*wts[j]*0.5;
3068 stress[i][3] +=(cx[j]-uwall)*(cy[j]-vwall)*dsf[i]*wts[j]*0.5;
3069 stress[i][4] +=(cy[j]-vwall)*(cz[j]-wwall)*dsf[i]*wts[j]*0.5;
3070 stress[i][5] +=(cx[j]-uwall)*(cz[j]-wwall)*dsf[i]*wts[j]*0.5;
3074 const T nwall = Nmr/Dmr;
3076 for (
int j=0; j<numDirections; j++)
3080 const VectorT3 en = solidFaceArea[i]/solidFaceAreaMag[i];
3081 const T c_dot_en = cx[j]*en[0]+cy[j]*en[1]+cz[j]*en[2];
3082 const T wallV_dot_en = uwall*en[0]+vwall*en[1]+wwall*en[2];
3083 if (c_dot_en-wallV_dot_en > 0)
3085 dsf[i] = 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);
3087 TempWall = TempWall + dsf[i]*(pow(cx[j]-uwall,2.0)+pow(cy[j]-vwall,2.0)+pow(cz[j]-wwall,2.0))*wts[j]*0.5;
3088 density[i] = density[i] + dsf[i]*wts[j]*0.5;
3089 stress[i][0] +=pow((cx[j]-uwall),2.0)*dsf[i]*wts[j]*0.5;
3090 stress[i][1] +=pow((cy[j]-vwall),2.0)*dsf[i]*wts[j]*0.5;
3091 stress[i][2] +=pow((cz[j]-wwall),2.0)*dsf[i]*wts[j]*0.5;
3092 stress[i][3] +=(cx[j]-uwall)*(cy[j]-vwall)*dsf[i]*wts[j]*0.5;
3093 stress[i][4] +=(cy[j]-vwall)*(cz[j]-wwall)*dsf[i]*wts[j]*0.5;
3094 stress[i][5] +=(cx[j]-uwall)*(cz[j]-wwall)*dsf[i]*wts[j]*0.5;
3101 const VectorT3& Af = solidFaceArea[i];
3102 force[i][0] = Af[0]*Ly*Lz*stress[i][0] + Af[1]*Lz*Lx*stress[i][3] + Af[2]*Lx*Ly*stress[i][5];
3103 force[i][1] = Af[0]*Ly*Lz*stress[i][3] + Af[1]*Lz*Lx*stress[i][1] + Af[2]*Lx*Ly*stress[i][4];
3104 force[i][2] = Af[0]*Ly*Lz*stress[i][5] + Af[1]*Lz*Lx*stress[i][4] + Af[2]*Ly*Ly*stress[i][2];
3106 pFile = fopen(
"WallTemperature.dat",
"a");
3107 fprintf(pFile,
"%E %E %E %E\n",solidFaceCentroid[i][0],solidFaceCentroid[i][1],solidFaceCentroid[i][2],TempWall);
3117 const int numMeshes =
_meshes.size();
3157 for (
int n=0;n<numMeshes;n++)
3178 const int nFaces = faces.
getCount();
3179 for(
int f=0; f<nFaces; f++)
3181 const int c0 = faceCells(f,0);
3182 const int c1 = faceCells(f,1);
3189 const int ibFace = ibFaceIndex[f];
3218 for(
int c=0; c<nCells; c++)
3221 cout <<
"wb value" << wB[c];
3222 TempB[c] = xB[c] /
T_Scalar(wB[c]);
3231 const int numMeshes =
_meshes.size();
3232 for (
int n=0;n<numMeshes;n++)
3239 for (
int direction = 0; direction < numFields; direction++)
3245 if (
_options.timeDiscretizationOrder > 1)
3254 if ( MPI::COMM_WORLD.Get_rank() == 0 )
3255 {cout <<
"updated time" <<endl;}
3258 #ifndef FVM_PARALLEL
3259 cout <<
"updated time" <<endl;
3274 const int numMeshes =
_meshes.size();
3275 for (
int n=0; n<numMeshes; n++)
3290 bc.
getVal(
"specifiedYVelocity"),
3291 bc.
getVal(
"specifiedZVelocity"),
3295 bc.
getVal(
"specifiedTauzz"),faces);
3303 if (bc.
bcType ==
"WallBC")
3307 else if (bc.
bcType ==
"RealWallBC")
3311 const vector<int>& vecReflection=(*pos).second;
3314 else if(bc.
bcType==
"SymmetryBC")
3318 const vector<int>& vecReflection=(*pos).second;
3321 else if(bc.
bcType==
"ZeroGradBC")
3325 else if(bc.
bcType==
"PressureInletBC")
3330 else if(bc.
bcType==
"VelocityInletBC")
3333 const vector<int>& vecReflection=(*pos).second;
3334 kbc.
applyInletBC(bVelocity,bTemperature,mdot,vecReflection);
3336 else if(bc.
bcType==
"PressureOutletBC")
3362 for(
int n=0; n<niter; n++)
3377 for(
int direction=0; direction<N123;direction++)
3409 _options.getKineticLinearSolver().cleanup();
3427 if ( MPI::COMM_WORLD.Get_rank() == 0 ){
3428 if (
_options.printNormalizedResiduals){
3429 cout <<
_niters <<
": " << *normRatio << endl;}
3431 cout <<
_niters <<
": " << *rNorm <<endl; }}
3433 #ifndef FVM_PARALLEL
3434 if (
_options.printNormalizedResiduals){
3435 cout <<
_niters <<
": " << *normRatio << endl;}
3437 cout <<
_niters <<
": " << *rNorm <<endl; }
3454 if ((*rNorm <
_options.absoluteTolerance)||(*normRatio <
_options.relativeTolerance )){
3473 pFile = fopen(filename,
"w");
3477 fprintf(pFile,
"%s \n",
"VARIABLES= cx, cy, cz, f,fEq,fES");
3478 fprintf(pFile,
"%s %i %s %i %s %i \n",
"ZONE I=", N3,
",J=",N2,
",K=",N1);
3479 fprintf(pFile,
"%s \n",
"F=BLOCK, VARLOCATION=(NODAL,NODAL,NODAL,NODAL,NODAL,NODAL)");
3480 const int numMeshes =
_meshes.size();
3481 const int cellno=
_options.printCellNumber;
3482 for (
int n=0; n<numMeshes; n++){
3487 for(
int j=0;j< numFields;j++){fprintf(pFile,
"%E \n",cx[j]);}
3488 for(
int j=0;j< numFields;j++){fprintf(pFile,
"%E \n",cy[j]);}
3489 for(
int j=0;j< numFields;j++){fprintf(pFile,
"%E \n",cz[j]);}
3493 for(
int j=0;j< numFields;j++){
3496 fprintf(pFile,
"%E\n",f[cellno]);
3498 for(
int j=0;j< numFields;j++){
3501 fprintf(pFile,
"%E\n",fEq[cellno]);
3504 for(
int j=0;j< numFields;j++){
3507 TArray& fEqES =
dynamic_cast< TArray&
>(fndEqES[cells]);
3508 fprintf(pFile,
"%E\n",fEqES[cellno]);
3511 for(
int j=0;j< numFields;j++){
3515 fprintf(pFile,
"%E\n",fEq[cellno]);
3527 const int nSolidFaces = solidFaces.
getCount();
3529 boost::shared_ptr<VectorT3Array>
3539 const TArray& solidFaceAreaMag =
3542 const int numMeshes =
_meshes.size();
3543 for (
int n=0; n<numMeshes; n++)
3567 for(
int f=0; f<nSolidFaces; f++){
3573 const IMatrix& mIC =
3574 dynamic_cast<const IMatrix&
>
3576 const Array<T>& iCoeffs = mIC.getCoeff();
3577 for(
int j=0;j<N123;j++){
3579 const TArray& f_dsf =
dynamic_cast<const TArray&
>(fnd[cells]);
3580 for(
int nc = sFCRow[f]; nc<sFCRow[f+1]; nc++)
3583 const int c = sFCCol[nc];
3584 const T coeff = iCoeffs[nc];
3585 stress[0] -=coeff*pow((cx[j]-v[c][0]),2.0)*f_dsf[c]*wts[j];
3586 stress[1] -=coeff*pow((cy[j]-v[c][1]),2.0)*f_dsf[c]*wts[j];
3587 stress[2] -=coeff*pow((cz[j]-v[c][2]),2.0)*f_dsf[c]*wts[j];
3588 stress[3] -=coeff*(cx[j]-v[c][0])*(cy[j]-v[c][1])*f_dsf[c]*wts[j];
3589 stress[4] -=coeff*(cy[j]-v[c][1])*(cz[j]-v[c][2])*f_dsf[c]*wts[j];
3590 stress[5] -=coeff*(cx[j]-v[c][0])*(cz[j]-v[c][2])*f_dsf[c]*wts[j];
3596 for(
int j=0;j<N123;j++){
3598 const TArray& f_dsf =
dynamic_cast<const TArray&
>(fnd[cells]);
3599 for(
int nc = sFCRow[f]; nc<sFCRow[f+1]; nc++)
3602 const int c = sFCCol[nc];
3603 if ( c < selfCount ){
3604 stress[0] +=pow((cx[j]-v[c][0]),2.0)*f_dsf[c]*wts[j];
3605 stress[1] +=pow((cy[j]-v[c][1]),2.0)*f_dsf[c]*wts[j];
3606 stress[2] +=pow((cz[j]-v[c][2]),2.0)*f_dsf[c]*wts[j];
3607 stress[3] +=(cx[j]-v[c][0])*(cy[j]-v[c][1])*f_dsf[c]*wts[j];
3608 stress[4] +=(cy[j]-v[c][1])*(cz[j]-v[c][2])*f_dsf[c]*wts[j];
3609 stress[5] +=(cx[j]-v[c][0])*(cz[j]-v[c][2])*f_dsf[c]*wts[j];
3617 const VectorT3& Af = solidFaceArea[f];
3618 force[f][0] = Af[0]*Ly*Lz*stress[0] + Af[1]*Lz*Lx*stress[3] + Af[2]*Lx*Ly*stress[5];
3619 force[f][1] = Af[0]*Ly*Lz*stress[3] + Af[1]*Lz*Lx*stress[1] + Af[2]*Lx*Ly*stress[4];
3620 force[f][2] = Af[0]*Ly*Lz*stress[5] + Af[1]*Lz*Lx*stress[4] + Af[2]*Ly*Ly*stress[2];
3622 force[f] /= solidFaceAreaMag[f];}
3630 pFile = fopen(
"cxyz0.plt",
"w");
3634 fprintf(pFile,
"%s \n",
"VARIABLES= cx, cy, cz, f,");
3635 fprintf(pFile,
"%s %i %s %i %s %i \n",
"ZONE I=", N3,
",J=",N2,
"K=",N1);
3636 fprintf(pFile,
"%s\n",
"F=POINT");
3637 const int numMeshes =
_meshes.size();
3638 const int cellno=
_options.printCellNumber;
3639 for (
int n=0; n<numMeshes; n++)
3648 for(
int j=0;j< numFields;j++)
3654 fprintf(pFile,
"%E %E %E %E %E\n",cx[j],cy[j],cz[j],f[cellno],fEq[cellno]);
const FaceGroupList & getBoundaryFaceGroups() const
const Array< int > & getCol() const
const DistFunctFields< T > & getdsf1() const
const Array< int > & getRow() const
const DistFunctFields< T > & getdsfEq() const
shared_ptr< FaceGroup > FaceGroupPtr
void applyPressureOutletBC(int f, const X &outletTemperature, const X &outletPressure) const
KineticVCMap & getVCMap()
const StorageSite & getIBFaces() const
const GeomFields & _geomFields
map< int, vector< int > > _faceReflectionArrayMap
void ConservationofMFSolid(const StorageSite &solidFaces, const int output=0, bool perUnitArea=0) const
const CRConnectivity & getConnectivity(const StorageSite &from, const StorageSite &to) const
void applyNSInterfaceBC() const
void applyInletBC(int f, const VectorX3 &InletVelocity, const X &InletTemperature, const X &InletMdot, const vector< int > &vecReflection) const
std::map< int, KineticBC< T > * > KineticBCMap
MacroFields & _macroFields
void linearizeKineticModel(LinearSystem &ls, int direction)
void applyInterfaceBC(const int f) const
void initializeMaxwellianEq()
map< string, shared_ptr< ArrayBase > > & getPersistenceData()
void correctMassDeficit2(double n1, double n2)
void ComputeMacroparameters()
Vector< T, 10 > VectorT10
const Array< int > & getIBFaceList() const
void applyDiffuseWallBC(int f, const VectorX3 &WallVelocity, const X &WallTemperature) const
Field EntropyGenRate_Collisional
KineticBCMap & getBCMap()
map< string, shared_ptr< ArrayBase > > _persistenceData
void applyZeroGradientBC(int f) const
void correctMassDeficit()
const Quadrature< T > & _quadrature
void applyPressureInletBC(int f, const X &inletTemperature, const X &inletPressure) const
Array< VectorT3 > VectorT3Array
void applyRealWallBC(int f, const VectorX3 &WallVelocity, const X &WallTemperature, const X &accommodationCoefficient, const vector< int > &vecReflection) const
KineticModelOptions< T > & getOptions()
const DistFunctFields< T > & getdsf() const
void MacroparameterIBCell(const StorageSite &solidFaces) const
FloatVal< T > getVal(const string varName) const
DistFunctFields< T > _dsfPtr2
const DistFunctFields< T > & getdsf2() const
Tangent sqrt(const Tangent &a)
const CRConnectivity & getAllFaceCells() const
const map< int, vector< int > > & getFaceReflectionArrayMap() const
void OutputDsfBLOCK(const char *filename)
std::vector< Field * > stdVectorField
DistFunctFields< T > _dsfPtr1
void applySpecularWallBC(int f, const vector< int > &vecReflection) const
void EquilibriumDistributionBGK()
virtual void * getData() const
pair< const Field *, const StorageSite * > ArrayIndex
SquareMatrix< T, N > inverseGauss(SquareMatrix< T, N > &a, int size)
map< SSPair, shared_ptr< Matrix > > _interpolationMatrices
Array< VectorT5 > VectorT5Array
DistFunctFields< T > _dsfPtr
vector< shared_ptr< Discretization > > DiscrList
void computeSolidFaceDsf(const StorageSite &solidFaces, const int method, const int RelaxDistribution=0)
DistFunctFields< T > TDistFF
const StorageSite & getFaces() const
const CRConnectivity & getCellCells() const
KineticModel(const MeshList &meshes, const GeomFields &geomFields, MacroFields ¯oFields, const Quadrature< T > &quad)
DistFunctFields< T > _dsfEqPtrES
const StorageSite & getCells() const
void NewtonsMethodBGK(const int ktrial)
int getCountLevel1() const
void InitializeMacroparameters()
const DistFunctFields< T > & getdsfEqES() const
void addArray(const StorageSite &, shared_ptr< ArrayBase > a)
MFRPtr _initialKmodelNorm
const CRConnectivity & getFaceCells(const StorageSite &site) const
void ComputeMacroparametersESBGK()
void setJacobianBGK(SquareMatrix< T, 5 > &fjac, VectorT5 &fvec, const VectorT5 &xn, const VectorT3 &v, const int c)
Tangent fabs(const Tangent &a)
Array< VectorT6 > VectorT6Array
void addMatrix(const Index &rowI, const Index &colI, shared_ptr< Matrix > m)
bool advance(const int niter, const int updated=0)
const double ConservationofMassCheck()
void setJacobianESBGK(SquareMatrix< T, 10 > &fjac, VectorT10 &fvec, const VectorT10 &xn, const VectorT3 &v, const int c)
void computeIBFaceDsf(const StorageSite &solidFaces, const int method, const int RelaxDistribution=0)
void computeSurfaceForce(const StorageSite &solidFaces, bool perUnitArea, bool IBM=0)
NumTypeTraits< T >::T_Scalar T_Scalar
void SetBoundaryConditions()
void NewtonsMethodESBGK(const int ktrial)
Array< StressTensorT6 > StressTensorArray
shared_ptr< MultiFieldReduction > MFRPtr
void addArray(const ArrayIndex &aIndex, shared_ptr< ArrayBase > a)
DistFunctFields< T > _dsfEqPtr
const FaceGroupList & getInterfaceGroups() const
void initKineticModelLinearization(LinearSystem &ls, int direction)
void weightedMaxwellian(double weight1, double uvel1, double uvel2, double temp1, double temp2)
StressTensor< T > StressTensorT6
void initializeMaxwellian()
Array< VectorT10 > VectorT10Array
shared_ptr< ArrayBase > getArrayPtr(const StorageSite &)
void ComputeCollisionfrequency()
std::map< int, KineticVC< T > * > KineticVCMap
virtual void linearize(DiscrList &discretizations, const MeshList &meshes, MultiFieldMatrix &matrix, MultiField &x, MultiField &b)
void callBoundaryConditions()
KineticModelOptions< T > _options
void EquilibriumDistributionESBGK()
pair< const StorageSite *, const StorageSite * > SSPair
MultiFieldMatrix & getMatrix()
vector< Mesh * > MeshList
void weightedMaxwellian(double weight1, double uvel1, double vvel1, double wvel1, double uvel2, double vvel2, double wvel2, double temp1, double temp2)
void InitializeFgammaCoefficients()
void computeSolidFacePressure(const StorageSite &solidFaces)