All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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-2023 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<UList<face>, SubField<point>>
61 {
62  // Friendship
63 
64  template<class Face> friend class MeshedSurface;
65 
66  template<class Face> friend class UnsortedMeshedSurface;
67 
68 
69 public:
70 
71  // Public data types
72 
73  //- Enumeration defining the state of the mesh after a read update.
74  // Used for post-processing applications, where the mesh
75  // needs to update based on the files written in time directories.
76  enum readUpdateState
77  {
82  };
83 
84 
85 private:
86 
87  // Private Typedefs
88 
89  typedef MeshedSurfaceIOAllocator Allocator;
90 
91  typedef PrimitivePatch<UList<face>, SubField<point>> MeshReference;
92 
93 
94 protected:
95 
96  // Protected Member Functions
97 
98  //- Non-const access to global points
100  {
101  return Allocator::storedIOPoints();
102  }
103 
104  //- Non-const access to the faces
106  {
107  return Allocator::storedIOFaces();
108  }
109 
110  //- Non-const access to the zones
112  {
113  return Allocator::storedIOZones();
114  }
115 
116  //- Update references to storedFaces
117  virtual void updateFacesRef();
118 
119  //- Update references to storedPoints
120  virtual void updatePointsRef();
121 
122  //- Update references to storedPoints/storedFaces
123  virtual void updateRefs();
124 
125 
126 public:
127 
128  // Public Typedefs
129 
130  typedef surfMesh Mesh;
131 
132  //- Placeholder only, but do not remove - it is needed for GeoMesh
133  typedef bool BoundaryMesh;
134 
135 
136  // Public Static Data
137 
138  //- The mesh sub-directory name (normally "surfMesh")
139  static word meshSubDir;
140 
141 
142  //- Runtime type information
143  TypeName("surfMesh");
144 
145 
146  // Constructors
147 
148  //- Construct from IOobject, with alternative surface name
149  explicit surfMesh(const IOobject&, const word& surfName="");
150 
151  //- Construct by transferring components (points, faces) without zones.
152  // surfZones are added using addZones() member function
153  surfMesh
154  (
155  const IOobject&,
156  pointField&&,
157  faceList&&,
158  const word& surfName=""
159  );
160 
161  //- Construct copy/move from MeshedSurface
162  surfMesh
163  (
164  const IOobject&,
165  MeshedSurface<face>&& surf,
166  const word& surfName=""
167  );
168 
169  //- Disallow default bitwise copy construction
170  surfMesh(const surfMesh&) = delete;
171 
172 
173  //- Destructor
174  virtual ~surfMesh();
175 
176 
177  // Member Functions
178 
179  // Database
180 
181  //- Return the local mesh directory (dbDir()/meshSubDir)
182  fileName meshDir() const;
183 
184  //- Return the current instance directory for points
185  // Used in the construction of geometric mesh data dependent
186  // on points
187  const fileName& pointsInstance() const;
188 
189  //- Return the current instance directory for faces
190  const fileName& facesInstance() const;
191 
192  //- Set the instance for mesh files
193  void setInstance(const fileName&);
194 
195 
196  // Access
197 
198  //- Return the number of raw points
199  virtual label nPoints() const;
200 
201  //- Return the number of raw faces
202  virtual label nFaces() const;
203 
204  //- Return number of faces
205  virtual label size() const
206  {
207  return nFaces();
208  }
209 
210  //- Return points
211  virtual const pointField& points() const;
212 
213  //- Return faces
214  virtual const faceList& faces() const;
215 
216  //- Return surface zones
217  virtual const surfZoneList& surfZones() const
218  {
219  return Allocator::storedIOZones();
220  }
221 
222  //- Check the surface zone definitions
223  void checkZones();
224 
225  //- Add surface zones
226  void addZones
227  (
228  const List<surfZone>&,
229  const bool validate = true
230  );
231 
232  //- Update the mesh based on the mesh files saved in
233  // time directories
234  virtual readUpdateState readUpdate();
235 
236  //- Update the mesh corresponding to given map
237 
238  //- Remove surface zones
239  void removeZones();
240 
241  //- Reset mesh primitive data.
242  void resetPrimitives
243  (
244  pointField&& points,
245  faceList&& faces,
246  surfZoneList&& zones,
247  const bool validate = true
248  );
249 
250 
251  //- Transfer the contents of the argument and annul the argument
253 
254 
255  //- Avoid masking the normal objectRegistry write
257 
258  //- Write to file
259  static void write(const fileName&, const surfMesh&);
260 
261  //- Write to file
262  void write(const fileName&);
263 
264 
265  // Storage management
266 
267  //- Clear geometry
268  void clearGeom();
269 
270  //- Clear addressing
271  void clearAddressing();
272 
273  //- Clear all geometry and addressing unnecessary for CFD
274  void clearOut();
275 
276  //- Clear primitive data (points, faces and cells)
277  void clearPrimitives();
278 
279  //- Remove all files from mesh instance
280  void removeFiles(const fileName& instanceDir) const;
281 
282  //- Remove all files from mesh instance()
283  void removeFiles() const;
284 
285 
286  // Member Operators
287 
288  //- Disallow default bitwise assignment
289  void operator=(const surfMesh&) = delete;
290 };
291 
292 
293 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
294 
295 } // End namespace Foam
296 
297 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
298 
299 #endif
300 
301 // ************************************************************************* //
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
A helper class for storing points, faces and zones with IO capabilities.
pointIOField & storedIOPoints()
Non-const access to the points.
faceCompactIOList & storedIOFaces()
Non-const access to the faces.
surfZoneIOList & storedIOZones()
Non-const access to the zones.
A surface geometry mesh with zone information, not to be confused with the similarly named surfaceMes...
Definition: MeshedSurface.H:85
A list of faces which address into the list of points.
Pre-declare related SubField type.
Definition: SubField.H:63
A surface geometry mesh, in which the surface zone information is conveyed by the 'zoneId' associated...
A class for handling file names.
Definition: fileName.H:82
virtual bool write(const bool write=true) const
Write using setting from DB.
A surface mesh consisting of general polygon faces.
Definition: surfMesh.H:60
virtual label size() const
Return number of faces.
Definition: surfMesh.H:204
virtual void updatePointsRef()
Update references to storedPoints.
Definition: surfMesh.C:74
void addZones(const List< surfZone > &, const bool validate=true)
Add surface zones.
Definition: surfMesh.C:375
const fileName & facesInstance() const
Return the current instance directory for faces.
Definition: surfMesh.C:305
void transfer(MeshedSurface< face > &)
Transfer the contents of the argument and annul the argument.
Definition: surfMesh.C:278
static void write(const fileName &, const surfMesh &)
Write to file.
Definition: surfMesh.C:410
fileName meshDir() const
Return the local mesh directory (dbDir()/meshSubDir)
Definition: surfMesh.C:293
surfMesh Mesh
Definition: surfMesh.H:129
pointField & storedPoints()
Non-const access to global points.
Definition: surfMesh.H:98
virtual const faceList & faces() const
Return faces.
Definition: surfMesh.C:329
void clearGeom()
Clear geometry.
Definition: surfMeshClear.C:48
readUpdateState
Enumeration defining the state of the mesh after a read update.
Definition: surfMesh.H:76
@ TOPO_PATCH_CHANGE
Definition: surfMesh.H:80
surfMesh(const IOobject &, const word &surfName="")
Construct from IOobject, with alternative surface name.
Definition: surfMesh.C:100
void clearPrimitives()
Clear primitive data (points, faces and cells)
virtual ~surfMesh()
Destructor.
Definition: surfMesh.C:247
virtual readUpdateState readUpdate()
Update the mesh based on the mesh files saved in.
Definition: surfMeshIO.C:51
void operator=(const surfMesh &)=delete
Disallow default bitwise assignment.
virtual void updateRefs()
Update references to storedPoints/storedFaces.
Definition: surfMesh.C:91
const fileName & pointsInstance() const
Return the current instance directory for points.
Definition: surfMesh.C:299
TypeName("surfMesh")
Runtime type information.
surfZoneList & storedZones()
Non-const access to the zones.
Definition: surfMesh.H:110
void clearAddressing()
Clear addressing.
Definition: surfMeshClear.C:59
void resetPrimitives(pointField &&points, faceList &&faces, surfZoneList &&zones, const bool validate=true)
Reset mesh primitive data.
Definition: surfMesh.C:257
virtual const pointField & points() const
Return points.
Definition: surfMesh.C:323
void removeFiles() const
Remove all files from mesh instance()
Definition: surfMesh.C:404
virtual const surfZoneList & surfZones() const
Return surface zones.
Definition: surfMesh.H:216
faceList & storedFaces()
Non-const access to the faces.
Definition: surfMesh.H:104
virtual label nPoints() const
Return the number of raw points.
Definition: surfMesh.C:311
static word meshSubDir
The mesh sub-directory name (normally "surfMesh")
Definition: surfMesh.H:138
void setInstance(const fileName &)
Set the instance for mesh files.
Definition: surfMeshIO.C:31
bool BoundaryMesh
Placeholder only, but do not remove - it is needed for GeoMesh.
Definition: surfMesh.H:132
void removeZones()
Update the mesh corresponding to given map.
Definition: surfMeshClear.C:32
void clearOut()
Clear all geometry and addressing unnecessary for CFD.
Definition: surfMeshClear.C:70
virtual void updateFacesRef()
Update references to storedFaces.
Definition: surfMesh.C:84
void checkZones()
Check the surface zone definitions.
Definition: surfMesh.C:335
virtual label nFaces() const
Return the number of raw faces.
Definition: surfMesh.C:317
Wraps the normal objectRegistry with a local instance for surfaces.
A class for handling words, derived from string.
Definition: word.H:62
Namespace for OpenFOAM.
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
thermo validate(args.executable(), "h")