polyMeshClear.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2017 OpenFOAM Foundation
9  Copyright (C) 2020 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "polyMesh.H"
30 #include "primitiveMesh.H"
31 #include "globalMeshData.H"
32 #include "MeshObject.H"
33 #include "indexedOctree.H"
34 #include "treeDataCell.H"
35 #include "pointMesh.H"
36 
37 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
38 
40 {
41  DebugInFunction << "Removing boundary patches." << endl;
42 
43  // Remove the point zones
44  boundary_.clear();
45  boundary_.setSize(0);
46 
47  clearOut();
48 }
49 
50 
51 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
52 
54 {
55  DebugInFunction << "Clearing geometric data" << endl;
56 
57  // Clear all geometric mesh objects
58  meshObject::clear<pointMesh, GeometricMeshObject>(*this);
59  meshObject::clear<polyMesh, GeometricMeshObject>(*this);
60 
62 
63  boundary_.clearGeom();
64 
65  // Reset valid directions (could change with rotation)
66  geometricD_ = Zero;
67  solutionD_ = Zero;
68 
69  // Remove the cell tree
70  cellTreePtr_.clear();
71 }
72 
73 
75 (
76  pointIOField&& newPoints,
77  autoPtr<labelIOList>& newTetBasePtIsPtr
78 )
79 {
81  << "Updating geometric data with newPoints:"
82  << newPoints.size() << " newTetBasePtIs:"
83  << bool(newTetBasePtIsPtr) << endl;
84 
85  if (points_.size() != 0 && points_.size() != newPoints.size())
86  {
88  << "Point motion detected but number of points "
89  << newPoints.size() << " in "
90  << newPoints.objectPath() << " does not correspond to "
91  << " current " << points_.size()
92  << exit(FatalError);
93  }
94 
95  // Clear all geometric mesh objects that are not 'movable'
97  <
98  pointMesh,
101  >
102  (
103  *this
104  );
106  <
107  polyMesh,
110  >
111  (
112  *this
113  );
114 
116 
117  boundary_.clearGeom();
118 
119  // Reset valid directions (could change with rotation)
120  geometricD_ = Zero;
121  solutionD_ = Zero;
122 
123  // Remove the cell tree
124  cellTreePtr_.clear();
125 
126  // Update local data
127  points_.instance() = newPoints.instance();
128  points_.transfer(newPoints);
129 
130  // Optional new tet base points
131  if (newTetBasePtIsPtr)
132  {
133  tetBasePtIsPtr_ = std::move(newTetBasePtIsPtr);
134  }
135 
136  // Calculate the geometry for the patches (transformation tensors etc.)
137  boundary_.calcGeometry();
138 
139  // Derived info
140  bounds_ = boundBox(points_);
141 
142  // Rotation can cause direction vector to change
143  geometricD_ = Zero;
144  solutionD_ = Zero;
145 
146  // Update all 'movable' objects
147  meshObject::movePoints<polyMesh>(*this);
148  meshObject::movePoints<pointMesh>(*this);
149 }
150 
151 
152 void Foam::polyMesh::clearAddressing(const bool isMeshUpdate)
153 {
155  << "Clearing topology isMeshUpdate:" << isMeshUpdate << endl;
156 
157  if (isMeshUpdate)
158  {
159  // Part of a mesh update. Keep meshObjects that have an updateMesh
160  // callback
162  <
163  pointMesh,
166  >
167  (
168  *this
169  );
171  <
172  polyMesh,
175  >
176  (
177  *this
178  );
179  }
180  else
181  {
182  meshObject::clear<pointMesh, TopologicalMeshObject>(*this);
183  meshObject::clear<polyMesh, TopologicalMeshObject>(*this);
184  }
185 
187 
188  // parallelData depends on the processorPatch ordering so force
189  // recalculation
190  globalMeshDataPtr_.clear();
191 
192  // Reset valid directions
193  geometricD_ = Zero;
194  solutionD_ = Zero;
195 
196  // Update zones
197  pointZones_.clearAddressing();
198  faceZones_.clearAddressing();
199  cellZones_.clearAddressing();
200 
201  // Remove the stored tet base points
202  tetBasePtIsPtr_.clear();
203 
204  // Remove the cell tree
205  cellTreePtr_.clear();
206 }
207 
208 
210 {
211  resetMotion();
212 
213  points_.setSize(0);
214  faces_.setSize(0);
215  owner_.setSize(0);
216  neighbour_.setSize(0);
217 
218  clearedPrimitives_ = true;
219 }
220 
221 
223 {
224  clearGeom();
225  clearAddressing();
226 }
227 
228 
230 {
231  DebugInFunction << "Clearing tet base points" << endl;
232 
233  tetBasePtIsPtr_.clear();
234 }
235 
236 
238 {
239  DebugInFunction << "Clearing cell tree" << endl;
240 
241  cellTreePtr_.clear();
242 }
243 
244 
245 // ************************************************************************* //
Foam::primitiveMesh::clearGeom
void clearGeom()
Clear geometry.
Definition: primitiveMeshClear.C:127
Foam::IOField
A primitive field of type <T> with automated input and output.
Definition: foamVtkLagrangianWriter.H:61
Foam::primitiveMesh::clearAddressing
void clearAddressing()
Clear topological data.
Definition: primitiveMeshClear.C:157
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
globalMeshData.H
Foam::polyMesh::clearCellTree
void clearCellTree()
Clear cell tree data.
Definition: polyMeshClear.C:237
indexedOctree.H
Foam::MoveableMeshObject
Definition: MeshObject.H:220
primitiveMesh.H
Foam::polyMesh::clearOut
void clearOut()
Clear all geometry and addressing unnecessary for CFD.
Definition: polyMeshClear.C:222
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
polyMesh.H
Foam::UpdateableMeshObject
Definition: MeshObject.H:241
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
DebugInFunction
#define DebugInFunction
Report an information message using Foam::Info.
Definition: messageStream.H:388
Foam::polyMesh::clearPrimitives
void clearPrimitives()
Clear primitive data (points, faces and cells)
Definition: polyMeshClear.C:209
Foam::polyMesh::clearTetBasePtIs
void clearTetBasePtIs()
Clear tet base points.
Definition: polyMeshClear.C:229
Foam::PtrList::setSize
void setSize(const label newLen)
Same as resize()
Definition: PtrList.H:151
Foam::FatalError
error FatalError
Foam::PtrList::clear
void clear()
Clear the PtrList. Delete allocated entries and set size to zero.
Definition: PtrListI.H:97
Foam::pointMesh
Mesh representing a set of points created from polyMesh.
Definition: pointMesh.H:51
treeDataCell.H
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
Foam::polyMesh::removeBoundary
void removeBoundary()
Remove boundary patches.
Definition: polyMeshClear.C:39
Foam::polyMesh::clearGeom
void clearGeom()
Clear geometry.
Definition: polyMeshClear.C:53
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
Foam::meshObject::clearUpto
static void clearUpto(objectRegistry &obr)
Definition: MeshObject.C:217
bool
bool
Definition: EEqn.H:20
Foam::TopologicalMeshObject
Definition: MeshObject.H:182
Foam::boundBox
A bounding box defined in terms of min/max extrema points.
Definition: boundBox.H:63
MeshObject.H
Foam::polyMesh::updateGeomPoints
void updateGeomPoints(pointIOField &&newPoints, autoPtr< labelIOList > &newTetBasePtIsPtr)
Definition: polyMeshClear.C:75
pointMesh.H