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-2022 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  if (debug)
42  {
44  << "Updating addressing and (optional) pointMesh/pointFields"
45  << endl;
46  }
47 
48  // Update boundaryMesh (note that patches themselves already ok)
49  boundary_.topoChange();
50 
51  // Update zones
52  pointZones_.clearAddressing();
53  faceZones_.clearAddressing();
54  cellZones_.clearAddressing();
55 
56  // Remove the stored tet base points
57  tetBasePtIsPtr_.clear();
58 
59  // Remove the cell tree
60  cellTreePtr_.clear();
61 
62  // Update parallel data
63  if (globalMeshDataPtr_.valid())
64  {
65  globalMeshDataPtr_->topoChange();
66  }
67 
69 
70  // Map the old motion points if present
71  if (oldPointsPtr_.valid())
72  {
73  // Make a copy of the original points
74  pointField oldMotionPoints = oldPointsPtr_();
75 
76  pointField& newMotionPoints = oldPointsPtr_();
77 
78  // Resize the list to new size
79  newMotionPoints.setSize(points_.size());
80 
81  // Map the list
82  newMotionPoints.map(oldMotionPoints, map.pointMap());
83 
84  // Any points created out-of-nothing get set to the current coordinate
85  // for lack of anything better.
86  forAll(map.pointMap(), newPointi)
87  {
88  if (map.pointMap()[newPointi] == -1)
89  {
90  newMotionPoints[newPointi] = points_[newPointi];
91  }
92  }
93  }
94 
95  if (oldCellCentresPtr_.valid())
96  {
97  // Make a copy of the original cell-centres
98  pointField oldMotionCellCentres = oldCellCentresPtr_();
99 
100  pointField& newMotionCellCentres = oldCellCentresPtr_();
101 
102  // Resize the list to new size
103  newMotionCellCentres.setSize(cellCentres().size());
104 
105  // Map the list
106  newMotionCellCentres.map(oldMotionCellCentres, map.cellMap());
107 
108  // Any points created out-of-nothing get set to the current coordinate
109  // for lack of anything better.
110  forAll(map.cellMap(), newCelli)
111  {
112  if (map.cellMap()[newCelli] == -1)
113  {
114  newMotionCellCentres[newCelli] = cellCentres()[newCelli];
115  }
116  }
117  }
118 
119  meshObject::topoChange<polyMesh>(*this, map);
120  meshObject::topoChange<pointMesh>(*this, map);
121 
122  // Reset valid directions (could change by faces put into empty patches)
123  geometricD_ = Zero;
124  solutionD_ = Zero;
125 }
126 
127 
129 {
130  meshObject::mapMesh<polyMesh>(*this, map);
131  meshObject::mapMesh<pointMesh>(*this, map);
132 }
133 
134 
136 {
137  meshObject::distribute<polyMesh>(*this, map);
138  meshObject::distribute<pointMesh>(*this, map);
139 }
140 
141 
142 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
virtual void distribute(const polyDistributionMap &map)
Redistribute or update using the given distribution map.
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
const labelList & pointMap() const
Old point map.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
label size() const
Return number of elements in table.
Definition: HashTableI.H:65
const labelList & cellMap() const
Old cell map.
void topoChange()
Correct polyBoundaryMesh after topology update.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
word timeName
Definition: getTimeIndex.H:3
static const zero Zero
Definition: zero.H:97
const vectorField & cellCentres() const
void map(const UList< Type > &mapF, const labelUList &mapAddressing)
1 to 1 map from the given field
Definition: Field.C:265
virtual void topoChange(const polyTopoChangeMap &)
Update topology using the given map.
const Time & time() const
Return time.
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
void setInstance(const fileName &)
Set the instance for mesh files.
Definition: polyMeshIO.C:77
void setSize(const label)
Reset size of List.
Definition: List.C:281
label newPointi
Definition: readKivaGrid.H:501
Class containing mesh-to-mesh mapping information.
Definition: polyMeshMap.H:50
void clearAddressing()
Clear addressing.
Definition: MeshZones.C:387
#define InfoInFunction
Report an information message using Foam::Info.