pointMesh.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2013 OpenFOAM Foundation
9  Copyright (C) 2021-2024 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::pointMesh
29 
30 Description
31  Mesh representing a set of points created from polyMesh.
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef Foam_pointMesh_H
36 #define Foam_pointMesh_H
37 
38 #include "GeoMesh.H"
39 #include "MeshObject.H"
40 #include "polyMesh.H"
41 #include "pointBoundaryMesh.H"
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 namespace Foam
46 {
47 
48 /*---------------------------------------------------------------------------*\
49  Class pointMesh Declaration
50 \*---------------------------------------------------------------------------*/
51 
52 class pointMesh
53 :
54  public MeshObject<polyMesh, UpdateableMeshObject, pointMesh>,
55  public GeoMesh<polyMesh>
56 {
57  // Private Typedefs
58 
59  typedef MeshObject
60  <
61  polyMesh,
63  pointMesh
65 
66 
67  // Permanent Data
68 
69  //- Boundary mesh
70  pointBoundaryMesh boundary_;
71 
72 
73  // Private Member Functions
74 
75  //- Map all fields
76  void mapFields(const mapPolyMesh& mpm);
77 
78  //- No copy construct
79  pointMesh(const pointMesh&) = delete;
80 
81  //- No copy assignment
82  void operator=(const pointMesh&) = delete;
83 
84 
85 public:
86 
87  // Public Typedefs
88 
89  //- The mesh type
90  typedef pointMesh Mesh;
91 
92  //- The boundary type associated with the mesh
94 
95 
96  // Declare name of the class and its debug switch
97  ClassName("pointMesh");
98 
99  //- Return the mesh sub-directory name (usually "pointMesh")
100  static word meshSubDir;
101 
102 
103  // Constructors
104 
105  //- Construct from polyMesh
106  explicit pointMesh(const polyMesh& pMesh);
108  //- Construct from polyMesh and IOobject (used when reading boundary)
109  explicit pointMesh(const polyMesh& pMesh, const IOobject& io);
110 
111  //- Construct from polyMesh and readOpt. Takes instance, time etc
112  //- from polyMesh. Used when reading boundary.
113  explicit pointMesh
114  (
115  const polyMesh& pMesh,
116  const IOobjectOption::readOption rOpt
117  );
118 
119 
120  //- Destructor
121  ~pointMesh() = default;
122 
123 
124  // Member Functions
125 
126  //- Return size. Number of points
127  static label size(const Mesh& mesh)
128  {
129  return mesh.GeoMesh<polyMesh>::mesh_.nPoints();
130  }
131 
132  //- Return size. Number of points
133  label size() const
134  {
135  return size(*this);
136  }
137 
138  //- Return reference to boundary mesh
139  const pointBoundaryMesh& boundary() const noexcept
140  {
141  return boundary_;
142  }
143 
144  //- Is demand-driven parallel info available?
145  bool hasGlobalData() const noexcept
146  {
147  return GeoMesh<polyMesh>::mesh_.hasGlobalData();
148  }
149 
150  //- Return parallel info (demand-driven)
151  const globalMeshData& globalData() const
152  {
153  return GeoMesh<polyMesh>::mesh_.globalData();
154  }
155 
156  //- Return database. For now is its polyMesh.
157  const objectRegistry& thisDb() const
158  {
160  }
161 
162  //- Return Time from polyMesh.
163  const Time& time() const
164  {
165  return GeoMesh<polyMesh>::mesh_.time();
166  }
167 
168  //- Set the instance for mesh files
169  void setInstance
170  (
171  const fileName& instance,
173  );
174 
175 
176  // Volume Mesh
177 
178  //- Return boundary mesh for underlying volume mesh
179  const polyBoundaryMesh& boundaryMesh() const
180  {
181  return GeoMesh<polyMesh>::mesh_.boundaryMesh();
182  }
183 
185  // Mesh Motion
186 
187  //- Move points
188  bool movePoints();
189 
190  //- Update the mesh corresponding to given map
191  void updateMesh(const mapPolyMesh& mpm);
193 
194  // Member Operators
195 
196  bool operator!=(const pointMesh& pm) const
197  {
198  return &pm != this;
199  }
200 
201  bool operator==(const pointMesh& pm) const
202  {
203  return &pm == this;
204  }
205 
206 
207  // Write
208 
209  //- Write
210  virtual bool writeObject
211  (
212  IOstreamOption streamOpt,
213  const bool writeOnProc = true
214  ) const;
215 };
216 
217 
218 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
219 
220 } // End namespace Foam
221 
222 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
223 
224 #endif
225 
226 // ************************************************************************* //
bool movePoints()
Move points.
Definition: pointMesh.C:147
writeOption
Enumeration defining write preferences.
bool hasGlobalData() const noexcept
Is demand-driven parallel info available?
Definition: pointMesh.H:168
A class for handling file names.
Definition: fileName.H:72
Foam::pointBoundaryMesh.
label nPoints() const noexcept
Number of mesh points.
Various mesh related information for a parallel run. Upon construction, constructs all info using par...
bool operator==(const pointMesh &pm) const
Definition: pointMesh.H:238
ClassName("pointMesh")
void updateMesh(const mapPolyMesh &mpm)
Update the mesh corresponding to given map.
Definition: pointMesh.C:161
A simple container for options an IOstream can normally have.
pointMesh Mesh
The mesh type.
Definition: pointMesh.H:93
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:69
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
virtual bool writeObject(IOstreamOption streamOpt, const bool writeOnProc=true) const
Write.
Definition: pointMesh.C:176
Mesh representing a set of points created from polyMesh.
Definition: pointMesh.H:45
bool operator!=(const pointMesh &pm) const
Definition: pointMesh.H:233
Templated abstract base-class for optional mesh objects used to automate their allocation to the mesh...
Definition: MeshObject.H:152
const Time & time() const
Return Time from polyMesh.
Definition: pointMesh.H:192
const globalMeshData & globalData() const
Return parallel info (demand-driven)
Definition: pointMesh.H:176
const polyMesh & mesh() const noexcept
Reference to the mesh.
Definition: MeshObject.H:255
A class for handling words, derived from Foam::string.
Definition: word.H:63
~pointMesh()=default
Destructor.
const objectRegistry & thisDb() const
Return database. For now is its polyMesh.
Definition: pointMesh.H:184
label size() const
Return size. Number of points.
Definition: pointMesh.H:152
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO...
const direction noexcept
Definition: Scalar.H:258
const objectRegistry & thisDb() const
Return the object registry.
Definition: GeoMesh.H:86
const fileName & instance() const noexcept
Read access to instance path component.
Definition: IOobjectI.H:266
void setInstance(const fileName &instance, const IOobjectOption::writeOption wOpt=IOobject::AUTO_WRITE)
Set the instance for mesh files.
Definition: pointMesh.C:129
static word meshSubDir
Return the mesh sub-directory name (usually "pointMesh")
Definition: pointMesh.H:107
pointBoundaryMesh BoundaryMesh
The boundary type associated with the mesh.
Definition: pointMesh.H:98
Automatically write from objectRegistry::writeObject()
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh for underlying volume mesh.
Definition: pointMesh.H:212
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:75
Generic mesh wrapper used by volMesh, surfaceMesh, pointMesh etc.
Definition: GeoMesh.H:42
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
Registry of regIOobjects.
const pointBoundaryMesh & boundary() const noexcept
Return reference to boundary mesh.
Definition: pointMesh.H:160
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:180
const polyMesh & mesh_
Reference to Mesh.
Definition: GeoMesh.H:51
Namespace for OpenFOAM.
UpdateableMeshObject(const word &objName, const objectRegistry &obr)
Construct from name and instance on registry.
Definition: MeshObject.H:352
readOption
Enumeration defining read preferences.