1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2011 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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
28 Mesh data needed to do the Finite Volume discretisation.
31 fvMesh contains all the topological and geometric information
32 related to the mesh. It is also responsible for keeping the data
33 up-to-date. This is done by deleting the cell volume, face area,
34 cell/face centre, addressing and other derived information as
35 required and recalculating it as necessary. The fvMesh therefore
36 reserves the right to delete the derived information upon every
37 topological (mesh refinement/morphing) or geometric change (mesh
38 motion). It is therefore unsafe to keep local references to the
39 derived data outside of the time loop.
45 \*---------------------------------------------------------------------------*/
52 #include "primitiveMesh.H"
53 #include "fvBoundaryMesh.H"
54 #include "surfaceInterpolation.H"
55 #include "DimensionedField.H"
56 #include "volFieldsFwd.H"
57 #include "surfaceFieldsFwd.H"
58 #include "pointFieldsFwd.H"
59 #include "slicedVolFieldsFwd.H"
60 #include "slicedSurfaceFieldsFwd.H"
61 #include "className.H"
63 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
68 class fvMeshLduAddressing;
72 /*---------------------------------------------------------------------------*\
73 Class fvMesh Declaration
74 \*---------------------------------------------------------------------------*/
80 public surfaceInterpolation
85 fvBoundaryMesh boundary_;
90 mutable fvMeshLduAddressing* lduPtr_;
92 //- Current time index for cell volumes
93 // Note. The whole mechanism will be replaced once the
94 // dimensionedField is created and the dimensionedField
95 // will take care of the old-time levels.
96 mutable label curTimeIndex_;
98 //- Cell volumes old time level
101 //- Cell volumes old time level
102 mutable DimensionedField<scalar, volMesh>* V0Ptr_;
104 //- Cell volumes old-old time level
105 mutable DimensionedField<scalar, volMesh>* V00Ptr_;
107 //- Face area vectors
108 mutable slicedSurfaceVectorField* SfPtr_;
110 //- Mag face area vectors
111 mutable surfaceScalarField* magSfPtr_;
114 mutable slicedVolVectorField* CPtr_;
117 mutable slicedSurfaceVectorField* CfPtr_;
119 //- Face motion fluxes
120 mutable surfaceScalarField* phiPtr_;
123 // Private Member Functions
125 // Storage management
127 //- Clear geometry but not the old-time cell volumes
128 void clearGeomNotOldVol();
134 void clearAddressing();
137 // Make geometric data
140 void makeMagSf() const;
146 //- Disallow construct as copy
147 fvMesh(const fvMesh&);
149 //- Disallow assignment
150 void operator=(const fvMesh&);
158 typedef fvBoundaryMesh BoundaryMesh;
161 // Declare name of the class and its debug switch
167 //- Construct from IOobject
168 explicit fvMesh(const IOobject& io);
170 //- Construct from components without boundary.
171 // Boundary is added using addFvPatches() member function
175 const Xfer<pointField>& points,
176 const Xfer<faceList>& faces,
177 const Xfer<labelList>& allOwner,
178 const Xfer<labelList>& allNeighbour,
179 const bool syncPar = true
182 //- Construct without boundary from cells rather than owner/neighbour.
183 // Boundary is added using addPatches() member function
187 const Xfer<pointField>& points,
188 const Xfer<faceList>& faces,
189 const Xfer<cellList>& cells,
190 const bool syncPar = true
203 //- Add boundary patches. Constructor helper
206 const List<polyPatch*>&,
207 const bool validBoundary = true
210 //- Update the mesh based on the mesh files saved in time
212 virtual readUpdateState readUpdate();
217 //- Return the top-level database
218 const Time& time() const
220 return polyMesh::time();
223 //- Return the object registry - resolve conflict polyMesh/lduMesh
224 virtual const objectRegistry& thisDb() const
226 return polyMesh::thisDb();
229 //- Return reference to name
230 // Note: name() is currently ambiguous due to derivation from
231 // surfaceInterpolation
232 const word& name() const
234 return polyMesh::name();
237 //- Return reference to boundary mesh
238 const fvBoundaryMesh& boundary() const;
240 //- Return ldu addressing
241 virtual const lduAddressing& lduAddr() const;
243 //- Return a list of pointers for each patch
244 // with only those pointing to interfaces being set
245 virtual lduInterfacePtrsList interfaces() const
247 return boundary().interfaces();
250 //- Internal face owner
251 const unallocLabelList& owner() const
253 return lduAddr().lowerAddr();
256 //- Internal face neighbour
257 const unallocLabelList& neighbour() const
259 return lduAddr().upperAddr();
262 //- Return cell volumes
263 const DimensionedField<scalar, volMesh>& V() const;
265 //- Return old-time cell volumes
266 const DimensionedField<scalar, volMesh>& V0() const;
268 //- Return old-old-time cell volumes
269 const DimensionedField<scalar, volMesh>& V00() const;
271 //- Return sub-cycle cell volumes
272 tmp<DimensionedField<scalar, volMesh> > Vsc() const;
274 //- Return sub-cycl old-time cell volumes
275 tmp<DimensionedField<scalar, volMesh> > Vsc0() const;
277 //- Return cell face area vectors
278 const surfaceVectorField& Sf() const;
280 //- Return cell face area magnitudes
281 const surfaceScalarField& magSf() const;
283 //- Return cell face motion fluxes
284 const surfaceScalarField& phi() const;
286 //- Return cell centres as volVectorField
287 const volVectorField& C() const;
289 //- Return face centres as surfaceVectorField
290 const surfaceVectorField& Cf() const;
295 //- Clear all geometry and addressing
298 //- Update mesh corresponding to the given map
299 virtual void updateMesh(const mapPolyMesh& mpm);
301 //- Move points, returns volumes swept by faces in motion
302 virtual tmp<scalarField> movePoints(const pointField&);
304 //- Map all fields in time using given map.
305 virtual void mapFields(const mapPolyMesh& mpm);
307 //- Remove boundary patches. Warning: fvPatchFields hold ref to
309 void removeFvBoundary();
311 //- Return cell face motion fluxes
312 surfaceScalarField& setPhi();
314 //- Return old-time cell volumes
315 DimensionedField<scalar, volMesh>& setV0();
320 //- Write the underlying polyMesh and other data
321 virtual bool writeObjects
323 IOstream::streamFormat fmt,
324 IOstream::versionNumber ver,
325 IOstream::compressionType cmp
328 //- Write mesh using IO settings from time
329 virtual bool write() const;
334 bool operator!=(const fvMesh&) const;
335 bool operator==(const fvMesh&) const;
339 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
341 } // End namespace Foam
343 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
346 # include "fvPatchFvMeshTemplates.C"
349 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
353 // ************************************************************************* //