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 Finite area mesh. Used for 2-D non-Euclidian finite area method.
33 faMeshDemandDrivenData.C
35 \*---------------------------------------------------------------------------*/
43 #include "faBoundaryMesh.H"
46 #include "primitiveFieldsFwd.H"
47 #include "DimensionedField.H"
48 #include "areaFieldsFwd.H"
49 #include "edgeFieldsFwd.H"
50 #include "indirectPrimitivePatch.H"
51 #include "edgeInterpolation.H"
52 #include "labelIOList.H"
53 #include "scalarIOField.H"
54 #include "FieldFields.H"
55 #include "faGlobalMeshData.H"
57 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
62 // Class forward declarations
63 class faMeshLduAddressing;
65 /*---------------------------------------------------------------------------*\
66 Class faMesh Declaration
67 \*---------------------------------------------------------------------------*/
71 public GeoMesh<polyMesh>,
73 public edgeInterpolation
78 labelIOList faceLabels_;
81 faBoundaryMesh boundary_;
84 // Primitive mesh data
86 //- Edges, addressing into local point list
93 labelList edgeNeighbour_;
96 // Primitive size data
99 mutable label nPoints_;
102 mutable label nEdges_;
104 //- Number of internal edges
105 mutable label nInternalEdges_;
108 mutable label nFaces_;
111 // Demand-driven data
114 mutable indirectPrimitivePatch* patchPtr_;
116 //- Ldu addressing data
117 mutable faMeshLduAddressing* lduPtr_;
120 mutable DimensionedField<scalar, areaMesh>* SPtr_;
122 //- Face areas old time level
123 mutable DimensionedField<scalar, areaMesh>* S0Ptr_;
125 //- Face areas old-old time level
126 mutable DimensionedField<scalar, areaMesh>* S00Ptr_;
128 //- Patch starts in the edge list
129 mutable labelList* patchStartsPtr_;
131 //- Edge length vectors
132 mutable edgeVectorField* LePtr_;
134 //- Mag edge length vectors
135 mutable edgeScalarField* magLePtr_;
138 mutable areaVectorField* centresPtr_;
141 mutable edgeVectorField* edgeCentresPtr_;
143 //- Face area normals
144 mutable areaVectorField* faceAreaNormalsPtr_;
146 //- Edge area normals
147 mutable edgeVectorField* edgeAreaNormalsPtr_;
149 //- Edge area normals
150 mutable vectorField* pointAreaNormalsPtr_;
153 mutable areaScalarField* faceCurvaturesPtr_;
155 //- Edge transformation tensors
156 mutable FieldField<Field, tensor>* edgeTransformTensorsPtr_;
158 //- Whether point normals must be corrected for a patch
159 mutable boolList* correctPatchPointNormalsPtr_;
161 // Other mesh-related data
164 mutable faGlobalMeshData* globalMeshDataPtr_;
168 //- Is the mesh moving
171 //- Current time index for mesh motion
172 mutable label curMotionTimeIndex_;
175 // Static Private Data
177 static const bool quadricsFit_;
180 // Private Member Functions
182 //- Disallow default bitwise copy construct
183 faMesh(const faMesh&);
185 //- Disallow default bitwise assignment
186 void operator=(const faMesh&);
189 //- Set primitive mesh data
190 void setPrimitiveMeshData();
192 // Private member functions to calculate demand driven data
194 //- Calculate ldu addressing
195 void calcLduAddressing() const;
197 //- Calculate patch starts in the edge list
198 void calcPatchStarts() const;
200 //- Calculate edge lengths
203 //- Calculate mag edge lengths
204 void calcMagLe() const;
206 //- Calculate face centres
207 void calcAreaCentres() const;
209 //- Calculate edge centres
210 void calcEdgeCentres() const;
212 //- Calculate face areas
215 //- Calculate face area normals
216 void calcFaceAreaNormals() const;
218 //- Calculate edge area normals
219 void calcEdgeAreaNormals() const;
221 //- Calculate point area normals
222 void calcPointAreaNormals() const;
224 //- Calculate point area normals by quadrics fit
225 void calcPointAreaNormalsByQuadricsFit() const;
227 //- Calculate face curvatures
228 void calcFaceCurvatures() const;
230 //- Calculate edge transformation tensors
231 void calcEdgeTransformTensors() const;
233 //- Clear geometry but not the face areas
234 void clearGeomNotAreas() const;
237 void clearGeom() const;
240 void clearAddressing() const;
242 //- Clear demand-driven data
243 void clearOut() const;
250 typedef faBoundaryMesh BoundaryMesh;
253 //- Runtime type information
257 //- Return the mesh sub-directory name (usually "faMesh")
258 static word meshSubDir;
263 //- Construct from polyMesh
264 explicit faMesh(const polyMesh& m);
266 //- Construct from components without boundary.
267 // Boundary is added using addFaPatches() member function
271 const labelList& faceLabels
274 //- Construct from finite area mesh definition file
278 const fileName& defFile
281 //- Construct from polyPatch
285 const label polyPatchID
298 //- Add boundary patches. Constructor helper
299 void addFaPatches(const List<faPatch*> &);
304 //- Return the local mesh directory (dbDir()/meshSubDir)
305 fileName meshDir() const;
307 //- Return reference to time
308 const Time& time() const;
310 //- Return the current instance directory for points
311 // Used in the consruction of gemometric mesh data dependent
313 const fileName& pointsInstance() const;
315 //- Return the current instance directory for faces
316 const fileName& facesInstance() const;
319 //- Mesh size parameters
321 inline label nPoints() const
326 inline label nEdges() const
331 inline label nInternalEdges() const
333 return nInternalEdges_;
336 inline label nFaces() const
341 // Primitive mesh data
343 //- Return mesh points
344 const pointField& points() const;
347 const edgeList& edges() const;
350 const faceList& faces() const;
352 //- Edge owner addresing
353 inline const labelList& edgeOwner() const
358 //- Edge neighbour addressing
359 inline const labelList& edgeNeighbour() const
361 return edgeNeighbour_;
367 //- Return reference to the mesh database
368 virtual const objectRegistry& thisDb() const;
370 //- Return constant reference to boundary mesh
371 const faBoundaryMesh& boundary() const;
373 //- Return faMesh face labels
374 const labelList& faceLabels() const
380 //- Return parallel info
381 const faGlobalMeshData& globalData() const;
383 //- Return ldu addressing
384 virtual const lduAddressing& lduAddr() const;
386 //- Return a list of pointers for each patch
387 // with only those pointing to interfaces being set
388 virtual lduInterfacePtrsList interfaces() const
390 return boundary().interfaces();
393 //- Internal face owner
394 const unallocLabelList& owner() const
396 return lduAddr().lowerAddr();
399 //- Internal face neighbour
400 const unallocLabelList& neighbour() const
402 return lduAddr().upperAddr();
405 //- Return true if given edge label is internal to the mesh
406 inline bool isInternalEdge(const label edgeIndex) const
408 return edgeIndex < nInternalEdges();
420 //- Move points, returns volumes swept by faces in motion
421 virtual tmp<scalarField> movePoints(const vectorField&);
424 // Demand-driven data
426 //- Return constant reference to primitive patch
427 const indirectPrimitivePatch& patch() const;
429 //- Return reference to primitive patch
430 indirectPrimitivePatch& patch();
432 //- Return patch starts
433 const labelList& patchStarts() const;
435 //- Return edge length vectors
436 const edgeVectorField& Le() const;
438 //- Return edge length magnitudes
439 const edgeScalarField& magLe() const;
441 //- Return face centres as areaVectorField
442 const areaVectorField& areaCentres() const;
444 //- Return edge centres as edgeVectorField
445 const edgeVectorField& edgeCentres() const;
447 //- Return face areas
448 const DimensionedField<scalar, areaMesh>& S() const;
450 //- Return old-time face areas
451 const DimensionedField<scalar, areaMesh>& S0() const;
453 //- Return old-old-time face areas
454 const DimensionedField<scalar, areaMesh>& S00() const;
456 //- Return face area normals
457 const areaVectorField& faceAreaNormals() const;
459 //- Return edge area normals
460 const edgeVectorField& edgeAreaNormals() const;
462 //- Return point area normals
463 const vectorField& pointAreaNormals() const;
465 //- Return face curvatures
466 const areaScalarField& faceCurvatures() const;
468 //- Return edge transformation tensors
469 const FieldField<Field, tensor>& edgeTransformTensors() const;
471 //- Return internal point labels
472 labelList internalPoints() const;
474 //- Return boundary point labels
475 labelList boundaryPoints() const;
477 //- Return edge length correction
478 tmp<edgeScalarField> edgeLengthCorrection() const;
480 //- Whether point normals should be corrected for a patch
481 bool correctPatchPointNormals(const label patchID) const;
483 //- Set whether point normals should be corrected for a patch
484 boolList& correctPatchPointNormals() const;
487 virtual bool write() const;
492 bool operator!=(const faMesh& m) const;
494 bool operator==(const faMesh& m) const;
498 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
500 } // End namespace Foam
502 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
505 # include "faPatchFaMeshTemplates.C"
508 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
512 // ************************************************************************* //