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-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 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 
35 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
36 
38 {
39  pointZones_.topoChange(map);
40  faceZones_.topoChange(map);
41  cellZones_.topoChange(map);
42 }
43 
44 
46 {
47  if (debug)
48  {
50  << "Updating addressing and (optional) pointMesh/pointFields"
51  << endl;
52  }
53 
54  // Update boundaryMesh (note that patches themselves already ok)
55  boundary_.topoChange();
56 
57  // Update zones
58  topoChangeZones(map);
59 
60  // Remove the stored tet base points
61  tetBasePtIsPtr_.clear();
62 
63  // Update parallel data
64  if (globalMeshDataPtr_.valid())
65  {
66  globalMeshDataPtr_->topoChange();
67  }
68 
69  setInstance(time().name());
70 
71  // Map the old motion points if present
72  if (oldPointsPtr_.valid())
73  {
74  // Make a copy of the original points
75  pointField oldMotionPoints = oldPointsPtr_();
76 
77  pointField& newMotionPoints = oldPointsPtr_();
78 
79  // Resize the list to new size
80  newMotionPoints.setSize(points_.size());
81 
82  // Map the list
83  newMotionPoints.map(oldMotionPoints, map.pointMap());
84 
85  // Any points created out-of-nothing get set to the current coordinate
86  // for lack of anything better.
87  forAll(map.pointMap(), newPointi)
88  {
89  if (map.pointMap()[newPointi] == -1)
90  {
91  newMotionPoints[newPointi] = points_[newPointi];
92  }
93  }
94  }
95 
96  if (oldCellCentresPtr_.valid())
97  {
98  // Make a copy of the original cell-centres
99  pointField oldMotionCellCentres = oldCellCentresPtr_();
100 
101  pointField& newMotionCellCentres = oldCellCentresPtr_();
102 
103  // Resize the list to new size
104  newMotionCellCentres.setSize(cellCentres().size());
105 
106  // Map the list
107  newMotionCellCentres.map(oldMotionCellCentres, map.cellMap());
108 
109  // Any points created out-of-nothing get set to the current coordinate
110  // for lack of anything better.
111  forAll(map.cellMap(), newCelli)
112  {
113  if (map.cellMap()[newCelli] == -1)
114  {
115  newMotionCellCentres[newCelli] = cellCentres()[newCelli];
116  }
117  }
118  }
119 
120  meshObjects::topoChange<polyMesh>(*this, map);
121  meshObjects::topoChange<pointMesh>(*this, map);
122 
123  // Reset valid directions (could change by faces put into empty patches)
124  geometricD_ = Zero;
125  solutionD_ = Zero;
126 }
127 
128 
130 {
131  // Update zones
132  pointZones_.mapMesh(map);
133  faceZones_.mapMesh(map);
134  cellZones_.mapMesh(map);
135 
136  meshObjects::mapMesh<polyMesh>(*this, map);
137  meshObjects::mapMesh<pointMesh>(*this, map);
138 }
139 
140 
142 {
143  // Update zones
144  pointZones_.distribute(map);
145  faceZones_.distribute(map);
146  cellZones_.distribute(map);
147 
148  meshObjects::distribute<polyMesh>(*this, map);
149  meshObjects::distribute<pointMesh>(*this, map);
150 }
151 
152 
153 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:433
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:435
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:258
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
label newPointi
Definition: readKivaGrid.H:495