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

UnsortedMeshedSurface.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::UnsortedMeshedSurface
00027 
00028 Description
00029     A surface geometry mesh, in which the surface zone information is
00030     conveyed by the 'zoneId' associated with each face.
00031 
00032     This form of surface description is particularly useful for reading in
00033     surface meshes from third-party formats (eg, obj, stl, gts, etc.). It
00034     can also be particularly useful for situations in which the surface
00035     many be adjusted in an arbitrary manner without worrying about needed
00036     to adjust the zone information (eg, surface refinement).
00037 
00038 See Also
00039     The Foam::MeshedSurface - which is organized as a surface mesh, but
00040     with independent zone information.
00041 
00042 SourceFiles
00043     UnsortedMeshedSurface.C
00044 
00045 \*---------------------------------------------------------------------------*/
00046 
00047 #ifndef UnsortedMeshedSurface_H
00048 #define UnsortedMeshedSurface_H
00049 
00050 #include "MeshedSurface.H"
00051 #include "surfZoneIdentifierList.H"
00052 #include "surfZoneList.H"
00053 #include "surfaceFormatsCore.H"
00054 #include "runTimeSelectionTables.H"
00055 #include "memberFunctionSelectionTables.H"
00056 #include "HashSet.H"
00057 
00058 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00059 
00060 namespace Foam
00061 {
00062 
00063 // Forward declaration of friend functions and operators
00064 
00065 class Time;
00066 class IFstream;
00067 
00068 template<class Face> class MeshedSurface;
00069 template<class Face> class MeshedSurfaceProxy;
00070 template<class Face> class UnsortedMeshedSurface;
00071 
00072 /*---------------------------------------------------------------------------*\
00073                    Class UnsortedMeshedSurface Declaration
00074 \*---------------------------------------------------------------------------*/
00075 
00076 template<class Face>
00077 class UnsortedMeshedSurface
00078 :
00079     public MeshedSurface<Face>
00080 {
00081     // friends - despite different face representationsx
00082     template<class Face2> friend class MeshedSurface;
00083     template<class Face2> friend class UnsortedMeshedSurface;
00084     friend class surfMesh;
00085 
00086 private:
00087 
00088     //- Private typedefs for convenience
00089 
00090         typedef MeshedSurface<Face>       ParentType;
00091         typedef MeshedSurface<Face>       FriendType;
00092         typedef MeshedSurfaceProxy<Face>  ProxyType;
00093 
00094 
00095     // Private Member Data
00096 
00097         //- The zone Id associated with each face
00098         labelList zoneIds_;
00099 
00100         //- Zone information (face ordering nFaces/startFace only used
00101         //  during reading and writing)
00102         List<surfZoneIdentifier> zoneToc_;
00103 
00104 
00105     // Private member functions
00106 
00107         //- Disable resize with value
00108         void resize(const label, const Face&);
00109 
00110         //- Disable setSize with value
00111         void setSize(const label, const Face&);
00112 
00113         //- Read OpenFOAM Surface format
00114         bool read(Istream&);
00115 
00116 
00117 protected:
00118 
00119     // Protected Member functions
00120 
00121         //- Return non-const access to the zone Ids
00122         List<label>& storedZoneIds()
00123         {
00124             return zoneIds_;
00125         }
00126 
00127         //- Return non-const access to the zone table-of-contents
00128         List<surfZoneIdentifier>& storedZoneToc()
00129         {
00130             return zoneToc_;
00131         }
00132 
00133         //- Set new zones from faceMap
00134         virtual void remapFaces(const UList<label>& faceMap);
00135 
00136 
00137 public:
00138 
00139         //- Runtime type information
00140         TypeName("UnsortedMeshedSurface");
00141 
00142 
00143     // Static
00144 
00145         //- Can we read this file format?
00146         static bool canReadType(const word& ext, const bool verbose=false);
00147 
00148         //- Can we read this file format?
00149         static bool canRead(const fileName&, const bool verbose=false);
00150 
00151         //- Can we write this file format?
00152         static bool canWriteType(const word& ext, const bool verbose=false);
00153 
00154         static wordHashSet readTypes();
00155         static wordHashSet writeTypes();
00156 
00157 
00158     // Constructors
00159 
00160         //- Construct null
00161         UnsortedMeshedSurface();
00162 
00163         //- Construct by transferring components
00164         //  (points, faces, zone ids, zone info).
00165         UnsortedMeshedSurface
00166         (
00167             const Xfer< pointField >&,
00168             const Xfer< List<Face> >&,
00169             const Xfer< List<label> >& zoneIds,
00170             const Xfer< surfZoneIdentifierList >&
00171         );
00172 
00173         //- Construct by transferring points, faces.
00174         //  Use zone information, or set single default zone
00175         UnsortedMeshedSurface
00176         (
00177             const Xfer<pointField>&,
00178             const Xfer<List<Face> >&,
00179             const UList<label>& zoneSizes = UList<label>(),
00180             const UList<word>& zoneNames = UList<word>()
00181         );
00182 
00183         //- Construct as copy
00184         UnsortedMeshedSurface(const UnsortedMeshedSurface<Face>&);
00185 
00186         //- Construct from a meshedSurface
00187         UnsortedMeshedSurface(const MeshedSurface<Face>&);
00188 
00189         //- Construct by transferring the contents from a UnsortedMeshedSurface
00190         UnsortedMeshedSurface(const Xfer<UnsortedMeshedSurface<Face> >&);
00191 
00192         //- Construct by transferring the contents from a meshedSurface
00193         UnsortedMeshedSurface(const Xfer<MeshedSurface<Face> >&);
00194 
00195         //- Construct from file name (uses extension to determine type)
00196         UnsortedMeshedSurface(const fileName&);
00197 
00198         //- Construct from file name (uses extension to determine type)
00199         UnsortedMeshedSurface(const fileName&, const word&);
00200 
00201         //- Construct from Istream
00202         UnsortedMeshedSurface(Istream&);
00203 
00204         //- Construct from objectRegistry and a named surface
00205         UnsortedMeshedSurface(const Time&, const word& surfName="");
00206 
00207 
00208     // Declare run-time constructor selection table
00209 
00210         declareRunTimeSelectionTable
00211         (
00212             autoPtr,
00213             UnsortedMeshedSurface,
00214             fileExtension,
00215             (
00216                 const fileName& name
00217             ),
00218             (name)
00219         );
00220 
00221 
00222     // Selectors
00223 
00224         //- Select constructed from filename (explicit extension)
00225         static autoPtr<UnsortedMeshedSurface> New
00226         (
00227             const fileName&,
00228             const word& ext
00229         );
00230 
00231         //- Select constructed from filename (implicit extension)
00232         static autoPtr<UnsortedMeshedSurface> New(const fileName&);
00233 
00234 
00235     // Destructor
00236 
00237         virtual ~UnsortedMeshedSurface();
00238 
00239 
00240     // Member Function Selectors
00241 
00242         declareMemberFunctionSelectionTable
00243         (
00244             void,
00245             UnsortedMeshedSurface,
00246             write,
00247             fileExtension,
00248             (
00249                 const fileName& name,
00250                 const UnsortedMeshedSurface<Face>& surf
00251             ),
00252             (name, surf)
00253         );
00254 
00255         //- Write to file
00256         static void write(const fileName&, const UnsortedMeshedSurface<Face>&);
00257 
00258 
00259     // Member Functions
00260 
00261         // Access
00262 
00263             //- The surface size is the number of faces
00264             label size() const
00265             {
00266                 return ParentType::size();
00267             }
00268 
00269             //- Reset size of face and zone list
00270             void setSize(const label);
00271 
00272             //- Return const access to the zone ids
00273             const List<label>& zoneIds() const
00274             {
00275                 return zoneIds_;
00276             }
00277 
00278             //- Return const access to the zone table-of-contents
00279             const List<surfZoneIdentifier>& zoneToc() const
00280             {
00281                 return zoneToc_;
00282             }
00283 
00284             //- Sort faces according to zoneIds
00285             //  Returns a surfZoneList and sets faceMap to index within faces()
00286             surfZoneList sortedZones(labelList& faceMap) const;
00287 
00288             //- Set zones to 0 and set a single zone
00289             void setOneZone();
00290 
00291             //- Set zone ids and zones
00292             void setZones(const surfZoneList&);
00293 
00294             //- Set zone ids and zones
00295             void setZones(const UList<label>& sizes, const UList<word>& names);
00296 
00297             //- Set zone ids and zones with default names
00298             void setZones(const UList<label>& sizes);
00299 
00300 
00301         // Edit
00302 
00303             //- Clear all storage
00304             virtual void clear();
00305 
00306             //- Return new surface.
00307             //  Returns return pointMap, faceMap from subsetMeshMap
00308             UnsortedMeshedSurface subsetMesh
00309             (
00310                 const labelHashSet& include,
00311                 labelList& pointMap,
00312                 labelList& faceMap
00313             ) const;
00314 
00315             //- Return new surface.
00316             UnsortedMeshedSurface subsetMesh
00317             (
00318                 const labelHashSet& include
00319             ) const;
00320 
00321             //- Transfer components (points, faces, zone ids).
00322             virtual void reset
00323             (
00324                 const Xfer< pointField >&,
00325                 const Xfer< List<Face> >&,
00326                 const Xfer< List<label> >& zoneIds
00327             );
00328 
00329             //- Transfer components (points, faces, zone ids).
00330             virtual void reset
00331             (
00332                 const Xfer< List<point> >&,
00333                 const Xfer< List<Face> >&,
00334                 const Xfer< List<label> >& zoneIds
00335             );
00336 
00337             //- Transfer the contents of the argument and annull the argument
00338             void transfer(UnsortedMeshedSurface<Face>&);
00339 
00340             //- Transfer the contents of the argument and annull the argument
00341             void transfer(MeshedSurface<Face>&);
00342 
00343             //- Transfer contents to the Xfer container
00344             Xfer< UnsortedMeshedSurface<Face> > xfer();
00345 
00346 
00347         // Read
00348 
00349             //- Read from file. Chooses reader based on explicit extension
00350             bool read(const fileName&, const word& ext);
00351 
00352             //- Read from file. Chooses reader based on detected extension
00353             virtual bool read(const fileName&);
00354 
00355 
00356         // Write
00357 
00358             //- Generic write routine. Chooses writer based on extension.
00359             virtual void write(const fileName& name) const
00360             {
00361                 write(name, *this);
00362             }
00363 
00364             //- Write to database
00365             void write(const Time&, const word& surfName="") const;
00366 
00367 
00368         // Member operators
00369 
00370             void operator=(const UnsortedMeshedSurface<Face>&);
00371 
00372             //- Conversion operator to MeshedSurfaceProxy
00373             operator MeshedSurfaceProxy<Face>() const;
00374 };
00375 
00376 
00377 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00378 
00379 } // End namespace Foam
00380 
00381 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00382 
00383 #ifdef NoRepository
00384 #   include "UnsortedMeshedSurface.C"
00385 #endif
00386 
00387 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00388 
00389 #endif
00390 
00391 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd