pointMesh.C
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-2026 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 \*---------------------------------------------------------------------------*/
25 
26 #include "pointMesh.H"
27 #include "globalMeshData.H"
28 #include "pointFields.H"
29 #include "SubField.H"
30 #include "facePointPatch.H"
31 #include "MapGeometricFields.H"
32 
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
38 }
39 
41 
43 
44 
45 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
46 
48 :
50  mesh_(pMesh),
51  boundary_(*this, pMesh.boundary())
52 {
53  if (debug)
54  {
55  Pout<< "pointMesh::pointMesh(const polyMesh&): "
56  << "Constructing from polyMesh " << pMesh.name()
57  << endl;
58  }
59 
60  // Calculate the geometry for the patches (transformation tensors etc.)
61  boundary_.calcGeometry();
62 }
63 
64 
65 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
66 
68 {
69  if (debug)
70  {
71  Pout<< "~pointMesh::pointMesh()"
72  << endl;
74  }
75 }
76 
77 
78 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
79 
82 {
83  if (!pointsPtr_.valid())
84  {
86  (
87  IOobject
88  (
89  "points",
90  time().name(),
91  *this,
94  true
95  ),
96  *this,
97  dimLength,
98  mesh_.points()
99  );
100  }
101 
102  return *pointsPtr_;
103 }
104 
105 
107 {
108  if (debug)
109  {
110  Pout<< "pointMesh::movePoints(const pointField&): "
111  << "Moving points." << endl;
112  }
113 
114  boundary_.movePoints(mesh_.points());
115 
116  // Move the points of all pointMesh meshObjects
117  meshObjects::movePoints<pointMesh>(const_cast<polyMesh&>(mesh_));
118 
119  return true;
120 }
121 
122 
124 {
125  if (debug)
126  {
127  Pout<< "pointMesh::topoChange(const polyTopoChangeMap&): "
128  << "Topology change." << endl;
129  }
130 
131  pointsPtr_.clear();
132  boundary_.topoChange();
133 
134  meshObjects::topoChange<pointMesh>(const_cast<polyMesh&>(mesh_), map);
135 }
136 
137 
139 {
140  if (debug)
141  {
142  Pout<< "pointMesh::mapMesh(const polyMeshMap&): "
143  << "Mesh mapping." << endl;
144  }
145 
146  pointsPtr_.clear();
147  boundary_.topoChange();
148 
149  meshObjects::mapMesh<pointMesh>(const_cast<polyMesh&>(mesh_), map);
150 }
151 
152 
154 {
155  if (debug)
156  {
157  Pout<< "pointMesh::swap(const polyMesh&): "
158  << "Mesh swapping." << endl;
159  }
160 
161  boundary_.reset();
162 
164  <
165  pointMesh,
168  >
169  (
170  const_cast<polyMesh&>(mesh_)
171  );
172 
174  <
175  pointMesh,
178  >
179  (
180  otherMesh
181  );
182 }
183 
184 
186 {
187  if (debug)
188  {
189  Pout<< "pointMesh::distribute(const polyDistributionMap&): "
190  << "Distribute." << endl;
191  }
192 
193  pointsPtr_.clear();
194  boundary_.topoChange();
195 
196  meshObjects::distribute<pointMesh>(const_cast<polyMesh&>(mesh_), map);
197 }
198 
199 
201 (
202  const labelUList& newToOld,
203  const bool validBoundary
204 )
205 {
206  if (debug)
207  {
208  Pout<< "pointMesh::reorderPatches( const labelUList&, const bool): "
209  << "Updating for reordered patches." << endl;
210  }
211 
212  boundary_.shuffle(newToOld, validBoundary);
213  meshObjects::reorderPatches<pointMesh>
214  (
215  const_cast<polyMesh&>(mesh_),
216  newToOld,
217  validBoundary
218  );
219 
220  #define ReorderPatchFieldsType(Type, nullArg) \
221  ReorderPatchFields<PointField<Type>> \
222  ( \
223  const_cast<objectRegistry&>(db()), \
224  newToOld \
225  );
227  #undef ReorderPatchFieldsType
228 }
229 
230 
232 {
233  if (debug)
234  {
235  Pout<< "pointMesh::addPatch(const label): "
236  << "Adding patch at " << patchi << endl;
237  }
238 
239  const polyBoundaryMesh& pbm = poly().boundary();
240 
241  if (pbm.size() != boundary_.size())
242  {
243  FatalErrorInFunction << "Problem :"
244  << " pointBoundaryMesh size :" << boundary_.size()
245  << " polyBoundaryMesh size :" << pbm.size()
246  << exit(FatalError);
247  }
248 
249  boundary_.set(patchi, facePointPatch::New(pbm[patchi], boundary_).ptr());
250  meshObjects::addPatch<pointMesh>(const_cast<polyMesh&>(mesh_), patchi);
251 
252  #define AddPatchFieldsType(Type, nullArg) \
253  AddPatchFields<PointField<Type>> \
254  ( \
255  const_cast<objectRegistry&>(db()), \
256  patchi, \
257  calculatedPointPatchField<scalar>::typeName \
258  );
260  #undef ReorderPatchFieldsType
261 }
262 
263 
265 {
266  if (debug)
267  {
268  Pout<< "pointMesh::clear(): "
269  << "Clear all but permanent registered meshObjects" << endl;
270  }
271 
272  // Clear all but permanent registered meshObjects
273  meshObjects::clear<pointMesh, DeletableMeshObject>
274  (
275  const_cast<polyMesh&>(mesh_)
276  );
277 }
278 
279 
281 {
282  if (debug)
283  {
284  Pout<< "pointMesh::reset(): "
285  << "Mesh reset." << endl;
286  }
287 
288  boundary_.reset();
289  meshObjects::reset<pointMesh>(const_cast<polyMesh&>(mesh_));
290 }
291 
292 
293 // ************************************************************************* //
MeshObject types:
Definition: MeshObjects.H:70
Templated abstract base-class for demand-driven mesh objects used to automate their allocation to the...
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
const word & name() const
Return name.
Definition: IOobject.H:307
Specialisation of DimensionedField which holds a slice of a given complete field in such a form that ...
label size() const
Return the number of elements in the UPtrList.
Definition: UPtrListI.H:29
static void printStack(Ostream &)
Helper function to print a stack.
static autoPtr< facePointPatch > New(const polyPatch &, const pointBoundaryMesh &)
Return a pointer to a new patch created on freestore from polyPatch.
static void clearUpto(objectRegistry &)
Clear all meshObjects derived from FromType up to (but not including)
Mesh representing a set of points created from polyMesh.
Definition: pointMesh.H:52
virtual bool movePoints()
Move points.
Definition: pointMesh.C:106
static const HashSet< word > curGeometryFields
Set of names of registered current-time geometric fields.
Definition: pointMesh.H:115
pointMesh(const polyMesh &pMesh)
Construct from polyMesh.
Definition: pointMesh.C:47
virtual void topoChange(const polyTopoChangeMap &)
Update the mesh corresponding to given map.
Definition: pointMesh.C:123
virtual void distribute(const polyDistributionMap &)
Redistribute or update using the given distribution map.
Definition: pointMesh.C:185
static const HashSet< word > geometryFields
Set of names of registered geometric fields.
Definition: pointMesh.H:112
virtual void swap(polyMesh &)
Swap mesh.
Definition: pointMesh.C:153
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
Definition: pointMesh.C:138
const DimensionedField< vector, pointMesh > & C() const
Return point locations.
Definition: pointMesh.C:81
~pointMesh()
Destructor.
Definition: pointMesh.C:67
virtual void addPatch(const label patchi)
Inserted patch at patchi.
Definition: pointMesh.C:231
virtual void clear()
Clear all but permanent registered meshObjects.
Definition: pointMesh.C:264
void reset()
Reset pointMesh with respect to the updated polyMesh.
Definition: pointMesh.C:280
virtual void reorderPatches(const labelUList &newToOld, const bool validBoundary)
Reordered/removed trailing patches. If validBoundary call is.
Definition: pointMesh.C:201
Foam::polyBoundaryMesh.
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
Class containing mesh-to-mesh mapping information.
Definition: polyMeshMap.H:51
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:78
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
label patchi
const dimensionSet time
Namespace for OpenFOAM.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
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
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:288
const dimensionSet & dimLength
Definition: dimensions.C:141
FOR_ALL_FIELD_TYPES(makeDimensionedPointFieldFunctions)
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
prefixOSstream Pout(cout, "Pout")
Definition: IOstreams.H:53
error FatalError
defineTypeNameAndDebug(atmosphericBoundaryLayer, 0)
#define ReorderPatchFieldsType(Type, nullArg)
#define AddPatchFieldsType(Type, nullArg)
faceListList boundary(nPatches)