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 {
36  defineTypeNameAndDebug(pointMesh, 0);
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 
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 // ************************************************************************* //
virtual bool movePoints()
Move points.
Definition: pointMesh.C:75
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Definition: polyMesh.H:453
static void printStack(Ostream &)
Helper function to print a stack.
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
virtual void reorderPatches(const labelUList &newToOld, const bool validBoundary)
Reordered/removed trailing patches. If validBoundary call is.
Definition: pointMesh.C:126
const word & name() const
Return name.
Definition: IOobject.H:315
bool set(const label) const
Is element set.
Definition: PtrListI.H:65
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
error FatalError
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:306
void movePoints(const pointField &)
Correct pointBoundaryMesh after moving points.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
void shuffle(const labelUList &newToOld, const bool validBoundary)
Reorders patches. Ordering does not have to be done in.
virtual void addPatch(const label patchi)
Inserted patch at patchi.
Definition: pointMesh.C:149
void topoChange()
Correct pointBoundaryMesh after topology update.
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:48
Templated abstract base-class for optional mesh objects used to automate their allocation to the mesh...
Definition: MeshObject.H:87
void reset()
Reset pointBoundaryMesh with respect to the updated polyBoundaryMesh.
void reset()
Reset pointMesh with respect to the updated polyMesh.
Definition: pointMesh.C:188
const pointField & points
A class for handling words, derived from string.
Definition: word.H:59
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
const objectRegistry & thisDb() const
Return database. For now is its polyMesh.
Definition: pointMesh.H:109
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
Definition: pointMesh.C:101
~pointMesh()
Destructor.
Definition: pointMesh.C:62
static const zero Zero
Definition: zero.H:97
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:60
Foam::polyBoundaryMesh.
virtual void topoChange(const polyTopoChangeMap &)
Update the mesh corresponding to given map.
Definition: pointMesh.C:89
defineTypeNameAndDebug(combustionModel, 0)
label size() const
Return the number of elements in the UPtrList.
Definition: UPtrListI.H:29
label patchi
prefixOSstream Pout(cout, "Pout")
Definition: IOstreams.H:53
pointMesh(const polyMesh &pMesh)
Construct from polyMesh.
Definition: pointMesh.C:42
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:76
Generic mesh wrapper used by volMesh, surfaceMesh, pointMesh etc.
Definition: GeoMesh.H:46
Registry of regIOobjects.
Class containing mesh-to-mesh mapping information.
Definition: polyMeshMap.H:50
const objectRegistry & db() const
Return the local objectRegistry.
Definition: IOobject.C:312
word patchFieldType(const PatchField &pf)
virtual void distribute(const polyDistributionMap &)
Redistribute or update using the given distribution map.
Definition: pointMesh.C:113
Namespace for OpenFOAM.