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-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 \*---------------------------------------------------------------------------*/
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 
39 
40 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
41 
43 :
45  GeoMesh<polyMesh>(pMesh),
46  boundary_(*this, pMesh.boundaryMesh())
47 {
48  if (debug)
49  {
50  Pout<< "pointMesh::pointMesh(const polyMesh&): "
51  << "Constructing from polyMesh " << pMesh.name()
52  << endl;
53  }
54 
55  // Calculate the geometry for the patches (transformation tensors etc.)
56  boundary_.calcGeometry();
57 }
58 
59 
60 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
61 
63 {
64  if (debug)
65  {
66  Pout<< "~pointMesh::pointMesh()"
67  << endl;
69  }
70 }
71 
72 
73 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
74 
76 {
77  if (debug)
78  {
79  Pout<< "pointMesh::movePoints(const pointField&): "
80  << "Moving points." << endl;
81  }
82 
83  boundary_.movePoints(GeoMesh<polyMesh>::mesh_.points());
84 
85  return true;
86 }
87 
88 
90 {
91  if (debug)
92  {
93  Pout<< "pointMesh::topoChange(const polyTopoChangeMap&): "
94  << "Topology change." << endl;
95  Pout<< endl;
96  }
97  boundary_.topoChange();
98 }
99 
100 
102 {
103  if (debug)
104  {
105  Pout<< "pointMesh::mapMesh(const polyMeshMap&): "
106  << "Mesh mapping." << endl;
107  Pout<< endl;
108  }
109  boundary_.topoChange();
110 }
111 
112 
114 {
115  if (debug)
116  {
117  Pout<< "pointMesh::distribute(const polyDistributionMap&): "
118  << "Distribute." << endl;
119  Pout<< endl;
120  }
121  boundary_.topoChange();
122 }
123 
124 
126 (
127  const labelUList& newToOld,
128  const bool validBoundary
129 )
130 {
131  if (debug)
132  {
133  Pout<< "pointMesh::reorderPatches( const labelUList&, const bool): "
134  << "Updating for reordered patches." << endl;
135  Pout<< endl;
136  }
137 
138  boundary_.shuffle(newToOld, validBoundary);
139 
140  objectRegistry& db = const_cast<objectRegistry&>(thisDb());
141  ReorderPatchFields<pointScalarField>(db, newToOld);
142  ReorderPatchFields<pointVectorField>(db, newToOld);
143  ReorderPatchFields<pointSphericalTensorField>(db, newToOld);
144  ReorderPatchFields<pointSymmTensorField>(db, newToOld);
145  ReorderPatchFields<pointTensorField>(db, newToOld);
146 }
147 
148 
150 {
151  if (debug)
152  {
153  Pout<< "pointMesh::addPatch(const label): "
154  << "Adding patch at " << patchi << endl;
155  Pout<< endl;
156  }
157 
158  const polyBoundaryMesh& pbm = mesh().boundaryMesh();
159  if (pbm.size() != boundary_.size())
160  {
161  FatalErrorInFunction << "Problem :"
162  << " pointBoundaryMesh size :" << boundary_.size()
163  << " polyBoundaryMesh size :" << pbm.size()
164  << exit(FatalError);
165  }
166 
167  boundary_.set(patchi, facePointPatch::New(pbm[patchi], boundary_).ptr());
168 
169  objectRegistry& db = const_cast<objectRegistry&>(thisDb());
170  const dictionary d;
171  const word patchFieldType("calculated");
172 
173  AddPatchFields<pointScalarField>(db, patchi, d, patchFieldType, Zero);
174  AddPatchFields<pointVectorField>(db, patchi, d, patchFieldType, Zero);
175  AddPatchFields<pointSphericalTensorField>
176  (
177  db,
178  patchi,
179  d,
181  Zero
182  );
183  AddPatchFields<pointSymmTensorField>(db, patchi, d, patchFieldType, Zero);
184  AddPatchFields<pointTensorField>(db, patchi, d, patchFieldType, Zero);
185 }
186 
187 
189 {
190  if (debug)
191  {
192  Pout<< "pointMesh::reset(): "
193  << "Mesh reset." << endl;
194  Pout<< endl;
195  }
196  boundary_.reset();
197 }
198 
199 
200 // ************************************************************************* //
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:160
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:52
virtual bool movePoints()
Move points.
Definition: pointMesh.C:75
pointMesh(const polyMesh &pMesh)
Construct from polyMesh.
Definition: pointMesh.C:42
virtual void topoChange(const polyTopoChangeMap &)
Update the mesh corresponding to given map.
Definition: pointMesh.C:89
virtual void distribute(const polyDistributionMap &)
Redistribute or update using the given distribution map.
Definition: pointMesh.C:113
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
Definition: pointMesh.C:101
~pointMesh()
Destructor.
Definition: pointMesh.C:62
virtual void addPatch(const label patchi)
Inserted patch at patchi.
Definition: pointMesh.C:149
void reset()
Reset pointMesh with respect to the updated polyMesh.
Definition: pointMesh.C:188
virtual void reorderPatches(const labelUList &newToOld, const bool validBoundary)
Reordered/removed trailing patches. If validBoundary call is.
Definition: pointMesh.C:126
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:306
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:251
defineTypeNameAndDebug(combustionModel, 0)
word patchFieldType(const PatchField &pf)
prefixOSstream Pout(cout, "Pout")
Definition: IOstreams.H:53
error FatalError