1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
29 #include "volFields.H"
30 #include "surfaceFields.H"
31 #include "slicedVolFields.H"
32 #include "slicedSurfaceFields.H"
35 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
40 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
42 void fvMesh::makeSf() const
46 Info<< "void fvMesh::makeSf() : "
47 << "assembling face areas"
51 // It is an error to attempt to recalculate
52 // if the pointer is already set
55 FatalErrorIn("fvMesh::makeSf()")
56 << "face areas already exist"
60 SfPtr_ = new slicedSurfaceVectorField
76 void fvMesh::makeMagSf() const
80 Info<< "void fvMesh::makeMagSf() : "
81 << "assembling mag face areas"
85 // It is an error to attempt to recalculate
86 // if the pointer is already set
89 FatalErrorIn("void fvMesh::makeMagSf()")
90 << "mag face areas already exist"
94 // Note: Added stabilisation for faces with exactly zero area.
95 // These should be caught on mesh checking but at least this stops
96 // the code from producing Nans.
97 magSfPtr_ = new surfaceScalarField
109 mag(Sf()) + dimensionedScalar("vs", dimArea, VSMALL)
114 void fvMesh::makeC() const
118 Info<< "void fvMesh::makeC() : "
119 << "assembling cell centres"
123 // It is an error to attempt to recalculate
124 // if the pointer is already set
127 FatalErrorIn("fvMesh::makeC()")
128 << "cell centres already exist"
129 << abort(FatalError);
132 CPtr_ = new slicedVolVectorField
152 void fvMesh::makeCf() const
156 Info<< "void fvMesh::makeCf() : "
157 << "assembling face centres"
161 // It is an error to attempt to recalculate
162 // if the pointer is already set
165 FatalErrorIn("fvMesh::makeCf()")
166 << "face centres already exist"
167 << abort(FatalError);
170 CfPtr_ = new slicedSurfaceVectorField
189 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
191 const volScalarField::DimensionedInternalField& fvMesh::V() const
195 VPtr_ = new slicedVolScalarField::DimensionedInternalField
211 return *static_cast<slicedVolScalarField::DimensionedInternalField*>(VPtr_);
215 const volScalarField::DimensionedInternalField& fvMesh::V0() const
219 FatalErrorIn("fvMesh::V0() const")
220 << "V0 is not available"
221 << abort(FatalError);
228 volScalarField::DimensionedInternalField& fvMesh::setV0()
232 FatalErrorIn("fvMesh::setV0()")
233 << "V0 is not available"
234 << abort(FatalError);
241 const volScalarField::DimensionedInternalField& fvMesh::V00() const
245 V00Ptr_ = new DimensionedField<scalar, volMesh>
258 // If V00 is used then V0 should be stored for restart
259 V0Ptr_->writeOpt() = IOobject::AUTO_WRITE;
266 const surfaceVectorField& fvMesh::Sf() const
277 const surfaceScalarField& fvMesh::magSf() const
288 const volVectorField& fvMesh::C() const
299 const surfaceVectorField& fvMesh::Cf() const
310 const surfaceScalarField& fvMesh::phi() const
314 FatalErrorIn("fvMesh::phi()")
315 << "mesh flux field does not exists, is the mesh actually moving?"
319 // Set zero current time
320 // mesh motion fluxes if the time has been incremented
321 if (phiPtr_->timeIndex() != time().timeIndex())
323 (*phiPtr_) = dimensionedScalar("0", dimVolume/dimTime, 0.0);
330 surfaceScalarField& fvMesh::setPhi()
334 FatalErrorIn("fvMesh::setPhi()")
335 << "mesh flux field does not exists, is the mesh actually moving?"
343 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
345 } // End namespace Foam
347 // ************************************************************************* //