1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open So
5 \\ / A nd | Copyright (C) 1991-2009 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 Xfer<pointField>& points,
177 const Xfer<faceList>& faces,
178 const Xfer<labelList>& allOwner,
179 const Xfer<labelList>& allNeighbour,
180 const bool syncPar = true
183 //- Construct without boundary from cells rather than owner/neighbour.
184 // Boundary is added using addPatches() member function
188 const Xfer<pointField>& points,
189 const Xfer<faceList>& faces,
190 const Xfer<cellList>& cells,
191 const bool syncPar = true
204 //- Add boundary patches. Constructor helper
207 const List<polyPatch*>&,
208 const bool validBoundary = true
211 //- Update the mesh based on the mesh files saved in time
213 virtual readUpdateState readUpdate();
218 //- Return the top-level database
219 const Time& time() const
221 return polyMesh::time();
224 //- Return the object registry - resolve conflict polyMesh/lduMesh
225 virtual const objectRegistry& thisDb() const
227 return polyMesh::thisDb();
230 //- Return reference to name
231 // Note: name() is currently ambiguous due to derivation from
232 // surfaceInterpolation
233 const word& name() const
235 return polyMesh::name();
238 //- Return reference to boundary mesh
239 const fvBoundaryMesh& boundary() const;
241 //- Return ldu addressing
242 virtual const lduAddressing& lduAddr() const;
244 //- Return a list of pointers for each patch
245 // with only those pointing to interfaces being set
246 virtual lduInterfacePtrsList interfaces() const
248 return boundary().interfaces();
251 //- Internal face owner
252 const unallocLabelList& owner() const
254 return lduAddr().lowerAddr();
257 //- Internal face neighbour
258 const unallocLabelList& neighbour() const
260 return lduAddr().upperAddr();
263 //- Return cell volumes
264 const DimensionedField<scalar, volMesh>& V() const;
266 //- Return old-time cell volumes
267 const DimensionedField<scalar, volMesh>& V0() const;
269 //- Return old-old-time cell volumes
270 const DimensionedField<scalar, volMesh>& V00() const;
272 //- Return cell face area vectors
273 const surfaceVectorField& Sf() const;
275 //- Return cell face area magnitudes
276 const surfaceScalarField& magSf() const;
278 //- Return cell face motion fluxes
279 const surfaceScalarField& phi() const;
281 //- Return cell centres as volVectorField
282 const volVectorField& C() const;
284 //- Return face centres as surfaceVectorField
285 const surfaceVectorField& Cf() const;
290 //- Clear all geometry and addressing
293 //- Update mesh corresponding to the given map
294 virtual void updateMesh(const mapPolyMesh& mpm);
296 //- Move points, returns volumes swept by faces in motion
297 virtual tmp<scalarField> movePoints(const pointField&);
299 //- Map all fields in time using given map.
300 virtual void mapFields(const mapPolyMesh& mpm);
302 //- Remove boundary patches. Warning: fvPatchFields hold ref to
304 void removeFvBoundary();
306 //- Return cell face motion fluxes
307 surfaceScalarField& setPhi();
309 //- Return old-time cell volumes
310 DimensionedField<scalar, volMesh>& setV0();
315 //- Write the underlying polyMesh and other data
316 virtual bool writeObjects
318 IOstream::streamFormat fmt,
319 IOstream::versionNumber ver,
320 IOstream::compressionType cmp
323 //- Write mesh using IO settings from time
324 virtual bool write() const;
329 bool operator!=(const fvMesh&) const;
330 bool operator==(const fvMesh&) const;
334 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
336 } // End namespace Foam
338 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
341 # include "fvPatchFvMeshTemplates.C"
344 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
348 // ************************************************************************* //