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-2025 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 "facePointPatch.H"
30 #include "MapGeometricFields.H"
31 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
37 }
38 
40 
42 
43 
44 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
45 
47 :
49  GeoMesh<polyMesh>(pMesh),
50  boundary_(*this, pMesh.boundaryMesh())
51 {
52  if (debug)
53  {
54  Pout<< "pointMesh::pointMesh(const polyMesh&): "
55  << "Constructing from polyMesh " << pMesh.name()
56  << endl;
57  }
58 
59  // Calculate the geometry for the patches (transformation tensors etc.)
60  boundary_.calcGeometry();
61 }
62 
63 
64 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
65 
67 {
68  if (debug)
69  {
70  Pout<< "~pointMesh::pointMesh()"
71  << endl;
73  }
74 }
75 
76 
77 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
78 
80 {
81  if (debug)
82  {
83  Pout<< "pointMesh::movePoints(const pointField&): "
84  << "Moving points." << endl;
85  }
86 
87  boundary_.movePoints(GeoMesh<polyMesh>::mesh_.points());
88 
89  return true;
90 }
91 
92 
94 {
95  if (debug)
96  {
97  Pout<< "pointMesh::topoChange(const polyTopoChangeMap&): "
98  << "Topology change." << endl;
99  }
100  boundary_.topoChange();
101 }
102 
103 
105 {
106  if (debug)
107  {
108  Pout<< "pointMesh::mapMesh(const polyMeshMap&): "
109  << "Mesh mapping." << endl;
110  }
111  boundary_.topoChange();
112 }
113 
114 
116 {
117  if (debug)
118  {
119  Pout<< "pointMesh::distribute(const polyDistributionMap&): "
120  << "Distribute." << endl;
121  }
122  boundary_.topoChange();
123 }
124 
125 
127 (
128  const labelUList& newToOld,
129  const bool validBoundary
130 )
131 {
132  if (debug)
133  {
134  Pout<< "pointMesh::reorderPatches( const labelUList&, const bool): "
135  << "Updating for reordered patches." << endl;
136  }
137 
138  boundary_.shuffle(newToOld, validBoundary);
139 
140  #define ReorderPatchFieldsType(Type, nullArg) \
141  ReorderPatchFields<PointField<Type>> \
142  ( \
143  const_cast<objectRegistry&>(thisDb()), \
144  newToOld \
145  );
147  #undef ReorderPatchFieldsType
148 }
149 
150 
152 {
153  if (debug)
154  {
155  Pout<< "pointMesh::addPatch(const label): "
156  << "Adding patch at " << patchi << endl;
157  }
158 
159  const polyBoundaryMesh& pbm = mesh().boundaryMesh();
160 
161  if (pbm.size() != boundary_.size())
162  {
163  FatalErrorInFunction << "Problem :"
164  << " pointBoundaryMesh size :" << boundary_.size()
165  << " polyBoundaryMesh size :" << pbm.size()
166  << exit(FatalError);
167  }
168 
169  boundary_.set(patchi, facePointPatch::New(pbm[patchi], boundary_).ptr());
170 
171  #define AddPatchFieldsType(Type, nullArg) \
172  AddPatchFields<PointField<Type>> \
173  ( \
174  const_cast<objectRegistry&>(thisDb()), \
175  patchi, \
176  calculatedPointPatchField<scalar>::typeName \
177  );
179  #undef ReorderPatchFieldsType
180 }
181 
182 
184 {
185  if (debug)
186  {
187  Pout<< "pointMesh::reset(): "
188  << "Mesh reset." << endl;
189  }
190  boundary_.reset();
191 }
192 
193 
194 // ************************************************************************* //
Templated abstract base-class for demand-driven mesh objects used to automate their allocation to the...
Generic mesh wrapper used by volMesh, surfaceMesh, pointMesh etc.
Definition: GeoMesh.H:47
const word & name() const
Return name.
Definition: IOobject.H:307
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.
Mesh representing a set of points created from polyMesh.
Definition: pointMesh.H:53
virtual bool movePoints()
Move points.
Definition: pointMesh.C:79
static const HashSet< word > curGeometryFields
Set of names of registered current-time geometric fields.
Definition: pointMesh.H:107
pointMesh(const polyMesh &pMesh)
Construct from polyMesh.
Definition: pointMesh.C:46
virtual void topoChange(const polyTopoChangeMap &)
Update the mesh corresponding to given map.
Definition: pointMesh.C:93
virtual void distribute(const polyDistributionMap &)
Redistribute or update using the given distribution map.
Definition: pointMesh.C:115
static const HashSet< word > geometryFields
Set of names of registered geometric fields.
Definition: pointMesh.H:104
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
Definition: pointMesh.C:104
~pointMesh()
Destructor.
Definition: pointMesh.C:66
virtual void addPatch(const label patchi)
Inserted patch at patchi.
Definition: pointMesh.C:151
void reset()
Reset pointMesh with respect to the updated polyMesh.
Definition: pointMesh.C:183
virtual void reorderPatches(const labelUList &newToOld, const bool validBoundary)
Reordered/removed trailing patches. If validBoundary call is.
Definition: pointMesh.C:127
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:80
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Definition: polyMesh.H:401
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
label patchi
const pointField & points
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:258
defineTypeNameAndDebug(combustionModel, 0)
prefixOSstream Pout(cout, "Pout")
Definition: IOstreams.H:53
error FatalError
FOR_ALL_FIELD_TYPES(makeFieldSourceTypedef)
#define ReorderPatchFieldsType(Type, nullArg)
#define AddPatchFieldsType(Type, nullArg)