5 #ifndef _FLOWMODELINTERIOR_H_
6 #define _FLOWMODELINTERIOR_H_
12 const bool isSymmetry=
false)
23 const TArray& cellVolume =
24 dynamic_cast<const TArray&
>(_geomFields.volume[cells]);
26 const TArray& faceAreaMag =
27 dynamic_cast<const TArray&
>(_geomFields.areaMag[faces]);
30 dynamic_cast<const VectorT3Array&
>(_geomFields.coordinate[cells]);
35 dynamic_cast<PPMatrix&
>(mfmatrix.
getMatrix(pIndex,pIndex));
37 const VVDiagArray& momAp =
dynamic_cast<const VVDiagArray&
>((*_momApField)[cells]);
42 const TArray& p =
dynamic_cast<const TArray&
>(_flowFields.pressure[cells]);
43 const PGradArray& pGrad =
dynamic_cast<const PGradArray&
>(_flowFields.pressureGradient[cells]);
45 const TArray& rho =
dynamic_cast<TArray&
>(_flowFields.density[cells]);
47 PPAssembler& ppAssembler = ppMatrix.getPairWiseAssembler(faceCells);
48 PPDiagArray& ppDiag = ppMatrix.getDiag();
50 TArray& rCell =
dynamic_cast<TArray&
>(rField[pIndex]);
51 TArray& massFlux =
dynamic_cast<TArray&
>(_flowFields.massFlux[faces]);
53 const T momURF(_options[
"momentumURF"]);
54 const T OneMinusmomURF(T(1.0)-momURF);
56 const IntArray& ibType =
dynamic_cast<const IntArray&
>(_geomFields.ibType[cells]);
57 const IntArray& ibFaceIndex =
dynamic_cast<const IntArray&
>(_geomFields.ibFaceIndex[faces]);
62 &(dynamic_cast<const VectorT3Array&>(_flowFields.velocity[mesh.
getIBFaces()])) : 0;
68 for(
int f=0; f<nFaces; f++)
70 const int c0 = faceCells(f,0);
71 const int c1 = faceCells(f,1);
72 const VectorT3 ds=cellCentroid[c1]-cellCentroid[c0];
75 const T diffMetric = faceAreaMag[f]*faceAreaMag[f]/
dot(Af,ds);
77 const T momApBar0 = (momAp[c0][0]+momAp[c0][1]+momAp[c0][2])/3.0;
78 const T momApBar1 = isSymmetry ? momApBar0 : (momAp[c1][0]+momAp[c1][1]+momAp[c1][2])/3.0 ;
79 const T momApBarFace = momApBar0 + momApBar1;
81 const T VdotA0 =
dot(V[c0],Af) - OneMinusmomURF*
dot(Vprev[c0],Af);
82 const T VdotA1 =
dot(V[c1],Af) - OneMinusmomURF*
dot(Vprev[c1],Af);
85 const T dpf = cellVolume[c0]*(pGrad[c0]*ds) + cellVolume[c1]*(pGrad[c1]*ds);
89 const T Vn = (VdotA0*momApBar0 + VdotA1*momApBar1 -dpf*diffMetric) / momApBarFace;
93 const T rhoF = 0.5*(rho[c0]+rho[c1]);
94 const T aByMomAp = Af[0]*Af[0] / (momAp[c0][0] + momAp[c1][0]) +
95 Af[1]*Af[1] / (momAp[c0][1] + momAp[c1][1]) +
96 Af[2]*Af[2] / (momAp[c0][2] + momAp[c1][2]);
99 const T pCoeff = rhoF*aByMomAp*(cellVolume[c0]+cellVolume[c1])/(
dot(Af,ds));
104 massFlux[f] = rhoF*Vn - pCoeff*(p[c0]-p[c1]) + (1-momURF)*massFlux[f];
106 if (isSymmetry) massFlux[f] = 0.;
110 rCell[c0] -= massFlux[f];
111 rCell[c1] += massFlux[f];
113 ppAssembler.getCoeff01(f) -=pCoeff;
114 ppAssembler.getCoeff10(f) -=pCoeff;
116 ppDiag[c0] += pCoeff;
117 ppDiag[c1] += pCoeff;
120 ppDiag[c0] -= ppAssembler.getCoeff01(f);
121 ppAssembler.getCoeff01(f) =0;
123 ppMatrix.setBoundary(c1);
131 const int ibFace = ibFaceIndex[f];
135 const VectorT3& faceVelocity = (*ibVelocity)[ibFace];
141 massFlux[f]= rho[c0]*
dot(Af,faceVelocity);
142 rCell[c0] -= massFlux[f];
144 ppMatrix.setDirichlet(c1);
145 boundaryFlux += massFlux[f];
151 ppMatrix.setDirichlet(c0);
155 if (c1 < nCellsInterior)
157 massFlux[f]= rho[c1]*
dot(Af,faceVelocity);
158 rCell[c1] += massFlux[f];
159 boundaryFlux -= massFlux[f];
164 ppAssembler.getCoeff10(f) =0;
180 ppMatrix.setDirichlet(c0);
181 ppMatrix.setDirichlet(c1);
189 dynamic_cast<PVMatrix&
>(mfmatrix.
getMatrix(pIndex,vIndex));
191 PVAssembler& pvAssembler = pvMatrix.getPairWiseAssembler(faceCells);
192 PVDiagArray& pvDiag = pvMatrix.getDiag();
194 for(
int f=0; f<nFaces; f++)
196 const int c0 = faceCells(f,0);
197 const int c1 = faceCells(f,1);
200 const T momApBar0 = (momAp[c0][0]+momAp[c0][1]+momAp[c0][2])/3.0;
201 const T momApBar1 = (momAp[c1][0]+momAp[c1][1]+momAp[c1][2])/3.0;
202 const T momApBarFace = momApBar0 + momApBar1;
203 const T rhoF = 0.5*(rho[c0]+rho[c1]);
205 VectorT3T coeff0(rhoF*momApBar0/momApBarFace*Af);
206 VectorT3T coeff1(rhoF*momApBar1/momApBarFace*Af);
209 pvAssembler.getCoeff01(f) -=coeff1;
210 pvAssembler.getCoeff10(f) +=coeff0;
212 pvDiag[c0] -= coeff0;
213 pvDiag[c1] += coeff1;
224 const bool isSymmetry =
false)
235 const VVDiagArray& momAp =
dynamic_cast<const VVDiagArray&
>((*_momApField)[cells]);
238 const TArray& pp =
dynamic_cast<const TArray&
>(ppField[pIndex]);
239 const TArray& rho =
dynamic_cast<const TArray&
>(_flowFields.density[cells]);
240 const TArray& cellVolume =
dynamic_cast<const TArray&
>(_geomFields.volume[cells]);
242 const IntArray& ibType =
dynamic_cast<const IntArray&
>(_geomFields.ibType[cells]);
243 const int nFaces = faces.
getCount();
244 for(
int f=0; f<nFaces; f++)
246 const int c0 = faceCells(f,0);
247 const int c1 = faceCells(f,1);
252 const VectorT3 ds=cellCentroid[c1]-cellCentroid[c0];
255 const T aByMomAp0 = Af[0]*Af[0] / momAp[c0][0] +
256 Af[1]*Af[1] / momAp[c0][1] +
257 Af[2]*Af[2] / momAp[c0][2];
259 const T aByMomAp1 = Af[0]*Af[0] / momAp[c1][0] +
260 Af[1]*Af[1] / momAp[c1][1] +
261 Af[2]*Af[2] / momAp[c1][2];
263 const T Adotes =
dot(Af,ds)/
mag(ds);
264 const T coeff0 = cellVolume[c0]*rho[c0]*aByMomAp0/Adotes;
265 const T coeff1 = isSymmetry ? coeff0 :
266 cellVolume[c1]*rho[c1]*aByMomAp1/Adotes;
268 const T ppFace = (coeff0*pp[c0]+coeff1*pp[c1])/(coeff0+coeff1);
269 const VectorT3 ppA = ppFace*faceArea[f];
271 V[c0] += ppA/momAp[c0];
273 V[c1] -= ppA/momAp[c1];
286 const T ppFace = pp[c0];
287 const VectorT3 ppA = ppFace*faceArea[f];
289 V[c0] += ppA/momAp[c0];
291 else if (c1 < nCellsInterior)
293 const T ppFace = pp[c1];
294 const VectorT3 ppA = ppFace*faceArea[f];
296 V[c1] -= ppA/momAp[c1];
305 const bool isSymmetry=
false)
314 const VVDiagArray& momAp =
dynamic_cast<const VVDiagArray&
>((*_momApField)[cells]);
316 const TArray& pCell =
dynamic_cast<const TArray&
>(_flowFields.pressure[cells]);
317 TArray& pFace =
dynamic_cast<TArray&
>(_flowFields.pressure[faces]);
318 const TArray& rho =
dynamic_cast<const TArray&
>(_flowFields.density[cells]);
319 const TArray& cellVolume =
dynamic_cast<const TArray&
>(_geomFields.volume[cells]);
321 const int nFaces = faces.
getCount();
322 const IntArray& ibType =
dynamic_cast<const IntArray&
>(_geomFields.ibType[cells]);
323 for(
int f=0; f<nFaces; f++)
325 const int c0 = faceCells(f,0);
326 const int c1 = faceCells(f,1);
331 const VectorT3 ds=cellCentroid[c1]-cellCentroid[c0];
334 const T aByMomAp0 = Af[0]*Af[0] / momAp[c0][0] +
335 Af[1]*Af[1] / momAp[c0][1] +
336 Af[2]*Af[2] / momAp[c0][2];
338 const T aByMomAp1 = Af[0]*Af[0] / momAp[c1][0] +
339 Af[1]*Af[1] / momAp[c1][1] +
340 Af[2]*Af[2] / momAp[c1][2];
342 const T Adotes =
dot(Af,ds)/
mag(ds);
343 const T coeff0 = cellVolume[c0]*rho[c0]*aByMomAp0/Adotes;
344 const T coeff1 = isSymmetry ? coeff0 :
345 cellVolume[c1]*rho[c1]*aByMomAp1/Adotes;
347 pFace[f] = (coeff0*pCell[c0]+coeff1*pCell[c1])/(coeff0+coeff1);
358 pFace[f] = pCell[c0];
362 pFace[f] = pCell[c1];
380 const TArray& pp =
dynamic_cast<const TArray&
>(xField[pIndex]);
383 dynamic_cast<PPMatrix&
>(mfmatrix.
getMatrix(pIndex,pIndex));
385 PPAssembler& ppAssembler = ppMatrix.getPairWiseAssembler(faceCells);
387 TArray& massFlux =
dynamic_cast<TArray&
>(_flowFields.massFlux[faces]);
389 const int nFaces = faces.
getCount();
390 for(
int f=0; f<nFaces; f++)
392 const int c0 = faceCells(f,0);
393 const int c1 = faceCells(f,1);
397 massFlux[f] -= ppAssembler.getCoeff01(f)*pp[c1] -
398 ppAssembler.getCoeff10(f)*pp[c0];
406 dynamic_cast<PVMatrix&
>(mfmatrix.
getMatrix(pIndex,vIndex));
408 PVAssembler& pvAssembler = pvMatrix.getPairWiseAssembler(faceCells);
411 for(
int f=0; f<nFaces; f++)
413 const int c0 = faceCells(f,0);
414 const int c1 = faceCells(f,1);
416 massFlux[f] += pvAssembler.getCoeff01(f)*Vp[c1] +
417 pvAssembler.getCoeff10(f)*Vp[c0];
Matrix & getMatrix(const Index &rowIndex, const Index &colIndex)
const StorageSite & getIBFaces() const
bool hasMatrix(const Index &rowIndex, const Index &colIndex) const
T mag(const Vector< T, 3 > &a)
void updateFacePressureInterior(const Mesh &mesh, const StorageSite &faces, const bool isSymmetry=false)
void correctVelocityInterior(const Mesh &mesh, const StorageSite &faces, const MultiField &ppField, const bool isSymmetry=false)
T discretizeMassFluxInterior(const Mesh &mesh, const StorageSite &faces, MultiFieldMatrix &mfmatrix, const MultiField &xField, MultiField &rField, const bool isSymmetry=false)
pair< const Field *, const StorageSite * > ArrayIndex
const StorageSite & getCells() const
void correctMassFluxInterior(const Mesh &mesh, const StorageSite &faces, MultiFieldMatrix &mfmatrix, const MultiField &xField)
const CRConnectivity & getFaceCells(const StorageSite &site) const
T dot(const Vector< T, 3 > &a, const Vector< T, 3 > &b)