1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open So
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
29 Mesh data needed to do the Finite Volume discretisation.
32 fvMesh contains all the topological and geometric information
33 related to the mesh. It is also responsible for keeping the data
34 up-to-date. This is done by deleting the cell volume, face area,
35 cell/face centre, addressing and other derived information as
36 required and recalculating it as necessary. The fvMesh therefore
37 reserves the right to delete the derived information upon every
38 topological (mesh refinement/morphing) or geometric change (mesh
39 motion). It is therefore unsafe to keep local references to the
40 derived data outside of the time loop.
46 \*---------------------------------------------------------------------------*/
53 #include "primitiveMesh.H"
54 #include "fvBoundaryMesh.H"
55 #include "surfaceInterpolation.H"
56 #include "DimensionedField.H"
57 #include "volFieldsFwd.H"
58 #include "surfaceFieldsFwd.H"
59 #include "pointFieldsFwd.H"
60 #include "slicedVolFieldsFwd.H"
61 #include "slicedSurfaceFieldsFwd.H"
62 #include "className.H"
64 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
69 class fvMeshLduAddressing;
73 /*---------------------------------------------------------------------------*\
74 Class fvMesh Declaration
75 \*---------------------------------------------------------------------------*/
81 public surfaceInterpolation
86 fvBoundaryMesh boundary_;
91 mutable fvMeshLduAddressing* lduPtr_;
93 //- Current time index for cell volumes
94 // Note. The whole mechanism will be replaced once the
95 // dimensionedField is created and the dimensionedField
96 // will take care of the old-time levels.
97 mutable label curTimeIndex_;
99 //- Cell volumes old time level
102 //- Cell volumes old time level
103 mutable DimensionedField<scalar, volMesh>* V0Ptr_;
105 //- Cell volumes old-old time level
106 mutable DimensionedField<scalar, volMesh>* V00Ptr_;
108 //- Face area vectors
109 mutable slicedSurfaceVectorField* SfPtr_;
111 //- Mag face area vectors
112 mutable surfaceScalarField* magSfPtr_;
115 mutable slicedVolVectorField* CPtr_;
118 mutable slicedSurfaceVectorField* CfPtr_;
120 //- Face motion fluxes
121 mutable surfaceScalarField* phiPtr_;
124 // Private Member Functions
126 // Storage management
128 //- Clear geometry but not the old-time cell volumes
129 void clearGeomNotOldVol();
135 void clearAddressing();
138 // Make geometric data
141 void makeMagSf() const;
147 //- Disallow construct as copy
148 fvMesh(const fvMesh&);
150 //- Disallow assignment
151 void operator=(const fvMesh&);
159 typedef fvBoundaryMesh BoundaryMesh;
162 // Declare name of the class and its debug switch
168 //- Construct from IOobject
169 explicit fvMesh(const IOobject& io);
171 //- Construct from components without boundary.
172 // Boundary is added using addFvPatches() member function
176 const pointField& points,
177 const faceList& faces,
178 const labelList& allOwner,
179 const labelList& allNeighbour,
180 const bool syncPar = true
183 //- Construct from components with cells rather than owner
184 // and neighbourwithout boundary.
185 // Boundary is added using addPatches() member function
189 const pointField& points,
190 const faceList& faces,
191 const cellList& cells,
192 const bool syncPar = true
205 //- Add boundary patches. Constructor helper
208 const List<polyPatch*>&,
209 const bool validBoundary = true
212 //- Update the mesh based on the mesh files saved in time
214 virtual readUpdateState readUpdate();
219 //- Return the top-level database
220 const Time& time() const
222 return polyMesh::time();
225 //- Return the object registry
226 virtual const objectRegistry& db() const
231 //- Return reference to name
232 // Note: name() is currently ambiguous due to derivation from
233 // surfaceInterpolation
234 const word& name() const
236 return polyMesh::name();
239 //- Return reference to boundary mesh
240 const fvBoundaryMesh& boundary() const;
242 //- Return ldu addressing
243 virtual const lduAddressing& lduAddr() const;
245 //- Return a list of pointers for each patch
246 // with only those pointing to interfaces being set
247 virtual lduInterfacePtrsList interfaces() const
249 return boundary().interfaces();
252 //- Internal face owner
253 const unallocLabelList& owner() const
255 return lduAddr().lowerAddr();
258 //- Internal face neighbour
259 const unallocLabelList& neighbour() const
261 return lduAddr().upperAddr();
264 //- Return cell volumes
265 const DimensionedField<scalar, volMesh>& V() const;
267 //- Return old-time cell volumes
268 const DimensionedField<scalar, volMesh>& V0() const;
270 //- Return old-old-time cell volumes
271 const DimensionedField<scalar, volMesh>& V00() const;
273 //- Return cell face area vectors
274 const surfaceVectorField& Sf() const;
276 //- Return cell face area magnitudes
277 const surfaceScalarField& magSf() const;
279 //- Return cell face motion fluxes
280 const surfaceScalarField& phi() const;
282 //- Return cell centres as volVectorField
283 const volVectorField& C() const;
285 //- Return face centres as surfaceVectorField
286 const surfaceVectorField& Cf() const;
291 //- Clear all geometry and addressing
294 //- Update mesh corresponding to the given map
295 virtual void updateMesh(const mapPolyMesh& mpm);
297 //- Move points, returns volumes swept by faces in motion
298 virtual tmp<scalarField> movePoints(const vectorField&);
300 //- Map all fields in time using given map.
301 virtual void mapFields(const mapPolyMesh& mpm);
303 //- Remove boundary patches. Warning: fvPatchFields hold ref to
305 void removeFvBoundary();
307 //- Return cell face motion fluxes
308 surfaceScalarField& setPhi();
310 //- Return old-time cell volumes
311 DimensionedField<scalar, volMesh>& setV0();
316 //- Write the underlying polyMesh and other data
317 virtual bool writeObjects
319 IOstream::streamFormat fmt,
320 IOstream::versionNumber ver,
321 IOstream::compressionType cmp
324 //- Write mesh using IO settings from time
325 virtual bool write() const;
330 bool operator!=(const fvMesh&) const;
331 bool operator==(const fvMesh&) const;
335 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
337 } // End namespace Foam
339 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
342 # include "fvPatchFvMeshTemplates.C"
345 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
349 // ************************************************************************* //