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