5 #ifndef _CONVECTIONDISCRETIZATION_H_
6 #define _CONVECTIONDISCRETIZATION_H_
17 template<
class X,
class Diag,
class OffDiag>
40 const Field& convectingFluxField,
41 const Field& continuityResidualField,
42 const Field& varGradientField,
43 const bool useCentralDifference=
false) :
65 const TArray& convectingFlux =
67 const TArray& continuityResidual =
79 const XArray& xCell =
dynamic_cast<const XArray&
>(xField[cVarIndex]);
80 XArray& rCell =
dynamic_cast<XArray&
>(rField[cVarIndex]);
89 shared_ptr<TArray> gridFluxPtr(
new TArray(nFaces));
90 TArray& gridFlux = *gridFluxPtr;
93 for(
int f=0; f<nFaces; f++)
95 const int c0 = faceCells(f,0);
96 const int c1 = faceCells(f,1);
97 const T_Scalar faceCFlux = convectingFlux[f] - gridFlux[f];
102 varFlux = faceCFlux*xCell[c0];
103 diag[c0] -= faceCFlux;
108 varFlux = faceCFlux*xCell[c1];
109 diag[c1] += faceCFlux;
113 rCell[c0] -= varFlux;
114 rCell[c1] += varFlux;
120 for(
int f=0; f<nFaces; f++)
122 const int c0 = faceCells(f,0);
123 const int c1 = faceCells(f,1);
124 const T_Scalar faceCFlux = convectingFlux[f];
131 X varFlux =0.5*faceCFlux*(xCell[c0] + xCell[c0]);
133 rCell[c0] -= varFlux;
134 rCell[c1] += varFlux;
143 diag[c0] -= 0.5*faceCFlux;
145 diag[c1] += 0.5*faceCFlux;
154 diag[c0] -= faceCFlux;
159 diag[c1] += faceCFlux;
166 for(
int f=0; f<nFaces; f++)
168 const int c0 = faceCells(f,0);
169 const int c1 = faceCells(f,1);
170 const T_Scalar faceCFlux = convectingFlux[f];
176 varFlux = faceCFlux*xCell[c0];
177 diag[c0] -= faceCFlux;
182 varFlux = faceCFlux*xCell[c1];
183 diag[c1] += faceCFlux;
187 rCell[c0] -= varFlux;
188 rCell[c1] += varFlux;
195 for(
int c=0;c<nCells;c++)
197 const T_Scalar cImb = continuityResidual[c];
const bool _useCentralDifference
Matrix & getMatrix(const Index &rowIndex, const Index &colIndex)
ConvectionDiscretization(const MeshList &meshes, const GeomFields &geomFields, Field &varField, const Field &convectingFluxField, const Field &continuityResidualField, const Field &varGradientField, const bool useCentralDifference=false)
bool hasArray(const StorageSite &s) const
NumTypeTraits< X >::T_Scalar T_Scalar
OffDiag & getCoeff10(const int np)
Array< Diag > & getDiag()
const GeomFields & _geomFields
CCMatrix::DiagArray DiagArray
const CRConnectivity & getAllFaceCells() const
pair< const Field *, const StorageSite * > ArrayIndex
CCMatrix::PairWiseAssembler CCAssembler
Array< VectorT3 > VectorT3Array
const StorageSite & getFaces() const
const StorageSite & getCells() const
OffDiag & getCoeff01(const int np)
CRMatrix< Diag, OffDiag, X > CCMatrix
const Field & _convectingFluxField
const Field & _continuityResidualField
PairWiseAssembler & getPairWiseAssembler(const CRConnectivity &pairs)
Vector< T_Scalar, 3 > VectorT3
void discretize(const Mesh &mesh, MultiFieldMatrix &mfmatrix, MultiField &xField, MultiField &rField)
const Field & _varGradientField
vector< Mesh * > MeshList