FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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