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-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 \*---------------------------------------------------------------------------*/
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 
41 
42 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
43 
45 :
47  GeoMesh<polyMesh>(pMesh),
48  boundary_(*this, pMesh.boundaryMesh())
49 {
50  if (debug)
51  {
52  Pout<< "pointMesh::pointMesh(const polyMesh&): "
53  << "Constructing from polyMesh " << pMesh.name()
54  << endl;
55  }
56 
57  // Calculate the geometry for the patches (transformation tensors etc.)
58  boundary_.calcGeometry();
59 }
60 
61 
62 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
63 
65 {
66  if (debug)
67  {
68  Pout<< "~pointMesh::pointMesh()"
69  << endl;
71  }
72 }
73 
74 
75 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
76 
78 {
79  if (debug)
80  {
81  Pout<< "pointMesh::movePoints(const pointField&): "
82  << "Moving points." << endl;
83  }
84 
85  boundary_.movePoints(GeoMesh<polyMesh>::mesh_.points());
86 
87  return true;
88 }
89 
90 
92 {
93  if (debug)
94  {
95  Pout<< "pointMesh::topoChange(const polyTopoChangeMap&): "
96  << "Topology change." << endl;
97  Pout<< endl;
98  }
99  boundary_.topoChange();
100 }
101 
102 
104 {
105  if (debug)
106  {
107  Pout<< "pointMesh::mapMesh(const polyMeshMap&): "
108  << "Mesh mapping." << endl;
109  Pout<< endl;
110  }
111  boundary_.topoChange();
112 }
113 
114 
116 {
117  if (debug)
118  {
119  Pout<< "pointMesh::distribute(const polyDistributionMap&): "
120  << "Distribute." << endl;
121  Pout<< endl;
122  }
123  boundary_.topoChange();
124 }
125 
126 
128 (
129  const labelUList& newToOld,
130  const bool validBoundary
131 )
132 {
133  if (debug)
134  {
135  Pout<< "pointMesh::reorderPatches( const labelUList&, const bool): "
136  << "Updating for reordered patches." << endl;
137  Pout<< endl;
138  }
139 
140  boundary_.shuffle(newToOld, validBoundary);
141 
142  objectRegistry& db = const_cast<objectRegistry&>(thisDb());
143  ReorderPatchFields<pointScalarField>(db, newToOld);
144  ReorderPatchFields<pointVectorField>(db, newToOld);
145  ReorderPatchFields<pointSphericalTensorField>(db, newToOld);
146  ReorderPatchFields<pointSymmTensorField>(db, newToOld);
147  ReorderPatchFields<pointTensorField>(db, newToOld);
148 }
149 
150 
152 {
153  if (debug)
154  {
155  Pout<< "pointMesh::addPatch(const label): "
156  << "Adding patch at " << patchi << endl;
157  Pout<< endl;
158  }
159 
160  const polyBoundaryMesh& pbm = mesh().boundaryMesh();
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  objectRegistry& db = const_cast<objectRegistry&>(thisDb());
172  const dictionary d;
173  const word patchFieldType("calculated");
174 
175  AddPatchFields<pointScalarField>(db, patchi, d, patchFieldType, Zero);
176  AddPatchFields<pointVectorField>(db, patchi, d, patchFieldType, Zero);
177  AddPatchFields<pointSphericalTensorField>
178  (
179  db,
180  patchi,
181  d,
183  Zero
184  );
185  AddPatchFields<pointSymmTensorField>(db, patchi, d, patchFieldType, Zero);
186  AddPatchFields<pointTensorField>(db, patchi, d, patchFieldType, Zero);
187 }
188 
189 
191 {
192  if (debug)
193  {
194  Pout<< "pointMesh::reset(): "
195  << "Mesh reset." << endl;
196  Pout<< endl;
197  }
198  boundary_.reset();
199 }
200 
201 
202 // ************************************************************************* //
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:310
label size() const
Return the number of elements in the UPtrList.
Definition: UPtrListI.H:29
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
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.
Registry of regIOobjects.
Mesh representing a set of points created from polyMesh.
Definition: pointMesh.H:53
virtual bool movePoints()
Move points.
Definition: pointMesh.C:77
pointMesh(const polyMesh &pMesh)
Construct from polyMesh.
Definition: pointMesh.C:44
virtual void topoChange(const polyTopoChangeMap &)
Update the mesh corresponding to given map.
Definition: pointMesh.C:91
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:97
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
Definition: pointMesh.C:103
~pointMesh()
Destructor.
Definition: pointMesh.C:64
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:190
virtual void reorderPatches(const labelUList &newToOld, const bool validBoundary)
Reordered/removed trailing patches. If validBoundary call is.
Definition: pointMesh.C:128
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
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
A class for handling words, derived from string.
Definition: word.H:62
#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
static const zero Zero
Definition: zero.H:97
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:257
defineTypeNameAndDebug(combustionModel, 0)
word patchFieldType(const PatchField &pf)
prefixOSstream Pout(cout, "Pout")
Definition: IOstreams.H:53
error FatalError