polyMeshClear.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-2025 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 "polyMesh.H"
27 #include "primitiveMesh.H"
28 #include "globalMeshData.H"
29 #include "meshObjects.H"
30 #include "indexedOctree.H"
31 #include "treeDataCell.H"
32 #include "pointMesh.H"
33 
34 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
35 
37 {
38  if (debug)
39  {
40  InfoInFunction << "Removing boundary patches." << endl;
41  }
42 
43  // Remove the point zones
44  boundary_.clear();
45  boundary_.setSize(0);
46 
47  clearOut();
48 }
49 
50 
51 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
52 
54 {
56 
57  Pout<< "polyMesh allocated :" << endl;
58 
59  if (cellTreePtr_.valid())
60  {
61  Pout<< " Cell tree" << endl;
62  }
63 
64  if (tetBasePtIsPtr_.valid())
65  {
66  Pout<< " Tet base points" << endl;
67  }
68 }
69 
70 
72 {
73  if (debug)
74  {
75  InfoInFunction << "Clearing geometric data" << endl;
76  }
77 
78  // Clear all geometric mesh objects
79  meshObjects::clear<pointMesh, DeletableMeshObject>(*this);
80  meshObjects::clear<polyMesh, DeletableMeshObject>(*this);
81 
83 
84  boundary_.clearGeom();
85 
86  // Reset valid directions (could change with rotation)
87  geometricD_ = Zero;
88  solutionD_ = Zero;
89 
90  // Remove the cell tree
91  cellTreePtr_.clear();
92 }
93 
94 
95 void Foam::polyMesh::clearAddressing(const bool isMeshUpdate)
96 {
97  if (debug)
98  {
100  << "Clearing topology isMeshUpdate:" << isMeshUpdate << endl;
101  }
102 
103  if (isMeshUpdate)
104  {
105  // Part of a mesh update. Keep meshObjects that have an topoChange
106  // callback
108  <
109  pointMesh,
112  >
113  (
114  *this
115  );
117  <
118  polyMesh,
121  >
122  (
123  *this
124  );
125  }
126  else
127  {
128  meshObjects::clear<pointMesh, DeletableMeshObject>(*this);
129  meshObjects::clear<polyMesh, DeletableMeshObject>(*this);
130  }
131 
133 
134  // parallelData depends on the processorPatch ordering so force
135  // recalculation
136  globalMeshDataPtr_.clear();
137 
138  // Reset valid directions
139  geometricD_ = Zero;
140  solutionD_ = Zero;
141 
142  // Update zones
143  pointZones_.clearAddressing();
144  faceZones_.clearAddressing();
145  cellZones_.clearAddressing();
146 
147  // Remove the stored tet base points
148  tetBasePtIsPtr_.clear();
149 
150  // Remove the cell tree
151  cellTreePtr_.clear();
152 }
153 
154 
156 {
157  resetMotion();
158 
159  points_.setSize(0);
160  faces_.setSize(0);
161  owner_.setSize(0);
162  neighbour_.setSize(0);
163 
164  clearedPrimitives_ = true;
165 }
166 
167 
169 {
170  clearGeom();
171  clearAddressing();
172 }
173 
174 
176 {
177  if (debug)
178  {
179  InfoInFunction << "Clearing tet base points" << endl;
180  }
181 
182  tetBasePtIsPtr_.clear();
183 }
184 
185 
187 {
188  if (debug)
189  {
190  InfoInFunction << "Clearing cell tree" << endl;
191  }
192 
193  cellTreePtr_.clear();
194 }
195 
196 
197 // ************************************************************************* //
MeshObject types:
Definition: MeshObjects.H:67
void clear()
Clear the PtrList, i.e. set size to zero deleting all the.
Definition: PtrList.C:198
void setSize(const label)
Reset size of PtrList. If extending the PtrList, new entries are.
Definition: PtrList.C:131
static void clearUpto(objectRegistry &)
Clear all meshObjects derived from FromType up to (but not including)
Mesh representing a set of points created from polyMesh.
Definition: pointMesh.H:53
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:80
void clearCellTree()
Clear cell tree data.
void clearGeom()
Clear geometry.
Definition: polyMeshClear.C:71
void clearPrimitives()
Clear primitive data (points, faces and cells)
void clearTetBasePtIs()
Clear tet base points.
void printAllocated() const
Print a list of all the currently allocated mesh data.
Definition: polyMeshClear.C:53
void removeBoundary()
Remove boundary patches.
Definition: polyMeshClear.C:36
void clearOut()
Clear all geometry and addressing unnecessary for CFD.
void clearGeom()
Clear geometry.
void clearAddressing()
Clear topological data.
void printAllocated() const
Print a list of all the currently allocated mesh data.
#define InfoInFunction
Report an information message using Foam::Info.
static const zero Zero
Definition: zero.H:97
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:258
prefixOSstream Pout(cout, "Pout")
Definition: IOstreams.H:53