FreeFOAM The Cross-Platform CFD Toolkit
fvMesh.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2011 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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.
20 
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/>.
23 
24 Class
25  Foam::fvMesh
26 
27 Description
28  Mesh data needed to do the Finite Volume discretisation.
29 
30  NOTE ON USAGE:
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.
40 
41 SourceFiles
42  fvMesh.C
43  fvMeshGeometry.C
44 
45 \*---------------------------------------------------------------------------*/
46 
47 #ifndef fvMesh_H
48 #define fvMesh_H
49 
50 #include <OpenFOAM/polyMesh.H>
51 #include <OpenFOAM/lduMesh.H>
52 #include <OpenFOAM/primitiveMesh.H>
61 #include <OpenFOAM/className.H>
62 
63 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
64 
65 namespace Foam
66 {
67 
68 class fvMeshLduAddressing;
69 class volMesh;
70 
71 
72 /*---------------------------------------------------------------------------*\
73  Class fvMesh Declaration
74 \*---------------------------------------------------------------------------*/
75 
76 class fvMesh
77 :
78  public polyMesh,
79  public lduMesh,
81 {
82  // Private data
83 
84  //- Boundary mesh
85  fvBoundaryMesh boundary_;
86 
87 
88  // Demand-driven data
89 
90  mutable fvMeshLduAddressing* lduPtr_;
91 
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_;
97 
98  //- Cell volumes old time level
99  mutable void* VPtr_;
100 
101  //- Cell volumes old time level
102  mutable DimensionedField<scalar, volMesh>* V0Ptr_;
103 
104  //- Cell volumes old-old time level
105  mutable DimensionedField<scalar, volMesh>* V00Ptr_;
106 
107  //- Face area vectors
108  mutable slicedSurfaceVectorField* SfPtr_;
109 
110  //- Mag face area vectors
111  mutable surfaceScalarField* magSfPtr_;
112 
113  //- Cell centres
114  mutable slicedVolVectorField* CPtr_;
115 
116  //- Face centres
117  mutable slicedSurfaceVectorField* CfPtr_;
118 
119  //- Face motion fluxes
120  mutable surfaceScalarField* phiPtr_;
121 
122 
123  // Private Member Functions
124 
125  // Storage management
126 
127  //- Clear geometry but not the old-time cell volumes
128  void clearGeomNotOldVol();
129 
130  //- Clear geometry
131  void clearGeom();
132 
133  //- Clear addressing
134  void clearAddressing();
135 
136 
137  // Make geometric data
138 
139  void makeSf() const;
140  void makeMagSf() const;
141 
142  void makeC() const;
143  void makeCf() const;
144 
145 
146  //- Disallow construct as copy
147  fvMesh(const fvMesh&);
148 
149  //- Disallow assignment
150  void operator=(const fvMesh&);
151 
152 
153 public:
154 
155  // Public typedefs
156 
157  typedef fvMesh Mesh;
159 
160 
161  // Declare name of the class and its debug switch
162  ClassName("fvMesh");
163 
164 
165  // Constructors
166 
167  //- Construct from IOobject
168  explicit fvMesh(const IOobject& io);
169 
170  //- Construct from components without boundary.
171  // Boundary is added using addFvPatches() member function
172  fvMesh
173  (
174  const IOobject& io,
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
180  );
181 
182  //- Construct without boundary from cells rather than owner/neighbour.
183  // Boundary is added using addPatches() member function
184  fvMesh
185  (
186  const IOobject& io,
187  const Xfer<pointField>& points,
188  const Xfer<faceList>& faces,
189  const Xfer<cellList>& cells,
190  const bool syncPar = true
191  );
192 
193 
194  // Destructor
195 
196  virtual ~fvMesh();
197 
198 
199  // Member Functions
200 
201  // Helpers
202 
203  //- Add boundary patches. Constructor helper
204  void addFvPatches
205  (
206  const List<polyPatch*>&,
207  const bool validBoundary = true
208  );
209 
210  //- Update the mesh based on the mesh files saved in time
211  // directories
212  virtual readUpdateState readUpdate();
213 
214 
215  // Access
216 
217  //- Return the top-level database
218  const Time& time() const
219  {
220  return polyMesh::time();
221  }
222 
223  //- Return the object registry - resolve conflict polyMesh/lduMesh
224  virtual const objectRegistry& thisDb() const
225  {
226  return polyMesh::thisDb();
227  }
228 
229  //- Return reference to name
230  // Note: name() is currently ambiguous due to derivation from
231  // surfaceInterpolation
232  const word& name() const
233  {
234  return polyMesh::name();
235  }
236 
237  //- Return reference to boundary mesh
238  const fvBoundaryMesh& boundary() const;
239 
240  //- Return ldu addressing
241  virtual const lduAddressing& lduAddr() const;
242 
243  //- Return a list of pointers for each patch
244  // with only those pointing to interfaces being set
246  {
247  return boundary().interfaces();
248  }
249 
250  //- Internal face owner
251  const unallocLabelList& owner() const
252  {
253  return lduAddr().lowerAddr();
254  }
255 
256  //- Internal face neighbour
258  {
259  return lduAddr().upperAddr();
260  }
261 
262  //- Return cell volumes
263  const DimensionedField<scalar, volMesh>& V() const;
264 
265  //- Return old-time cell volumes
266  const DimensionedField<scalar, volMesh>& V0() const;
267 
268  //- Return old-old-time cell volumes
269  const DimensionedField<scalar, volMesh>& V00() const;
270 
271  //- Return sub-cycle cell volumes
273 
274  //- Return sub-cycl old-time cell volumes
276 
277  //- Return cell face area vectors
278  const surfaceVectorField& Sf() const;
279 
280  //- Return cell face area magnitudes
281  const surfaceScalarField& magSf() const;
282 
283  //- Return cell face motion fluxes
284  const surfaceScalarField& phi() const;
285 
286  //- Return cell centres as volVectorField
287  const volVectorField& C() const;
288 
289  //- Return face centres as surfaceVectorField
290  const surfaceVectorField& Cf() const;
291 
292 
293  // Edit
294 
295  //- Clear all geometry and addressing
296  void clearOut();
297 
298  //- Update mesh corresponding to the given map
299  virtual void updateMesh(const mapPolyMesh& mpm);
300 
301  //- Move points, returns volumes swept by faces in motion
302  virtual tmp<scalarField> movePoints(const pointField&);
303 
304  //- Map all fields in time using given map.
305  virtual void mapFields(const mapPolyMesh& mpm);
306 
307  //- Remove boundary patches. Warning: fvPatchFields hold ref to
308  // these fvPatches.
309  void removeFvBoundary();
310 
311  //- Return cell face motion fluxes
313 
314  //- Return old-time cell volumes
316 
317 
318  // Write
319 
320  //- Write the underlying polyMesh and other data
321  virtual bool writeObjects
322  (
326  ) const;
327 
328  //- Write mesh using IO settings from time
329  virtual bool write() const;
330 
331 
332  // Member Operators
333 
334  bool operator!=(const fvMesh&) const;
335  bool operator==(const fvMesh&) const;
336 };
337 
338 
339 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
340 
341 } // End namespace Foam
342 
343 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
344 
345 #ifdef NoRepository
347 #endif
348 
349 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
350 
351 #endif
352 
353 // ************************ vim: set sw=4 sts=4 et: ************************ //