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 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "polyMesh.H"
29 #include "primitiveMesh.H"
30 #include "globalMeshData.H"
31 #include "MeshObject.H"
32 #include "indexedOctree.H"
33 #include "treeDataCell.H"
34 #include "pointMesh.H"
35 
36 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
37 
39 {
40  if (debug)
41  {
42  InfoInFunction << "Removing boundary patches." << endl;
43  }
44 
45  // Remove the point zones
46  boundary_.clear();
47  boundary_.setSize(0);
48 
49  clearOut();
50 }
51 
52 
53 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
54 
56 {
57  if (debug)
58  {
59  InfoInFunction << "Clearing geometric data" << endl;
60  }
61 
62  // Clear all geometric mesh objects
63  meshObject::clear<pointMesh, GeometricMeshObject>(*this);
64  meshObject::clear<polyMesh, GeometricMeshObject>(*this);
65 
67 
68  boundary_.clearGeom();
69 
70  // Reset valid directions (could change with rotation)
71  geometricD_ = Zero;
72  solutionD_ = Zero;
73 
74  // Remove the cell tree
75  cellTreePtr_.clear();
76 }
77 
78 
80 (
81  pointIOField& newPoints,
82  autoPtr<labelIOList>& newTetBasePtIsPtr
83 )
84 {
85  if (debug)
86  {
87  InfoInFunction << "Updating geometric data with newPoints:"
88  << newPoints.size() << " newTetBasePtIs:"
89  << newTetBasePtIsPtr.valid() << endl;
90  }
91 
92  if (points_.size() != 0 && points_.size() != newPoints.size())
93  {
95  << "Point motion detected but number of points "
96  << newPoints.size() << " in "
97  << newPoints.objectPath() << " does not correspond to "
98  << " current " << points_.size()
99  << exit(FatalError);
100  }
101 
102  // Clear all geometric mesh objects that are not 'moveable'
104  <
105  pointMesh,
108  >
109  (
110  *this
111  );
113  <
114  polyMesh,
117  >
118  (
119  *this
120  );
121 
123 
124  boundary_.clearGeom();
125 
126  // Reset valid directions (could change with rotation)
127  geometricD_ = Zero;
128  solutionD_ = Zero;
129 
130  // Remove the cell tree
131  cellTreePtr_.clear();
132 
133  // Update local data
134  points_.instance() = newPoints.instance();
135  points_.transfer(newPoints);
136 
137  // Optional new tet base points
138  if (newTetBasePtIsPtr.valid())
139  {
140  tetBasePtIsPtr_ = std::move(newTetBasePtIsPtr);
141  }
142 
143  // Calculate the geometry for the patches (transformation tensors etc.)
144  boundary_.calcGeometry();
145 
146  // Derived info
147  bounds_ = boundBox(points_);
148 
149  // Rotation can cause direction vector to change
150  geometricD_ = Zero;
151  solutionD_ = Zero;
152 
153  // Update all 'moveable' objects
154  meshObject::movePoints<polyMesh>(*this);
155  meshObject::movePoints<pointMesh>(*this);
156 }
157 
158 
159 void Foam::polyMesh::clearAddressing(const bool isMeshUpdate)
160 {
161  if (debug)
162  {
164  << "Clearing topology isMeshUpdate:" << isMeshUpdate << endl;
165  }
166 
167  if (isMeshUpdate)
168  {
169  // Part of a mesh update. Keep meshObjects that have an updateMesh
170  // callback
172  <
173  pointMesh,
176  >
177  (
178  *this
179  );
181  <
182  polyMesh,
185  >
186  (
187  *this
188  );
189  }
190  else
191  {
192  meshObject::clear<pointMesh, TopologicalMeshObject>(*this);
193  meshObject::clear<polyMesh, TopologicalMeshObject>(*this);
194  }
195 
197 
198  // parallelData depends on the processorPatch ordering so force
199  // recalculation
200  globalMeshDataPtr_.clear();
201 
202  // Reset valid directions
203  geometricD_ = Zero;
204  solutionD_ = Zero;
205 
206  // Update zones
207  pointZones_.clearAddressing();
208  faceZones_.clearAddressing();
209  cellZones_.clearAddressing();
210 
211  // Remove the stored tet base points
212  tetBasePtIsPtr_.clear();
213 
214  // Remove the cell tree
215  cellTreePtr_.clear();
216 }
217 
218 
220 {
221  resetMotion();
222 
223  points_.setSize(0);
224  faces_.setSize(0);
225  owner_.setSize(0);
226  neighbour_.setSize(0);
227 
228  clearedPrimitives_ = true;
229 }
230 
231 
233 {
234  clearGeom();
235  clearAddressing();
236 }
237 
238 
240 {
241  if (debug)
242  {
243  InfoInFunction << "Clearing tet base points" << endl;
244  }
245 
246  tetBasePtIsPtr_.clear();
247 }
248 
249 
251 {
252  if (debug)
253  {
254  InfoInFunction << "Clearing cell tree" << endl;
255  }
256 
257  cellTreePtr_.clear();
258 }
259 
260 
261 // ************************************************************************* //
Foam::expressions::patchExpr::debug
int debug
Static debugging option.
Foam::primitiveMesh::clearGeom
void clearGeom()
Clear geometry.
Definition: primitiveMeshClear.C:127
InfoInFunction
#define InfoInFunction
Report an information message using Foam::Info.
Definition: messageStream.H:316
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:143
Foam::Zero
static constexpr const zero Zero
Global zero.
Definition: zero.H:128
globalMeshData.H
Foam::polyMesh::clearCellTree
void clearCellTree()
Clear cell tree data.
Definition: polyMeshClear.C:250
indexedOctree.H
Foam::MoveableMeshObject
Definition: MeshObject.H:220
Foam::autoPtr::valid
bool valid() const noexcept
True if the managed pointer is non-null.
Definition: autoPtrI.H:107
Foam::polyMesh::updateGeom
void updateGeom(pointIOField &newPoints, autoPtr< labelIOList > &newTetBasePtIsPtr)
Update geometry; keep topology. Optional new face decomposition.
Definition: polyMeshClear.C:80
primitiveMesh.H
Foam::polyMesh::clearOut
void clearOut()
Clear all geometry and addressing unnecessary for CFD.
Definition: polyMeshClear.C:232
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:337
polyMesh.H
Foam::UpdateableMeshObject
Definition: MeshObject.H:241
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::polyMesh::clearPrimitives
void clearPrimitives()
Clear primitive data (points, faces and cells)
Definition: polyMeshClear.C:219
Foam::polyMesh::clearTetBasePtIs
void clearTetBasePtIs()
Clear tet base points.
Definition: polyMeshClear.C:239
Foam::PtrList::setSize
void setSize(const label newLen)
Same as resize()
Definition: PtrListI.H:108
Foam::FatalError
error FatalError
Foam::PtrList::clear
void clear()
Clear the PtrList. Delete allocated entries and set size to zero.
Definition: PtrListI.H:100
Foam::pointMesh
Mesh representing a set of points created from polyMesh.
Definition: pointMesh.H:50
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:38
Foam::polyMesh::clearGeom
void clearGeom()
Clear geometry.
Definition: polyMeshClear.C:55
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:355
Foam::meshObject::clearUpto
static void clearUpto(objectRegistry &obr)
Definition: MeshObject.C:217
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
pointMesh.H