OpenFOAM logo
Open Source CFD Toolkit

faMesh.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2005 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Class
00026     faMesh
00027 
00028 Description
00029     Finite area mesh.  Used for 2-D non-Euclidian finite area method.
00030 
00031 SourceFiles
00032     faMesh.C
00033     faMeshDemandDrivenData.C
00034 
00035 \*---------------------------------------------------------------------------*/
00036 
00037 #ifndef faMesh_H
00038 #define faMesh_H
00039 
00040 #include "faBoundaryMesh.H"
00041 #include "faProcTopology.H"
00042 #include "edgeList.H"
00043 #include "faceList.H"
00044 #include "primitiveFieldsFwd.H"
00045 #include "lduAddressing.H"
00046 #include "areaFieldsFwd.H"
00047 #include "edgeFieldsFwd.H"
00048 #include "indirectPrimitivePatch.H"
00049 #include "edgeInterpolation.H"
00050 #include "labelIOList.H"
00051 #include "scalarIOField.H"
00052 #include "FieldFields.H"
00053 
00054 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00055 
00056 namespace Foam
00057 {
00058 
00059 // Class forward declarations
00060 class polyMesh;
00061 class lduAddressingFaMesh;
00062 
00063 /*---------------------------------------------------------------------------*\
00064                            Class faMesh Declaration
00065 \*---------------------------------------------------------------------------*/
00066 
00067 class faMesh      
00068 :
00069     public edgeInterpolation
00070 {
00071     // Private data
00072 
00073         //- Reference to mesh
00074         const polyMesh& mesh_;
00075 
00076         //- Face labels
00077         labelIOList faceLabels_;
00078 
00079         //- Boundary mesh
00080         faBoundaryMesh boundary_;
00081 
00082 
00083         // Primitive mesh data
00084 
00085             //- Edges, addressing into local point list
00086             edgeList edges_;
00087 
00088             //- Edge owner
00089             labelList edgeOwner_;
00090 
00091             //- Edge neighbour
00092             labelList edgeNeighbour_;
00093 
00094 
00095         // Primitive size data
00096 
00097             //- Number of points
00098             mutable label nPoints_;
00099 
00100             //- Number of edges
00101             mutable label nEdges_;
00102 
00103             //- Number of internal edges
00104             mutable label nInternalEdges_;
00105 
00106             //- Number of faces
00107             mutable label nFaces_;
00108 
00109 
00110     // Demand-driven data
00111 
00112         //- Primitive patch
00113         mutable indirectPrimitivePatch* patchPtr_;
00114 
00115         //- Ldu addressing data
00116         mutable lduAddressingFaMesh* lduPtr_;
00117 
00118         //- Face areas
00119         mutable scalarField* SPtr_;
00120 
00121         //- Face areas old time level
00122         mutable scalarIOField* S0Ptr_;
00123 
00124         //- Face areas old-old time level
00125         mutable scalarIOField* S00Ptr_;
00126 
00127         //- Patch starts in the edge list
00128         mutable labelList* patchStartsPtr_;
00129 
00130         //- Edge length vectors
00131         mutable edgeVectorField* LePtr_;
00132 
00133         //- Mag edge length vectors
00134         mutable edgeScalarField* magLePtr_;
00135 
00136         //- Face centres
00137         mutable areaVectorField* centresPtr_;
00138 
00139         //- Edge centres
00140         mutable edgeVectorField* edgeCentresPtr_;
00141 
00142         //- Face area normals
00143         mutable areaVectorField* faceAreaNormalsPtr_;
00144 
00145         //- Edge area normals
00146         mutable edgeVectorField* edgeAreaNormalsPtr_;
00147 
00148         //- Edge area normals
00149         mutable vectorField* pointAreaNormalsPtr_;
00150 
00151         //- Face curvatures
00152         mutable areaScalarField* faceCurvaturesPtr_;
00153 
00154         //- Edge transformation tensors
00155         mutable FieldField<Field, tensor>* edgeTransformTensorsPtr_;
00156 
00157 
00158         // Other mesh related data
00159 
00160             //- Parallel info
00161             mutable faProcTopology* parallelDataPtr_;
00162 
00163             // Mesh motion
00164 
00165                 //- Is the mesh moving
00166                 bool moving_;
00167 
00168                 //- Current time index for mesh motion
00169                 mutable label curMotionTimeIndex_;
00170 
00171 
00172     // Private Member Functions
00173 
00174         //- Disallow default bitwise copy construct
00175         faMesh(const faMesh&);
00176 
00177         //- Disallow default bitwise assignment
00178         void operator=(const faMesh&);
00179 
00180         //- Set primitive mesh data
00181         void setPrimitiveMeshData();
00182 
00183         // Private member functions to calculate demand driven data
00184 
00185             //- Calculate ldu addressing
00186             void calcLduAddressing() const;
00187 
00188             //- Calculate patch starts in the edge list
00189             void calcPatchStarts() const;
00190 
00191             //- Calculate edge lengths
00192             void calcLe() const;
00193 
00194             //- Calculate mag edge lengths
00195             void calcMagLe() const;
00196 
00197             //- Calculate face centres
00198             void calcCentres() const;
00199 
00200             //- Calculate edge centres
00201             void calcEdgeCentres() const;
00202 
00203             //- Calculate face areas
00204             void calcS() const;
00205 
00206             //- Calculate face area normals
00207             void calcFaceAreaNormals() const;
00208 
00209             //- Calculate edge area normals
00210             void calcEdgeAreaNormals() const;
00211 
00212             //- Calculate point area normals
00213             void calcPointAreaNormals() const;
00214 
00215             //- Calculate face curvatures
00216             void calcFaceCurvatures() const;
00217 
00218             //- Calculate edge transformation tensors
00219             void calcEdgeTransformTensors() const;
00220 
00221             //- Clear geometry but not the face areas
00222             void clearGeomNotAreas() const;
00223 
00224             //- Clear geometry
00225             void clearGeom() const;
00226 
00227             //- Clear addressing
00228             void clearAddressing() const;
00229 
00230             //- Clear demand-driven data
00231             void clearOut() const;
00232 
00233 public:
00234 
00235     // Public typedefs
00236 
00237         typedef faMesh Mesh;
00238         typedef faBoundaryMesh BoundaryMesh;
00239 
00240 
00241     // Static data members
00242 
00243     // Declare name of the class and it's debug switch
00244     TypeName("faMesh");
00245 
00246     //- Return the mesh sub-directory name (usually "faMesh")
00247     static word meshSubDir;
00248 
00249 
00250     // Constructors
00251 
00252         //- Construct from objectRegistry, polyMesh reference
00253         //  and read/write options
00254         faMesh
00255         (
00256             const polyMesh& m,
00257             IOobject::readOption r=IOobject::MUST_READ,
00258             IOobject::writeOption w=IOobject::AUTO_WRITE
00259         );
00260 
00261         //- Construct from components without boundary.
00262         //  Boundary is added using addFaPatches() member function
00263         faMesh
00264         (
00265             const polyMesh& m,
00266             const labelList& faceLabels,
00267             IOobject::readOption r=IOobject::NO_READ,
00268             IOobject::writeOption w=IOobject::AUTO_WRITE
00269         );
00270 
00271 
00272     // Destructor
00273 
00274         virtual ~faMesh();
00275 
00276 
00277     // Member Functions
00278 
00279         // Database
00280 
00281             //- Return the local mesh directory (dbDir()/meshSubDir)
00282             fileName meshDir() const;
00283 
00284             //- Return reference to time
00285             const Time& time() const;
00286 
00287 
00288             //- Mesh size parameters
00289 
00290                 inline label nPoints() const
00291                 {
00292                     return nPoints_;
00293                 }
00294 
00295                 inline label nEdges() const
00296                 {
00297                     return nEdges_;
00298                 }
00299 
00300                 inline label nInternalEdges() const
00301                 {
00302                     return nInternalEdges_;
00303                 }
00304 
00305                 inline label nFaces() const
00306                 {
00307                     return nFaces_;
00308                 }
00309 
00310             // Primitive mesh data
00311 
00312                 //- Return mesh points
00313                 const pointField& points() const;
00314 
00315                 //- Return edges
00316                 const edgeList& edges() const;
00317 
00318                 //- Return faces
00319                 const faceList& faces() const;
00320 
00321                 //- Edge owner addresing
00322                 inline const labelList& edgeOwner() const
00323                 {
00324                     return edgeOwner_;
00325                 }
00326 
00327                 //- Edge neighbour addressing
00328                 inline const labelList& edgeNeighbour() const
00329                 {
00330                     return edgeNeighbour_;
00331                 }
00332 
00333 
00334 
00335         //- Add boundary patches. Constructor helper
00336         void addFaPatches(const List<faPatch*> &);
00337 
00338         //- Return reference to the mesh database
00339         const objectRegistry& db() const;
00340 
00341         //- Return constant reference to boundary mesh
00342         const faBoundaryMesh& boundary() const;
00343 
00344         //- Return reference to boundary mesh
00345         faBoundaryMesh& boundary();
00346 
00347         //- Return faMesh face labels
00348         const labelList& faceLabels() const
00349         {
00350             return faceLabels_;
00351         }
00352 
00353 
00354         //- Return parallel info
00355         const faProcTopology& parallelData() const;
00356 
00357 
00358         // Mesh motion
00359 
00360             //- Is mesh moving
00361             bool moving() const
00362             {
00363                 return moving_;
00364             }
00365 
00366             //- Move points, returns volumes swept by faces in motion
00367             virtual tmp<scalarField> movePoints(const vectorField&);
00368 
00369 
00370         // Demand-driven data
00371 
00372             //- Return constant reference to primitive patch
00373             const indirectPrimitivePatch& patch() const;
00374 
00375             //- Return reference to primitive patch
00376             indirectPrimitivePatch& patch();
00377 
00378             //- Return ldu addressing
00379             const lduAddressing& ldu() const;
00380 
00381             //- Return patch starts
00382             const labelList& patchStarts() const;
00383 
00384             //- Return edge length vectors
00385             const edgeVectorField& Le() const;
00386 
00387             //- Return edge length magnitudes
00388             const edgeScalarField& magLe() const;
00389 
00390             //- Return face centres as areaVectorField
00391             const areaVectorField& centres() const;
00392 
00393             //- Return edge centres as edgeVectorField
00394             const edgeVectorField& edgeCentres() const;
00395 
00396             //- Return face areas
00397             const scalarField& S() const;
00398 
00399             //- Return old-time face areas
00400             const scalarField& S0() const;
00401 
00402             //- Return old-old-time face areas
00403             const scalarField& S00() const;
00404 
00405             //- Return face area normals
00406             const areaVectorField& faceAreaNormals() const;
00407 
00408             //- Return edge area normals
00409             const edgeVectorField& edgeAreaNormals() const;
00410 
00411             //- Return point area normals
00412             const vectorField& pointAreaNormals() const;
00413 
00414             //- Return face curvatures
00415             const areaScalarField& faceCurvatures() const;
00416 
00417             //- Return edge transformation tensors
00418             const FieldField<Field, tensor>& edgeTransformTensors() const;
00419 
00420             //- Return internal point labels
00421             labelList internalPoints() const;
00422 
00423             //- Return boundary point labels
00424             labelList boundaryPoints() const;
00425 
00426             //- Return edge length correction
00427             tmp<edgeScalarField> edgeLengthCorrection() const;
00428 
00429             // For consistency with older nomenclature, provide
00430             // wrapping for owner/neighbour addressing from faMesh
00431 
00432             //- Internal face owner
00433             const unallocLabelList& owner() const
00434             {
00435                 return ldu().lowerAddr();
00436             }
00437 
00438             //- Internal face neighbour
00439             const unallocLabelList& neighbour() const
00440             {
00441                 return ldu().upperAddr();
00442             }
00443 
00444 
00445         // Edit
00446 
00447             //- Write mesh
00448             bool write
00449             (
00450                 IOstream::streamFormat fmt,
00451                 IOstream::versionNumber ver,
00452                 IOstream::compressionType cmp
00453             ) const;
00454 
00455 
00456     // Member Operators
00457 
00458         //- Return reference to polyMesh
00459         const polyMesh& operator()() const
00460         {
00461             return mesh_;
00462         }
00463 
00464         bool operator!=(const faMesh& m) const;
00465 
00466         bool operator==(const faMesh& m) const;
00467 
00468 
00469     // Friend Functions
00470 
00471     // Friend Operators
00472 
00473     // IOstream Operators
00474 
00475     friend Ostream& operator<<(Ostream&, const faMesh&);
00476 };
00477 
00478 
00479 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00480 
00481 } // End namespace Foam
00482 
00483 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00484 
00485 #endif
00486 
00487 // ************************************************************************* //
For further information go to www.openfoam.org