Changed the option to select the generation of a C++ scanner to the backward compatib...
[OpenFOAM-1.5.x.git] / src / finiteVolume / fvMesh / fvMesh.H
blobf28c72ad4ea42f5bb87cdfa7e7cca25cdd66ac39
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open So
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2008 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 pointField& points,
177             const faceList& faces,
178             const labelList& allOwner,
179             const labelList& allNeighbour,
180             const bool syncPar = true
181         );
183         //- Construct from components with cells rather than owner
184         //  and neighbourwithout boundary.
185         //  Boundary is added using addPatches() member function
186         fvMesh
187         (
188             const IOobject& io,
189             const pointField& points,
190             const faceList& faces,
191             const cellList& cells,
192             const bool syncPar = true
193         );
196     // Destructor
198         virtual ~fvMesh();
201     // Member Functions
203         // Helpers
205             //- Add boundary patches. Constructor helper
206             void addFvPatches
207             (
208                 const List<polyPatch*>&,
209                 const bool validBoundary = true
210             );
212             //- Update the mesh based on the mesh files saved in time
213             //  directories
214             virtual readUpdateState readUpdate();
217         // Access
219             //- Return the top-level database
220             const Time& time() const
221             {
222                 return polyMesh::time();
223             }
225             //- Return the object registry
226             virtual const objectRegistry& db() const
227             {
228                 return *this;
229             }
231             //- Return reference to name 
232             //  Note: name() is currently ambiguous due to derivation from
233             //  surfaceInterpolation
234             const word& name() const
235             {
236                 return polyMesh::name();
237             }
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
248             {
249                 return boundary().interfaces();
250             }
252             //- Internal face owner
253             const unallocLabelList& owner() const
254             {
255                 return lduAddr().lowerAddr();
256             }
258             //- Internal face neighbour
259             const unallocLabelList& neighbour() const
260             {
261                 return lduAddr().upperAddr();
262             }
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;
289         // Edit
291             //- Clear all geometry and addressing
292             void clearOut();
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
304             //  these fvPatches.
305             void removeFvBoundary();
307             //- Return cell face motion fluxes
308             surfaceScalarField& setPhi();
310             //- Return old-time cell volumes
311             DimensionedField<scalar, volMesh>& setV0();
314         // Write
316             //- Write the underlying polyMesh and other data
317             virtual bool writeObjects
318             (
319                 IOstream::streamFormat fmt,
320                 IOstream::versionNumber ver,
321                 IOstream::compressionType cmp
322             ) const;
324             //- Write mesh using IO settings from time
325             virtual bool write() const;
328     // Member Operators
330         bool operator!=(const fvMesh&) const;
331         bool operator==(const fvMesh&) const;
335 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
337 } // End namespace Foam
339 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
341 #ifdef NoRepository
342 #   include "fvPatchFvMeshTemplates.C"
343 #endif
345 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
347 #endif
349 // ************************************************************************* //