1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 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, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 Foam::UnsortedMeshedSurface
29 A surface geometry mesh, in which the surface zone information is
30 conveyed by the 'zoneId' associated with each face.
32 This form of surface description is particularly useful for reading in
33 surface meshes from third-party formats (eg, obj, stl, gts, etc.). It
34 can also be particularly useful for situations in which the surface
35 many be adjusted in an arbitrary manner without worrying about needed
36 to adjust the zone information (eg, surface refinement).
39 The Foam::MeshedSurface - which is organized as a surface mesh, but
40 with independent zone information.
43 UnsortedMeshedSurface.C
45 \*---------------------------------------------------------------------------*/
47 #ifndef UnsortedMeshedSurface_H
48 #define UnsortedMeshedSurface_H
50 #include "MeshedSurface.H"
51 #include "surfZoneIdentifierList.H"
52 #include "surfZoneList.H"
53 #include "surfaceFormatsCore.H"
54 #include "runTimeSelectionTables.H"
55 #include "memberFunctionSelectionTables.H"
58 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
63 // Forward declaration of friend functions and operators
68 template<class Face> class MeshedSurface;
69 template<class Face> class MeshedSurfaceProxy;
70 template<class Face> class UnsortedMeshedSurface;
72 /*---------------------------------------------------------------------------*\
73 Class UnsortedMeshedSurface Declaration
74 \*---------------------------------------------------------------------------*/
77 class UnsortedMeshedSurface
79 public MeshedSurface<Face>
81 // friends - despite different face representationsx
82 template<class Face2> friend class MeshedSurface;
83 template<class Face2> friend class UnsortedMeshedSurface;
84 friend class surfMesh;
88 //- Private typedefs for convenience
90 typedef MeshedSurface<Face> ParentType;
91 typedef MeshedSurface<Face> FriendType;
92 typedef MeshedSurfaceProxy<Face> ProxyType;
95 // Private Member Data
97 //- The zone Id associated with each face
100 //- Zone information (face ordering nFaces/startFace only used
101 // during reading and writing)
102 List<surfZoneIdentifier> zoneToc_;
105 // Private member functions
107 //- Disable resize with value
108 void resize(const label, const Face&);
110 //- Disable setSize with value
111 void setSize(const label, const Face&);
113 //- Read OpenFOAM Surface format
119 // Protected Member functions
121 //- Return non-const access to the zone Ids
122 List<label>& storedZoneIds()
127 //- Return non-const access to the zone table-of-contents
128 List<surfZoneIdentifier>& storedZoneToc()
133 //- Set new zones from faceMap
134 virtual void remapFaces(const UList<label>& faceMap);
139 //- Runtime type information
140 TypeName("UnsortedMeshedSurface");
145 //- Can we read this file format?
146 static bool canReadType(const word& ext, const bool verbose=false);
148 //- Can we read this file format?
149 static bool canRead(const fileName&, const bool verbose=false);
151 //- Can we write this file format?
152 static bool canWriteType(const word& ext, const bool verbose=false);
154 static wordHashSet readTypes();
155 static wordHashSet writeTypes();
161 UnsortedMeshedSurface();
163 //- Construct by transferring components
164 // (points, faces, zone ids, zone info).
165 UnsortedMeshedSurface
167 const Xfer< pointField >&,
168 const Xfer< List<Face> >&,
169 const Xfer< List<label> >& zoneIds,
170 const Xfer< surfZoneIdentifierList >&
173 //- Construct by transferring points, faces.
174 // Use zone information, or set single default zone
175 UnsortedMeshedSurface
177 const Xfer<pointField>&,
178 const Xfer<List<Face> >&,
179 const UList<label>& zoneSizes = UList<label>(),
180 const UList<word>& zoneNames = UList<word>()
183 //- Construct as copy
184 UnsortedMeshedSurface(const UnsortedMeshedSurface<Face>&);
186 //- Construct from a meshedSurface
187 UnsortedMeshedSurface(const MeshedSurface<Face>&);
189 //- Construct by transferring the contents from a UnsortedMeshedSurface
190 UnsortedMeshedSurface(const Xfer<UnsortedMeshedSurface<Face> >&);
192 //- Construct by transferring the contents from a meshedSurface
193 UnsortedMeshedSurface(const Xfer<MeshedSurface<Face> >&);
195 //- Construct from file name (uses extension to determine type)
196 UnsortedMeshedSurface(const fileName&);
198 //- Construct from file name (uses extension to determine type)
199 UnsortedMeshedSurface(const fileName&, const word&);
201 //- Construct from Istream
202 UnsortedMeshedSurface(Istream&);
204 //- Construct from objectRegistry and a named surface
205 UnsortedMeshedSurface(const Time&, const word& surfName="");
208 // Declare run-time constructor selection table
210 declareRunTimeSelectionTable
213 UnsortedMeshedSurface,
224 //- Select constructed from filename (explicit extension)
225 static autoPtr<UnsortedMeshedSurface> New
231 //- Select constructed from filename (implicit extension)
232 static autoPtr<UnsortedMeshedSurface> New(const fileName&);
237 virtual ~UnsortedMeshedSurface();
240 // Member Function Selectors
242 declareMemberFunctionSelectionTable
245 UnsortedMeshedSurface,
249 const fileName& name,
250 const UnsortedMeshedSurface<Face>& surf
256 static void write(const fileName&, const UnsortedMeshedSurface<Face>&);
263 //- The surface size is the number of faces
266 return ParentType::size();
269 //- Reset size of face and zone list
270 void setSize(const label);
272 //- Return const access to the zone ids
273 const List<label>& zoneIds() const
278 //- Return const access to the zone table-of-contents
279 const List<surfZoneIdentifier>& zoneToc() const
284 //- Sort faces according to zoneIds
285 // Returns a surfZoneList and sets faceMap to index within faces()
286 surfZoneList sortedZones(labelList& faceMap) const;
288 //- Set zones to 0 and set a single zone
291 //- Set zone ids and zones
292 void setZones(const surfZoneList&);
294 //- Set zone ids and zones
295 void setZones(const UList<label>& sizes, const UList<word>& names);
297 //- Set zone ids and zones with default names
298 void setZones(const UList<label>& sizes);
303 //- Clear all storage
304 virtual void clear();
306 //- Return new surface.
307 // Returns return pointMap, faceMap from subsetMeshMap
308 UnsortedMeshedSurface subsetMesh
310 const labelHashSet& include,
315 //- Return new surface.
316 UnsortedMeshedSurface subsetMesh
318 const labelHashSet& include
321 //- Transfer components (points, faces, zone ids).
324 const Xfer< pointField >&,
325 const Xfer< List<Face> >&,
326 const Xfer< List<label> >& zoneIds
329 //- Transfer components (points, faces, zone ids).
332 const Xfer< List<point> >&,
333 const Xfer< List<Face> >&,
334 const Xfer< List<label> >& zoneIds
337 //- Transfer the contents of the argument and annull the argument
338 void transfer(UnsortedMeshedSurface<Face>&);
340 //- Transfer the contents of the argument and annull the argument
341 void transfer(MeshedSurface<Face>&);
343 //- Transfer contents to the Xfer container
344 Xfer< UnsortedMeshedSurface<Face> > xfer();
349 //- Read from file. Chooses reader based on explicit extension
350 bool read(const fileName&, const word& ext);
352 //- Read from file. Chooses reader based on detected extension
353 virtual bool read(const fileName&);
358 //- Generic write routine. Chooses writer based on extension.
359 virtual void write(const fileName& name) const
364 //- Write to database
365 void write(const Time&, const word& surfName="") const;
370 void operator=(const UnsortedMeshedSurface<Face>&);
372 //- Conversion operator to MeshedSurfaceProxy
373 operator MeshedSurfaceProxy<Face>() const;
377 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
379 } // End namespace Foam
381 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
384 # include "UnsortedMeshedSurface.C"
387 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
391 // ************************************************************************* //