OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

surfMesh.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-2009 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     Foam::surfMesh
00027 
00028 Description
00029     A surface mesh consisting of general polygon faces.
00030 
00031 SourceFiles
00032     surfMesh.C
00033     surfMeshClear.C
00034     surfMeshIO.C
00035 
00036 \*---------------------------------------------------------------------------*/
00037 
00038 #ifndef surfMesh_H
00039 #define surfMesh_H
00040 
00041 #include "surfaceRegistry.H"
00042 #include "MeshedSurfaceIOAllocator.H"
00043 #include "PrimitivePatch.H"
00044 #include "SubField.H"
00045 
00046 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00047 
00048 namespace Foam
00049 {
00050 
00051 template<class Face> class MeshedSurface;
00052 
00053 /*---------------------------------------------------------------------------*\
00054                           Class surfMesh Declaration
00055 \*---------------------------------------------------------------------------*/
00056 
00057 class surfMesh
00058 :
00059     public  surfaceRegistry,
00060     private MeshedSurfaceIOAllocator,
00061     public  PrimitivePatch<face, ::Foam::UList, ::Foam::SubField<point>, point>
00062 {
00063     // friends
00064     template<class Face> friend class MeshedSurface;
00065     template<class Face> friend class UnsortedMeshedSurface;
00066 
00067 public:
00068 
00069     // Public data types
00070 
00071         //- Enumeration defining the state of the mesh after a read update.
00072         //  Used for post-processing applications, where the mesh
00073         //  needs to update based on the files written in time directores
00074         enum readUpdateState
00075         {
00076             UNCHANGED,
00077             POINTS_MOVED,
00078             TOPO_CHANGE,
00079             TOPO_PATCH_CHANGE
00080         };
00081 
00082 
00083 private:
00084 
00085     // Private typedefs
00086 
00087         typedef MeshedSurfaceIOAllocator Allocator;
00088 
00089         typedef PrimitivePatch
00090         <
00091             face,
00092             ::Foam::UList,
00093             ::Foam::SubField<point>,
00094             point
00095         >
00096         MeshReference;
00097 
00098 
00099     // Private member functions
00100 
00101         //- Disallow construct as copy
00102         surfMesh(const surfMesh&);
00103 
00104         //- Disallow default bitwise assignment
00105         void operator=(const surfMesh&);
00106 
00107 
00108 protected:
00109 
00110     // Protected Member Functions
00111 
00112         //- Non-const access to global points
00113         pointField& storedPoints()
00114         {
00115             return Allocator::storedIOPoints();
00116         }
00117 
00118         //- Non-const access to the faces
00119         faceList& storedFaces()
00120         {
00121             return Allocator::storedIOFaces();
00122         }
00123 
00124         //- Non-const access to the zones
00125         surfZoneList& storedZones()
00126         {
00127             return Allocator::storedIOZones();
00128         }
00129 
00130         //- Update references to storedFaces
00131         virtual void updateFacesRef();
00132 
00133         //- Update references to storedPoints
00134         virtual void updatePointsRef();
00135 
00136         //- Update references to storedPoints/storedFaces
00137         virtual void updateRefs();
00138 
00139 
00140 public:
00141 
00142     // Public typedefs
00143 
00144     typedef surfMesh Mesh;
00145 
00146     //- Placeholder only, but do not remove - it is needed for GeoMesh
00147     typedef bool BoundaryMesh;
00148 
00149 
00150     //- Runtime type information
00151     TypeName("surfMesh");
00152 
00153     //- Return the mesh sub-directory name (normally "surfMesh")
00154     static word meshSubDir;
00155 
00156     // Constructors
00157 
00158         //- Construct from IOobject, with alternative surface name
00159         explicit surfMesh(const IOobject&, const word& surfName="");
00160 
00161         //- Construct by transferring components (points, faces) without zones.
00162         //  surfZones are added using addZones() member function
00163         surfMesh
00164         (
00165             const IOobject&,
00166             const Xfer<pointField>&,
00167             const Xfer<faceList>&,
00168             const word& surfName=""
00169         );
00170 
00171         //- Construct copy/move from MeshedSurface
00172         surfMesh
00173         (
00174             const IOobject&,
00175             const Xfer< MeshedSurface<face> >& surf,
00176             const word& surfName=""
00177         );
00178 
00179 
00180     // Destructor
00181 
00182         virtual ~surfMesh();
00183 
00184 
00185     // Member Functions
00186 
00187         // Database
00188 
00189             //- Return the local mesh directory (dbDir()/meshSubDir)
00190             fileName meshDir() const;
00191 
00192             //- Return the current instance directory for points
00193             //  Used in the consruction of geometric mesh data dependent
00194             //  on points
00195             const fileName& pointsInstance() const;
00196 
00197             //- Return the current instance directory for faces
00198             const fileName& facesInstance() const;
00199 
00200             //- Set the instance for mesh files
00201             void setInstance(const fileName&);
00202 
00203 
00204         // Access
00205 
00206             //- Return the number of raw points
00207             virtual label nPoints() const;
00208 
00209             //- Return the number of raw faces
00210             virtual label nFaces() const;
00211 
00212             //- Return number of faces
00213             virtual label size() const
00214             {
00215                 return nFaces();
00216             }
00217 
00218 
00219             //- Return points
00220             virtual const pointField& points() const;
00221 
00222             //- Return faces
00223             virtual const faceList& faces() const;
00224 
00225             //- Return surface zones
00226             virtual const surfZoneList& surfZones() const
00227             {
00228                 return Allocator::storedIOZones();
00229             }
00230 
00231             //- Check the surface zone definitions
00232             void checkZones();
00233 
00234             //- Add surface zones
00235             void addZones
00236             (
00237                 const List<surfZone>&,
00238                 const bool validate = true
00239             );
00240 
00241             //- Update the mesh based on the mesh files saved in
00242             //  time directories
00243             virtual readUpdateState readUpdate();
00244 
00245             //- Update the mesh corresponding to given map
00246 
00247             //- Remove surface zones
00248             void removeZones();
00249 
00250             //- Reset mesh primitive data.
00251             void resetPrimitives
00252             (
00253                 const Xfer< pointField >& points,
00254                 const Xfer< faceList >& faces,
00255                 const Xfer< surfZoneList >& zones,
00256                 const bool validate = true
00257             );
00258 
00259 
00260             //- Transfer the contents of the argument and annull the argument
00261             void transfer(MeshedSurface<face>&);
00262 
00263 
00264         //- Avoid masking the normal objectRegistry write
00265         using surfaceRegistry::write;
00266 
00267         //- Write to file
00268         static void write(const fileName&, const surfMesh&);
00269 
00270         //- Write to file
00271         void write(const fileName&);
00272 
00273         //  Storage management
00274 
00275             //- Transfer contents to the Xfer container as a MeshedSurface
00276             Xfer< MeshedSurface<face> > xfer();
00277 
00278             //- Clear geometry
00279             void clearGeom();
00280 
00281             //- Clear addressing
00282             void clearAddressing();
00283 
00284             //- Clear all geometry and addressing unnecessary for CFD
00285             void clearOut();
00286 
00287             //- Clear primitive data (points, faces and cells)
00288             void clearPrimitives();
00289 
00290             //- Remove all files from mesh instance
00291             void removeFiles(const fileName& instanceDir) const;
00292 
00293             //- Remove all files from mesh instance()
00294             void removeFiles() const;
00295 };
00296 
00297 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00298 
00299 } // End namespace Foam
00300 
00301 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00302 
00303 #endif
00304 
00305 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd