polyMeshUpdate.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-2024 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 Description
25  Update the polyMesh corresponding to the given map.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "polyMesh.H"
30 #include "polyTopoChangeMap.H"
31 #include "Time.H"
32 #include "globalMeshData.H"
33 #include "pointMesh.H"
34 #include "indexedOctree.H"
35 #include "treeDataCell.H"
36 
37 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
38 
40 {
41  pointZones_.topoChange(map);
42  faceZones_.topoChange(map);
43  cellZones_.topoChange(map);
44 }
45 
46 
48 {
49  if (debug)
50  {
52  << "Updating addressing and (optional) pointMesh/pointFields"
53  << endl;
54  }
55 
56  // Update boundaryMesh (note that patches themselves already ok)
57  boundary_.topoChange();
58 
59  // Update zones
60  topoChangeZones(map);
61 
62  // Remove the stored tet base points
63  tetBasePtIsPtr_.clear();
64 
65  // Remove the cell tree
66  cellTreePtr_.clear();
67 
68  // Update parallel data
69  if (globalMeshDataPtr_.valid())
70  {
71  globalMeshDataPtr_->topoChange();
72  }
73 
74  setInstance(time().name());
75 
76  // Map the old motion points if present
77  if (oldPointsPtr_.valid())
78  {
79  // Make a copy of the original points
80  pointField oldMotionPoints = oldPointsPtr_();
81 
82  pointField& newMotionPoints = oldPointsPtr_();
83 
84  // Resize the list to new size
85  newMotionPoints.setSize(points_.size());
86 
87  // Map the list
88  newMotionPoints.map(oldMotionPoints, map.pointMap());
89 
90  // Any points created out-of-nothing get set to the current coordinate
91  // for lack of anything better.
92  forAll(map.pointMap(), newPointi)
93  {
94  if (map.pointMap()[newPointi] == -1)
95  {
96  newMotionPoints[newPointi] = points_[newPointi];
97  }
98  }
99  }
100 
101  if (oldCellCentresPtr_.valid())
102  {
103  // Make a copy of the original cell-centres
104  pointField oldMotionCellCentres = oldCellCentresPtr_();
105 
106  pointField& newMotionCellCentres = oldCellCentresPtr_();
107 
108  // Resize the list to new size
109  newMotionCellCentres.setSize(cellCentres().size());
110 
111  // Map the list
112  newMotionCellCentres.map(oldMotionCellCentres, map.cellMap());
113 
114  // Any points created out-of-nothing get set to the current coordinate
115  // for lack of anything better.
116  forAll(map.cellMap(), newCelli)
117  {
118  if (map.cellMap()[newCelli] == -1)
119  {
120  newMotionCellCentres[newCelli] = cellCentres()[newCelli];
121  }
122  }
123  }
124 
125  meshObjects::topoChange<polyMesh>(*this, map);
126  meshObjects::topoChange<pointMesh>(*this, map);
127 
128  // Reset valid directions (could change by faces put into empty patches)
129  geometricD_ = Zero;
130  solutionD_ = Zero;
131 }
132 
133 
135 {
136  // Update zones
137  pointZones_.mapMesh(map);
138  faceZones_.mapMesh(map);
139  cellZones_.mapMesh(map);
140 
141  meshObjects::mapMesh<polyMesh>(*this, map);
142  meshObjects::mapMesh<pointMesh>(*this, map);
143 }
144 
145 
147 {
148  // Update zones
149  pointZones_.distribute(map);
150  faceZones_.distribute(map);
151  cellZones_.distribute(map);
152 
153  meshObjects::distribute<polyMesh>(*this, map);
154  meshObjects::distribute<pointMesh>(*this, map);
155 }
156 
157 
158 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
void map(const UList< Type > &mapF, const labelUList &mapAddressing)
1 to 1 map from the given field
Definition: Field.C:289
void setSize(const label)
Reset size of List.
Definition: List.C:281
virtual void topoChange(const polyTopoChangeMap &map)
Update topology using the given map.
Definition: ZoneList.C:379
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
Class containing mesh-to-mesh mapping information.
Definition: polyMeshMap.H:51
virtual void topoChange(const polyTopoChangeMap &)
Update topology using the given map.
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
void topoChangeZones(const polyTopoChangeMap &)
Update zones using the given map.
virtual void distribute(const polyDistributionMap &map)
Redistribute or update using the given distribution map.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
const labelList & cellMap() const
Old cell map.
const labelList & pointMap() const
Old point map.
#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:257
word name(const bool)
Return a word representation of a bool.
Definition: boolIO.C:39
label newPointi
Definition: readKivaGrid.H:495