1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2008-2010 OpenCFD Ltd.
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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
25 Foam::UnsortedMeshedSurface
28 A surface geometry mesh, in which the surface zone information is
29 conveyed by the 'zoneId' associated with each face.
31 This form of surface description is particularly useful for reading in
32 surface meshes from third-party formats (eg, obj, stl, gts, etc.). It
33 can also be particularly useful for situations in which the surface
34 many be adjusted in an arbitrary manner without worrying about needed
35 to adjust the zone information (eg, surface refinement).
38 The Foam::MeshedSurface - which is organized as a surface mesh, but
39 with independent zone information.
42 UnsortedMeshedSurface.C
44 \*---------------------------------------------------------------------------*/
46 #ifndef UnsortedMeshedSurface_H
47 #define UnsortedMeshedSurface_H
49 #include "MeshedSurface.H"
50 #include "surfZoneIdentifierList.H"
51 #include "surfZoneList.H"
52 #include "surfaceFormatsCore.H"
53 #include "runTimeSelectionTables.H"
54 #include "memberFunctionSelectionTables.H"
57 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
62 // Forward declaration of friend functions and operators
67 template<class Face> class MeshedSurface;
68 template<class Face> class MeshedSurfaceProxy;
69 template<class Face> class UnsortedMeshedSurface;
71 /*---------------------------------------------------------------------------*\
72 Class UnsortedMeshedSurface Declaration
73 \*---------------------------------------------------------------------------*/
76 class UnsortedMeshedSurface
78 public MeshedSurface<Face>
80 // friends - despite different face representationsx
81 template<class Face2> friend class MeshedSurface;
82 template<class Face2> friend class UnsortedMeshedSurface;
83 friend class surfMesh;
87 // Private typedefs for convenience
89 typedef MeshedSurface<Face> ParentType;
90 typedef MeshedSurface<Face> FriendType;
91 typedef MeshedSurfaceProxy<Face> ProxyType;
94 // Private Member Data
96 //- The zone Id associated with each face
99 //- Zone information (face ordering nFaces/startFace only used
100 // during reading and writing)
101 List<surfZoneIdentifier> zoneToc_;
104 // Private Member Functions
106 //- Disable resize with value
107 void resize(const label, const Face&);
109 //- Disable setSize with value
110 void setSize(const label, const Face&);
115 // Protected Member functions
117 //- Return non-const access to the zone Ids
118 List<label>& storedZoneIds()
123 //- Return non-const access to the zone table-of-contents
124 List<surfZoneIdentifier>& storedZoneToc()
129 //- Set new zones from faceMap
130 virtual void remapFaces(const labelUList& faceMap);
138 typedef Face FaceType;
140 //- Runtime type information
141 TypeName("UnsortedMeshedSurface");
146 //- Can we read this file format?
147 static bool canReadType(const word& ext, const bool verbose=false);
149 //- Can we read this file format?
150 static bool canRead(const fileName&, const bool verbose=false);
152 //- Can we write this file format?
153 static bool canWriteType(const word& ext, const bool verbose=false);
155 static wordHashSet readTypes();
156 static wordHashSet writeTypes();
162 UnsortedMeshedSurface();
164 //- Construct by transferring components
165 // (points, faces, zone ids, zone info).
166 UnsortedMeshedSurface
168 const Xfer<pointField>&,
169 const Xfer<List<Face> >&,
170 const Xfer<List<label> >& zoneIds,
171 const Xfer<surfZoneIdentifierList>&
174 //- Construct by transferring points, faces.
175 // Use zone information, or set single default zone
176 UnsortedMeshedSurface
178 const Xfer<pointField>&,
179 const Xfer<List<Face> >&,
180 const labelUList& zoneSizes = labelUList(),
181 const UList<word>& zoneNames = UList<word>()
184 //- Construct as copy
185 UnsortedMeshedSurface(const UnsortedMeshedSurface<Face>&);
187 //- Construct from a meshedSurface
188 UnsortedMeshedSurface(const MeshedSurface<Face>&);
190 //- Construct by transferring the contents from a UnsortedMeshedSurface
191 UnsortedMeshedSurface(const Xfer<UnsortedMeshedSurface<Face> >&);
193 //- Construct by transferring the contents from a meshedSurface
194 UnsortedMeshedSurface(const Xfer<MeshedSurface<Face> >&);
196 //- Construct from file name (uses extension to determine type)
197 UnsortedMeshedSurface(const fileName&);
199 //- Construct from file name (uses extension to determine type)
200 UnsortedMeshedSurface(const fileName&, const word&);
202 //- Construct from objectRegistry and a named surface
203 UnsortedMeshedSurface(const Time&, const word& surfName="");
206 // Declare run-time constructor selection table
208 declareRunTimeSelectionTable
211 UnsortedMeshedSurface,
222 //- Select constructed from filename (explicit extension)
223 static autoPtr<UnsortedMeshedSurface> New
229 //- Select constructed from filename (implicit extension)
230 static autoPtr<UnsortedMeshedSurface> New(const fileName&);
234 virtual ~UnsortedMeshedSurface();
237 // Member Function Selectors
239 declareMemberFunctionSelectionTable
242 UnsortedMeshedSurface,
246 const fileName& name,
247 const UnsortedMeshedSurface<Face>& surf
253 static void write(const fileName&, const UnsortedMeshedSurface<Face>&);
260 //- The surface size is the number of faces
263 return ParentType::size();
266 //- Reset size of face and zone list
267 void setSize(const label);
269 //- Return const access to the zone ids
270 const List<label>& zoneIds() const
275 //- Return const access to the zone table-of-contents
276 const List<surfZoneIdentifier>& zoneToc() const
281 //- Sort faces according to zoneIds
282 // Returns a surfZoneList and sets faceMap to index within faces()
283 surfZoneList sortedZones(labelList& faceMap) const;
285 //- Set zones to 0 and set a single zone
288 //- Set zone ids and zones
289 void setZones(const surfZoneList&);
291 //- Set zone ids and zones
292 void setZones(const labelUList& sizes, const UList<word>& names);
294 //- Set zone ids and zones with default names
295 void setZones(const labelUList& sizes);
300 //- Clear all storage
301 virtual void clear();
303 //- Return new surface.
304 // Returns return pointMap, faceMap from subsetMeshMap
305 UnsortedMeshedSurface subsetMesh
307 const labelHashSet& include,
312 //- Return new surface.
313 UnsortedMeshedSurface subsetMesh
315 const labelHashSet& include
318 //- Transfer components (points, faces, zone ids).
321 const Xfer<pointField>&,
322 const Xfer<List<Face> >&,
323 const Xfer<List<label> >& zoneIds
326 //- Transfer components (points, faces, zone ids).
329 const Xfer<List<point> >&,
330 const Xfer<List<Face> >&,
331 const Xfer<List<label> >& zoneIds
334 //- Transfer the contents of the argument and annul the argument
335 void transfer(UnsortedMeshedSurface<Face>&);
337 //- Transfer the contents of the argument and annul the argument
338 void transfer(MeshedSurface<Face>&);
340 //- Transfer contents to the Xfer container
341 Xfer<UnsortedMeshedSurface<Face> > xfer();
346 //- Read from file. Chooses reader based on explicit extension
347 bool read(const fileName&, const word& ext);
349 //- Read from file. Chooses reader based on detected extension
350 virtual bool read(const fileName&);
355 //- Generic write routine. Chooses writer based on extension.
356 virtual void write(const fileName& name) const
361 //- Write to database
362 void write(const Time&, const word& surfName="") const;
367 void operator=(const UnsortedMeshedSurface<Face>&);
369 //- Conversion operator to MeshedSurfaceProxy
370 operator MeshedSurfaceProxy<Face>() const;
374 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
376 } // End namespace Foam
378 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
381 # include "UnsortedMeshedSurface.C"
384 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
388 // ************************************************************************* //