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-------------------------------------------------------------------------------
11License
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 <
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
152void 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// ************************************************************************* //
A primitive field of type <T> with automated input and output.
Definition: IOField.H:58
void setSize(const label newLen)
Same as resize()
Definition: PtrList.H:151
void clear()
Clear the PtrList. Delete allocated entries and set size to zero.
Definition: PtrListI.H:97
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
A bounding box defined in terms of min/max extrema points.
Definition: boundBox.H:64
static void clearUpto(objectRegistry &obr)
Definition: MeshObject.C:217
Mesh representing a set of points created from polyMesh.
Definition: pointMesh.H:55
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:81
void clearCellTree()
Clear cell tree data.
void clearGeom()
Clear geometry.
Definition: polyMeshClear.C:53
void clearPrimitives()
Clear primitive data (points, faces and cells)
void updateGeomPoints(pointIOField &&newPoints, autoPtr< labelIOList > &newTetBasePtIsPtr)
Definition: polyMeshClear.C:75
void clearAddressing(const bool isMeshUpdate=false)
Clear addressing.
void clearTetBasePtIs()
Clear tet base points.
void removeBoundary()
Remove boundary patches.
Definition: polyMeshClear.C:39
void clearOut()
Clear all geometry and addressing unnecessary for CFD.
void clearGeom()
Clear geometry.
void clearAddressing()
Clear topological data.
bool
Definition: EEqn.H:20
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
#define DebugInFunction
Report an information message using Foam::Info.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
error FatalError
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130