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