00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "fvMesh.H"
00028 #include "Time.H"
00029 #include "volFields.H"
00030 #include "surfaceFields.H"
00031 #include "slicedVolFields.H"
00032 #include "slicedSurfaceFields.H"
00033 #include "SubField.H"
00034 #include "cyclicFvPatchFields.H"
00035
00036
00037
00038 namespace Foam
00039 {
00040
00041
00042
00043 void fvMesh::makeSf() const
00044 {
00045 if (debug)
00046 {
00047 Info<< "void fvMesh::makeSf() : "
00048 << "assembling face areas"
00049 << endl;
00050 }
00051
00052
00053
00054 if (SfPtr_)
00055 {
00056 FatalErrorIn("fvMesh::makeSf()")
00057 << "face areas already exist"
00058 << abort(FatalError);
00059 }
00060
00061 SfPtr_ = new slicedSurfaceVectorField
00062 (
00063 IOobject
00064 (
00065 "S",
00066 pointsInstance(),
00067 meshSubDir,
00068 *this
00069 ),
00070 *this,
00071 dimArea,
00072 faceAreas()
00073 );
00074 }
00075
00076
00077 void fvMesh::makeMagSf() const
00078 {
00079 if (debug)
00080 {
00081 Info<< "void fvMesh::makeMagSf() : "
00082 << "assembling mag face areas"
00083 << endl;
00084 }
00085
00086
00087
00088 if (magSfPtr_)
00089 {
00090 FatalErrorIn("void fvMesh::makeMagSf()")
00091 << "mag face areas already exist"
00092 << abort(FatalError);
00093 }
00094
00095
00096
00097
00098 magSfPtr_ = new surfaceScalarField
00099 (
00100 IOobject
00101 (
00102 "magSf",
00103 pointsInstance(),
00104 meshSubDir,
00105 *this,
00106 IOobject::NO_READ,
00107 IOobject::NO_WRITE,
00108 false
00109 ),
00110 mag(Sf()) + dimensionedScalar("vs", dimArea, VSMALL)
00111 );
00112 }
00113
00114
00115 void fvMesh::makeC() const
00116 {
00117 if (debug)
00118 {
00119 Info<< "void fvMesh::makeC() : "
00120 << "assembling cell centres"
00121 << endl;
00122 }
00123
00124
00125
00126 if (CPtr_)
00127 {
00128 FatalErrorIn("fvMesh::makeC()")
00129 << "cell centres already exist"
00130 << abort(FatalError);
00131 }
00132
00133 CPtr_ = new slicedVolVectorField
00134 (
00135 IOobject
00136 (
00137 "C",
00138 pointsInstance(),
00139 meshSubDir,
00140 *this,
00141 IOobject::NO_READ,
00142 IOobject::NO_WRITE,
00143 false
00144 ),
00145 *this,
00146 dimLength,
00147 cellCentres(),
00148 faceCentres()
00149 );
00150
00151
00152
00153
00154
00155 slicedVolVectorField& C = *CPtr_;
00156
00157 forAll(C.boundaryField(), patchi)
00158 {
00159 if (isA<cyclicFvPatchVectorField>(C.boundaryField()[patchi]))
00160 {
00161
00162 C.boundaryField()[patchi] == static_cast<const vectorField&>
00163 (
00164 static_cast<const List<vector>&>
00165 (
00166 boundary_[patchi].patchSlice(faceCentres())
00167 )
00168 );
00169 }
00170 }
00171 }
00172
00173
00174 void fvMesh::makeCf() const
00175 {
00176 if (debug)
00177 {
00178 Info<< "void fvMesh::makeCf() : "
00179 << "assembling face centres"
00180 << endl;
00181 }
00182
00183
00184
00185 if (CfPtr_)
00186 {
00187 FatalErrorIn("fvMesh::makeCf()")
00188 << "face centres already exist"
00189 << abort(FatalError);
00190 }
00191
00192 CfPtr_ = new slicedSurfaceVectorField
00193 (
00194 IOobject
00195 (
00196 "Cf",
00197 pointsInstance(),
00198 meshSubDir,
00199 *this,
00200 IOobject::NO_READ,
00201 IOobject::NO_WRITE,
00202 false
00203 ),
00204 *this,
00205 dimLength,
00206 faceCentres()
00207 );
00208 }
00209
00210
00211
00212
00213 const volScalarField::DimensionedInternalField& fvMesh::V() const
00214 {
00215 if (!VPtr_)
00216 {
00217 VPtr_ = new slicedVolScalarField::DimensionedInternalField
00218 (
00219 IOobject
00220 (
00221 "V",
00222 time().timeName(),
00223 *this,
00224 IOobject::NO_READ,
00225 IOobject::NO_WRITE
00226 ),
00227 *this,
00228 dimVolume,
00229 cellVolumes()
00230 );
00231 }
00232
00233 return *static_cast<slicedVolScalarField::DimensionedInternalField*>(VPtr_);
00234 }
00235
00236
00237 const volScalarField::DimensionedInternalField& fvMesh::V0() const
00238 {
00239 if (!V0Ptr_)
00240 {
00241 FatalErrorIn("fvMesh::V0() const")
00242 << "V0 is not available"
00243 << abort(FatalError);
00244 }
00245
00246 return *V0Ptr_;
00247 }
00248
00249
00250 volScalarField::DimensionedInternalField& fvMesh::setV0()
00251 {
00252 if (!V0Ptr_)
00253 {
00254 FatalErrorIn("fvMesh::setV0()")
00255 << "V0 is not available"
00256 << abort(FatalError);
00257 }
00258
00259 return *V0Ptr_;
00260 }
00261
00262
00263 const volScalarField::DimensionedInternalField& fvMesh::V00() const
00264 {
00265 if (!V00Ptr_)
00266 {
00267 V00Ptr_ = new DimensionedField<scalar, volMesh>
00268 (
00269 IOobject
00270 (
00271 "V00",
00272 time().timeName(),
00273 *this,
00274 IOobject::NO_READ,
00275 IOobject::NO_WRITE
00276 ),
00277 V0()
00278 );
00279
00280
00281 V0Ptr_->writeOpt() = IOobject::AUTO_WRITE;
00282 }
00283
00284 return *V00Ptr_;
00285 }
00286
00287
00288 const surfaceVectorField& fvMesh::Sf() const
00289 {
00290 if (!SfPtr_)
00291 {
00292 makeSf();
00293 }
00294
00295 return *SfPtr_;
00296 }
00297
00298
00299 const surfaceScalarField& fvMesh::magSf() const
00300 {
00301 if (!magSfPtr_)
00302 {
00303 makeMagSf();
00304 }
00305
00306 return *magSfPtr_;
00307 }
00308
00309
00310 const volVectorField& fvMesh::C() const
00311 {
00312 if (!CPtr_)
00313 {
00314 makeC();
00315 }
00316
00317 return *CPtr_;
00318 }
00319
00320
00321 const surfaceVectorField& fvMesh::Cf() const
00322 {
00323 if (!CfPtr_)
00324 {
00325 makeCf();
00326 }
00327
00328 return *CfPtr_;
00329 }
00330
00331
00332 const surfaceScalarField& fvMesh::phi() const
00333 {
00334 if (!phiPtr_)
00335 {
00336 FatalErrorIn("fvMesh::phi()")
00337 << "mesh flux field does not exists, is the mesh actually moving?"
00338 << exit(FatalError);
00339 }
00340
00341
00342
00343 if (phiPtr_->timeIndex() != time().timeIndex())
00344 {
00345 (*phiPtr_) = dimensionedScalar("0", dimVolume/dimTime, 0.0);
00346 }
00347
00348 return *phiPtr_;
00349 }
00350
00351
00352 surfaceScalarField& fvMesh::setPhi()
00353 {
00354 if (!phiPtr_)
00355 {
00356 FatalErrorIn("fvMesh::setPhi()")
00357 << "mesh flux field does not exists, is the mesh actually moving?"
00358 << exit(FatalError);
00359 }
00360
00361 return *phiPtr_;
00362 }
00363
00364
00365
00366
00367 }
00368
00369