initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / finiteVolume / fvMesh / fvMesh.H
blob64e4d87f3e69dc9f91fd45745438d4b7527f8596
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open So
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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 Class
26     Foam::fvMesh
28 Description
29     Mesh data needed to do the Finite Volume discretisation.
31     NOTE ON USAGE:
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.
42 SourceFiles
43     fvMesh.C
44     fvMeshGeometry.C
46 \*---------------------------------------------------------------------------*/
48 #ifndef fvMesh_H
49 #define fvMesh_H
51 #include "polyMesh.H"
52 #include "lduMesh.H"
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 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
66 namespace Foam
69 class fvMeshLduAddressing;
70 class volMesh;
73 /*---------------------------------------------------------------------------*\
74                            Class fvMesh Declaration
75 \*---------------------------------------------------------------------------*/
77 class fvMesh
79     public polyMesh,
80     public lduMesh,
81     public surfaceInterpolation
83     // Private data
85         //- Boundary mesh
86         fvBoundaryMesh boundary_;
89     // Demand-driven data
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
100         mutable void* VPtr_;
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_;
114         //- Cell centres
115         mutable slicedVolVectorField* CPtr_;
117         //- Face centres
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();
131             //- Clear geometry
132             void clearGeom();
134             //- Clear addressing
135             void clearAddressing();
138        // Make geometric data
140             void makeSf() const;
141             void makeMagSf() const;
143             void makeC() const;
144             void makeCf() const;
147         //- Disallow construct as copy
148         fvMesh(const fvMesh&);
150         //- Disallow assignment
151         void operator=(const fvMesh&);
154 public:
156     // Public typedefs
158         typedef fvMesh Mesh;
159         typedef fvBoundaryMesh BoundaryMesh;
162     // Declare name of the class and its debug switch
163     ClassName("fvMesh");
166     // Constructors
168         //- Construct from IOobject
169         explicit fvMesh(const IOobject& io);
171         //- Construct from components without boundary.
172         //  Boundary is added using addFvPatches() member function
173         fvMesh
174         (
175             const IOobject& io,
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
181         );
183         //- Construct without boundary from cells rather than owner/neighbour.
184         //  Boundary is added using addPatches() member function
185         fvMesh
186         (
187             const IOobject& io,
188             const Xfer<pointField>& points,
189             const Xfer<faceList>& faces,
190             const Xfer<cellList>& cells,
191             const bool syncPar = true
192         );
195     // Destructor
197         virtual ~fvMesh();
200     // Member Functions
202         // Helpers
204             //- Add boundary patches. Constructor helper
205             void addFvPatches
206             (
207                 const List<polyPatch*>&,
208                 const bool validBoundary = true
209             );
211             //- Update the mesh based on the mesh files saved in time
212             //  directories
213             virtual readUpdateState readUpdate();
216         // Access
218             //- Return the top-level database
219             const Time& time() const
220             {
221                 return polyMesh::time();
222             }
224             //- Return the object registry - resolve conflict polyMesh/lduMesh
225             virtual const objectRegistry& thisDb() const
226             {
227                 return polyMesh::thisDb();
228             }
230             //- Return reference to name
231             //  Note: name() is currently ambiguous due to derivation from
232             //  surfaceInterpolation
233             const word& name() const
234             {
235                 return polyMesh::name();
236             }
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
247             {
248                 return boundary().interfaces();
249             }
251             //- Internal face owner
252             const unallocLabelList& owner() const
253             {
254                 return lduAddr().lowerAddr();
255             }
257             //- Internal face neighbour
258             const unallocLabelList& neighbour() const
259             {
260                 return lduAddr().upperAddr();
261             }
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;
288         // Edit
290             //- Clear all geometry and addressing
291             void clearOut();
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
303             //  these fvPatches.
304             void removeFvBoundary();
306             //- Return cell face motion fluxes
307             surfaceScalarField& setPhi();
309             //- Return old-time cell volumes
310             DimensionedField<scalar, volMesh>& setV0();
313         // Write
315             //- Write the underlying polyMesh and other data
316             virtual bool writeObjects
317             (
318                 IOstream::streamFormat fmt,
319                 IOstream::versionNumber ver,
320                 IOstream::compressionType cmp
321             ) const;
323             //- Write mesh using IO settings from time
324             virtual bool write() const;
327     // Member Operators
329         bool operator!=(const fvMesh&) const;
330         bool operator==(const fvMesh&) const;
334 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
336 } // End namespace Foam
338 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
340 #ifdef NoRepository
341 #   include "fvPatchFvMeshTemplates.C"
342 #endif
344 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
346 #endif
348 // ************************************************************************* //