surfMesh.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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
19  for more details.
20 
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/>.
23 
24 Class
25  Foam::surfMesh
26 
27 Description
28  A surface mesh consisting of general polygon faces.
29 
30 SourceFiles
31  surfMesh.C
32  surfMeshClear.C
33  surfMeshIO.C
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef surfMesh_H
38 #define surfMesh_H
39 
40 #include "surfaceRegistry.H"
42 #include "PrimitivePatch.H"
43 #include "SubField.H"
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 
50 template<class Face> class MeshedSurface;
51 
52 /*---------------------------------------------------------------------------*\
53  Class surfMesh Declaration
54 \*---------------------------------------------------------------------------*/
55 
56 class surfMesh
57 :
58  public surfaceRegistry,
60  public PrimitivePatch<face, ::Foam::UList, ::Foam::SubField<point>, point>
61 {
62  // friends
63  template<class Face> friend class MeshedSurface;
64  template<class Face> friend class UnsortedMeshedSurface;
65 
66 public:
67 
68  // Public data types
69 
70  //- Enumeration defining the state of the mesh after a read update.
71  // Used for post-processing applications, where the mesh
72  // needs to update based on the files written in time directories
73  enum readUpdateState
74  {
79  };
80 
81 
82 private:
83 
84  // Private typedefs
85 
87 
88  typedef PrimitivePatch
89  <
90  face,
93  point
94  >
96 
97 
98  // Private Member Functions
99 
100  //- Disallow construct as copy
101  surfMesh(const surfMesh&);
102 
103  //- Disallow default bitwise assignment
104  void operator=(const surfMesh&);
105 
106 
107 protected:
108 
109  // Protected Member Functions
110 
111  //- Non-const access to global points
113  {
114  return Allocator::storedIOPoints();
115  }
116 
117  //- Non-const access to the faces
119  {
120  return Allocator::storedIOFaces();
121  }
122 
123  //- Non-const access to the zones
125  {
126  return Allocator::storedIOZones();
127  }
128 
129  //- Update references to storedFaces
130  virtual void updateFacesRef();
131 
132  //- Update references to storedPoints
133  virtual void updatePointsRef();
134 
135  //- Update references to storedPoints/storedFaces
136  virtual void updateRefs();
137 
138 
139 public:
140 
141  // Public typedefs
143  typedef surfMesh Mesh;
144 
145  //- Placeholder only, but do not remove - it is needed for GeoMesh
146  typedef bool BoundaryMesh;
147 
148 
149  //- Runtime type information
150  TypeName("surfMesh");
151 
152  //- Return the mesh sub-directory name (normally "surfMesh")
153  static word meshSubDir;
154 
155  // Constructors
156 
157  //- Construct from IOobject, with alternative surface name
158  explicit surfMesh(const IOobject&, const word& surfName="");
159 
160  //- Construct by transferring components (points, faces) without zones.
161  // surfZones are added using addZones() member function
162  surfMesh
163  (
164  const IOobject&,
165  const Xfer<pointField>&,
166  const Xfer<faceList>&,
167  const word& surfName=""
168  );
169 
170  //- Construct copy/move from MeshedSurface
171  surfMesh
172  (
173  const IOobject&,
174  const Xfer<MeshedSurface<face>>& surf,
175  const word& surfName=""
176  );
177 
178 
179  //- Destructor
180  virtual ~surfMesh();
181 
182 
183  // Member Functions
184 
185  // Database
186 
187  //- Return the local mesh directory (dbDir()/meshSubDir)
188  fileName meshDir() const;
189 
190  //- Return the current instance directory for points
191  // Used in the consruction of geometric mesh data dependent
192  // on points
193  const fileName& pointsInstance() const;
194 
195  //- Return the current instance directory for faces
196  const fileName& facesInstance() const;
197 
198  //- Set the instance for mesh files
199  void setInstance(const fileName&);
200 
201 
202  // Access
203 
204  //- Return the number of raw points
205  virtual label nPoints() const;
206 
207  //- Return the number of raw faces
208  virtual label nFaces() const;
209 
210  //- Return number of faces
211  virtual label size() const
212  {
213  return nFaces();
214  }
215 
216 
217  //- Return points
218  virtual const pointField& points() const;
219 
220  //- Return faces
221  virtual const faceList& faces() const;
222 
223  //- Return surface zones
224  virtual const surfZoneList& surfZones() const
225  {
226  return Allocator::storedIOZones();
227  }
228 
229  //- Check the surface zone definitions
230  void checkZones();
231 
232  //- Add surface zones
233  void addZones
234  (
235  const List<surfZone>&,
236  const bool validate = true
237  );
238 
239  //- Update the mesh based on the mesh files saved in
240  // time directories
241  virtual readUpdateState readUpdate();
242 
243  //- Update the mesh corresponding to given map
244 
245  //- Remove surface zones
246  void removeZones();
247 
248  //- Reset mesh primitive data.
249  void resetPrimitives
250  (
251  const Xfer<pointField>& points,
252  const Xfer<faceList>& faces,
253  const Xfer<surfZoneList>& zones,
254  const bool validate = true
255  );
256 
257 
258  //- Transfer the contents of the argument and annul the argument
260 
261 
262  //- Avoid masking the normal objectRegistry write
264 
265  //- Write to file
266  static void write(const fileName&, const surfMesh&);
267 
268  //- Write to file
269  void write(const fileName&);
270 
271  // Storage management
272 
273  //- Transfer contents to the Xfer container as a MeshedSurface
275 
276  //- Clear geometry
277  void clearGeom();
278 
279  //- Clear addressing
280  void clearAddressing();
281 
282  //- Clear all geometry and addressing unnecessary for CFD
283  void clearOut();
284 
285  //- Clear primitive data (points, faces and cells)
286  void clearPrimitives();
287 
288  //- Remove all files from mesh instance
289  void removeFiles(const fileName& instanceDir) const;
290 
291  //- Remove all files from mesh instance()
292  void removeFiles() const;
293 };
294 
295 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
296 
297 } // End namespace Foam
298 
299 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
300 
301 #endif
302 
303 // ************************************************************************* //
A surface geometry mesh, in which the surface zone information is conveyed by the &#39;zoneId&#39; associated...
Definition: MeshedSurface.H:74
bool BoundaryMesh
Placeholder only, but do not remove - it is needed for GeoMesh.
Definition: surfMesh.H:145
virtual void updateRefs()
Update references to storedPoints/storedFaces.
Definition: surfMesh.C:91
A simple container for copying or transferring objects of type <T>.
Definition: Xfer.H:85
const fileName & facesInstance() const
Return the current instance directory for faces.
Definition: surfMesh.C:323
virtual label size() const
Return number of faces.
Definition: surfMesh.H:210
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
faceCompactIOList & storedIOFaces()
Non-const access to the faces.
A class for handling file names.
Definition: fileName.H:69
readUpdateState
Enumeration defining the state of the mesh after a read update.
Definition: surfMesh.H:72
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:75
virtual void updatePointsRef()
Update references to storedPoints.
Definition: surfMesh.C:74
surfZoneList & storedZones()
Non-const access to the zones.
Definition: surfMesh.H:123
A surface geometry mesh with zone information, not to be confused with the similarly named surfaceMes...
Definition: MeshedSurface.H:72
const fileName & pointsInstance() const
Return the current instance directory for points.
Definition: surfMesh.C:317
faceList & storedFaces()
Non-const access to the faces.
Definition: surfMesh.H:117
void clearGeom()
Clear geometry.
Definition: surfMeshClear.C:48
void addZones(const List< surfZone > &, const bool validate=true)
Add surface zones.
Definition: surfMesh.C:393
pointIOField & storedIOPoints()
Non-const access to the points.
static void write(const fileName &, const surfMesh &)
Write to file.
Definition: surfMesh.C:428
void setInstance(const fileName &)
Set the instance for mesh files.
Definition: surfMeshIO.C:31
virtual readUpdateState readUpdate()
Update the mesh based on the mesh files saved in.
Definition: surfMeshIO.C:51
Wraps the normal objectRegistry with a local instance for surfaces.
void clearPrimitives()
Clear primitive data (points, faces and cells)
A list of faces which address into the list of points.
Xfer< MeshedSurface< face > > xfer()
Transfer contents to the Xfer container as a MeshedSurface.
Definition: surfMesh.C:293
static word meshSubDir
Return the mesh sub-directory name (normally "surfMesh")
Definition: surfMesh.H:152
A class for handling words, derived from string.
Definition: word.H:59
virtual const faceList & faces() const
Return faces.
Definition: surfMesh.C:347
virtual void updateFacesRef()
Update references to storedFaces.
Definition: surfMesh.C:84
surfZoneIOList & storedIOZones()
Non-const access to the zones.
void removeZones()
Update the mesh corresponding to given map.
Definition: surfMeshClear.C:32
virtual label nPoints() const
Return the number of raw points.
Definition: surfMesh.C:329
void clearOut()
Clear all geometry and addressing unnecessary for CFD.
Definition: surfMeshClear.C:70
A helper class for storing points, faces and zones with IO capabilities.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:61
A surface mesh consisting of general polygon faces.
Definition: surfMesh.H:55
void removeFiles() const
Remove all files from mesh instance()
Definition: surfMesh.C:422
thermo validate(args.executable(), "h")
surfMesh Mesh
Definition: surfMesh.H:142
void transfer(MeshedSurface< face > &)
Transfer the contents of the argument and annul the argument.
Definition: surfMesh.C:278
virtual const surfZoneList & surfZones() const
Return surface zones.
Definition: surfMesh.H:223
pointField & storedPoints()
Non-const access to global points.
Definition: surfMesh.H:111
virtual label nFaces() const
Return the number of raw faces.
Definition: surfMesh.C:335
void checkZones()
Check the surface zone definitions.
Definition: surfMesh.C:353
virtual const pointField & points() const
Return points.
Definition: surfMesh.C:341
void resetPrimitives(const Xfer< pointField > &points, const Xfer< faceList > &faces, const Xfer< surfZoneList > &zones, const bool validate=true)
Reset mesh primitive data.
Definition: surfMesh.C:257
TypeName("surfMesh")
Runtime type information.
virtual ~surfMesh()
Destructor.
Definition: surfMesh.C:247
virtual bool write(const bool valid=true) const
Write using setting from DB.
fileName meshDir() const
Return the local mesh directory (dbDir()/meshSubDir)
Definition: surfMesh.C:311
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:92
void clearAddressing()
Clear addressing.
Definition: surfMeshClear.C:59
Namespace for OpenFOAM.