1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
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"
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_;
99 mutable DimensionedField<scalar, volMesh>* VPtr_;
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 // Make geometric data
129 //- Make face area magnitudes
130 void makeMagSf() const;
132 //- Make mesh motion fluxes
133 void makePhi() const;
135 //- Update mesh motion fluxes given swept volumes
136 void updatePhi(const scalarField& sweptVols) const;
138 //- Make cell centres
141 //- Make face centres
145 //- Disallow construct as copy
146 fvMesh(const fvMesh&);
148 //- Disallow assignment
149 void operator=(const fvMesh&);
152 // Storage management
154 //- Clear geometry but not the old-time cell volumes
155 void clearGeomNotOldVol();
161 void clearAddressing();
169 typedef fvBoundaryMesh BoundaryMesh;
172 // Declare name of the class and its debug switch
178 //- Construct from IOobject
179 explicit fvMesh(const IOobject& io);
181 //- Construct from components without boundary.
182 // Boundary is added using addFvPatches() member function
186 const Xfer<pointField>& points,
187 const Xfer<faceList>& faces,
188 const Xfer<labelList>& allOwner,
189 const Xfer<labelList>& allNeighbour,
190 const bool syncPar = true
193 //- Construct without boundary from cells rather than owner/neighbour.
194 // Boundary is added using addPatches() member function
198 const Xfer<pointField>& points,
199 const Xfer<faceList>& faces,
200 const Xfer<cellList>& cells,
201 const bool syncPar = true
214 //- Add boundary patches. Constructor helper
217 const List<polyPatch*>&,
218 const bool validBoundary = true
221 //- Update the mesh based on the mesh files saved in time
223 virtual readUpdateState readUpdate();
228 //- Return the top-level database
229 const Time& time() const
231 return polyMesh::time();
234 //- Return the object registry - resolve conflict polyMesh/lduMesh
235 virtual const objectRegistry& thisDb() const
237 return polyMesh::thisDb();
240 //- Return reference to name
241 // Note: name() is currently ambiguous due to derivation from
242 // surfaceInterpolation
243 const word& name() const
245 return polyMesh::name();
248 //- Return reference to boundary mesh
249 const fvBoundaryMesh& boundary() const;
251 //- Return ldu addressing
252 virtual const lduAddressing& lduAddr() const;
254 //- Return a list of pointers for each patch
255 // with only those pointing to interfaces being set
256 virtual lduInterfacePtrsList interfaces() const
258 return boundary().interfaces();
261 //- Internal face owner
262 const unallocLabelList& owner() const
264 return lduAddr().lowerAddr();
267 //- Internal face neighbour
268 const unallocLabelList& neighbour() const
270 return lduAddr().upperAddr();
274 //- Return cell volumes
275 const DimensionedField<scalar, volMesh>& V() const;
277 //- Return old-time cell volumes
278 const DimensionedField<scalar, volMesh>& V0() const;
280 //- Return old-old-time cell volumes
281 const DimensionedField<scalar, volMesh>& V00() const;
283 //- Return sub-cycle cell volumes
284 tmp<DimensionedField<scalar, volMesh> > Vsc() const;
286 //- Return sub-cycl old-time cell volumes
287 tmp<DimensionedField<scalar, volMesh> > Vsc0() const;
289 //- Return cell face area vectors
290 const surfaceVectorField& Sf() const;
292 //- Return cell face area magnitudes
293 const surfaceScalarField& magSf() const;
295 //- Return cell face motion fluxes
296 const surfaceScalarField& phi() const;
298 //- Return cell centres as volVectorField
299 const volVectorField& C() const;
301 //- Return face centres as surfaceVectorField
302 const surfaceVectorField& Cf() const;
307 //- Clear all geometry and addressing
310 //- Update mesh corresponding to the given map
311 virtual void updateMesh(const mapPolyMesh& mpm);
313 //- Sync mesh update for topo change on other processors
314 // Locally, there is no topological change
315 virtual void syncUpdateMesh();
317 //- Move points, returns volumes swept by faces in motion
318 virtual tmp<scalarField> movePoints(const pointField&);
320 //- Map all fields in time using given map.
321 virtual void mapFields(const mapPolyMesh& mpm) const;
323 //- Map cell volumes in time using given map.
324 virtual void mapOldVolumes(const mapPolyMesh& mpm);
326 //- Remove boundary patches. Warning: fvPatchFields hold ref to
328 void removeFvBoundary();
330 //- Return cell face motion fluxes
331 surfaceScalarField& setPhi();
333 //- Return old-time cell volumes
334 DimensionedField<scalar, volMesh>& setV0();
339 //- Write the underlying polyMesh and other data
340 virtual bool writeObjects
342 IOstream::streamFormat fmt,
343 IOstream::versionNumber ver,
344 IOstream::compressionType cmp
347 //- Write mesh using IO settings from time
348 virtual bool write() const;
353 bool operator!=(const fvMesh&) const;
354 bool operator==(const fvMesh&) const;
358 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
360 } // End namespace Foam
362 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
365 # include "fvPatchFvMeshTemplates.C"
368 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
372 // ************************************************************************* //