Loading...
Searching...
No Matches
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-2024 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 boundary_.clear();
45 clearOut();
46}
47
48
49// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
50
52{
53 DebugInFunction << "Clearing geometric data" << endl;
54
55 // Clear all geometric mesh objects
58
60
61 boundary_.clearGeom();
62
63 // Reset valid directions (could change with rotation)
64 geometricD_ = Zero;
65 solutionD_ = Zero;
66
67 // Remove the cell tree
68 cellTreePtr_.reset(nullptr);
69}
70
71
73(
74 pointIOField&& newPoints,
75 autoPtr<labelIOList>& newTetBasePtIsPtr
76)
77{
79 << "Updating geometric data with newPoints:"
80 << newPoints.size() << " newTetBasePtIs:"
81 << bool(newTetBasePtIsPtr) << endl;
82
83 if (points_.size() != 0 && points_.size() != newPoints.size())
84 {
86 << "Point motion detected but number of points "
87 << newPoints.size() << " in "
88 << newPoints.objectPath() << " does not correspond to "
89 << " current " << points_.size()
90 << exit(FatalError);
91 }
92
93 // Clear all geometric mesh objects that are not 'movable'
95 <
96 pointMesh,
97 TopologicalMeshObject,
98 MoveableMeshObject
99 >
100 (
101 *this
102 );
104 <
105 polyMesh,
106 TopologicalMeshObject,
107 MoveableMeshObject
108 >
109 (
110 *this
111 );
112
114
115 boundary_.clearGeom();
116
117 // Reset valid directions (could change with rotation)
118 geometricD_ = Zero;
119 solutionD_ = Zero;
120
121 // Remove the cell tree
122 cellTreePtr_.reset(nullptr);
123
124 // Update local data
125 points_.instance() = newPoints.instance();
126 points_.transfer(newPoints);
127
128 // Optional new tet base points
129 if (newTetBasePtIsPtr)
130 {
131 tetBasePtIsPtr_ = std::move(newTetBasePtIsPtr);
132 }
133
134 // Calculate the geometry for the patches (transformation tensors etc.)
135 boundary_.calcGeometry();
136
137 // Derived info
138 bounds_ = boundBox(points_);
139
140 // Rotation can cause direction vector to change
141 geometricD_ = Zero;
142 solutionD_ = Zero;
144 // Update all 'movable' objects
147}
148
149
150void Foam::polyMesh::clearAddressing(const bool isMeshUpdate)
151{
153 << "isMeshUpdate:" << isMeshUpdate << endl;
154
155 if (isMeshUpdate)
156 {
157 // Part of a mesh update.
158 // Keep meshObjects that have an updateMesh callback
160 <
161 pointMesh,
164 >
165 (
166 *this
167 );
169 <
170 polyMesh,
173 >
174 (
175 *this
176 );
177 }
178 else
179 {
182 }
183
185
186 // parallelData depends on the processorPatch ordering so force
187 // recalculation
188 globalMeshDataPtr_.reset(nullptr);
189
190 // Reset valid directions
191 geometricD_ = Zero;
192 solutionD_ = Zero;
193
194 // Update zones
195 pointZones_.clearAddressing();
196 faceZones_.clearAddressing();
197 cellZones_.clearAddressing();
198
199 // Remove the stored tet base points
200 tetBasePtIsPtr_.reset(nullptr);
201
202 // Remove the cell tree
203 cellTreePtr_.reset(nullptr);
204}
205
206
208{
209 resetMotion();
210
211 points_.clear();
212 faces_.clear();
213 owner_.clear();
214 neighbour_.clear();
215
216 clearedPrimitives_ = true;
217}
218
219
220void Foam::polyMesh::clearOut(const bool isMeshUpdate)
221{
222 clearGeom(); // not implementable? isMeshUpdate
223 clearAddressing(isMeshUpdate);
224}
225
226
229 DebugInFunction << "Clearing tet base points" << endl;
230
231 tetBasePtIsPtr_.reset(nullptr);
232}
233
234
236{
238
239 cellTreePtr_.reset(nullptr);
240}
241
242
243// ************************************************************************* //
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
A bounding box defined in terms of min/max extrema points.
Definition boundBox.H:71
static void clearUpto(objectRegistry &obr)
Clear all meshObject derived from FromType up to (but not including) ToType.
static void clear(objectRegistry &obr)
Clear/remove all meshObject of MeshObjectType via objectRegistry::checkOut().
static void movePoints(objectRegistry &obr)
Update for mesh motion.
Mesh representing a set of points created from polyMesh.
Definition pointMesh.H:49
Mesh consisting of general polyhedral cells.
Definition polyMesh.H:79
void clearCellTree()
Clear cell tree data.
void clearGeom()
Clear geometry.
void clearPrimitives()
Clear primitive data (points, faces and cells).
void updateGeomPoints(pointIOField &&newPoints, autoPtr< labelIOList > &newTetBasePtIsPtr)
Update geometry points; keep topology. Optionally with new face decomposition.
void clearAddressing(const bool isMeshUpdate=false)
Clear addressing.
void resetMotion() const
Reset motion.
Definition polyMesh.C:1282
void clearTetBasePtIs()
Clear tet base points.
void removeBoundary()
Remove boundary patches.
void clearGeom()
Clear geometry.
void clearAddressing()
Clear topological data.
void clearOut()
Clear all geometry and addressing unnecessary for CFD.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition error.H:600
#define DebugInFunction
Report an information message using Foam::Info.
vectorIOField pointIOField
pointIOField is a vectorIOField.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
static constexpr const zero Zero
Global zero (0).
Definition zero.H:127
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition errorManip.H:125