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-2019 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 "mapPolyMesh.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_.updateMesh();
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  // Remove the cell tree
59  cellTreePtr_.clear();
60 
61  // Update parallel data
62  if (globalMeshDataPtr_.valid())
63  {
64  globalMeshDataPtr_->updateMesh();
65  }
66 
68 
69  // Map the old motion points if present
70  if (oldPointsPtr_.valid())
71  {
72  // Make a copy of the original points
73  pointField oldMotionPoints = oldPointsPtr_();
74 
75  pointField& newMotionPoints = oldPointsPtr_();
76 
77  // Resize the list to new size
78  newMotionPoints.setSize(points_.size());
79 
80  // Map the list
81  newMotionPoints.map(oldMotionPoints, mpm.pointMap());
82 
83  // Any points created out-of-nothing get set to the current coordinate
84  // for lack of anything better.
85  forAll(mpm.pointMap(), newPointi)
86  {
87  if (mpm.pointMap()[newPointi] == -1)
88  {
89  newMotionPoints[newPointi] = points_[newPointi];
90  }
91  }
92  }
93 
94  if (oldCellCentresPtr_.valid())
95  {
96  // Make a copy of the original cell-centres
97  pointField oldMotionCellCentres = oldCellCentresPtr_();
98 
99  pointField& newMotionCellCentres = oldCellCentresPtr_();
100 
101  // Resize the list to new size
102  newMotionCellCentres.setSize(cellCentres().size());
103 
104  // Map the list
105  newMotionCellCentres.map(oldMotionCellCentres, mpm.cellMap());
106 
107  // Any points created out-of-nothing get set to the current coordinate
108  // for lack of anything better.
109  forAll(mpm.cellMap(), newCelli)
110  {
111  if (mpm.cellMap()[newCelli] == -1)
112  {
113  newMotionCellCentres[newCelli] = cellCentres()[newCelli];
114  }
115  }
116  }
117 
118  meshObject::updateMesh<polyMesh>(*this, mpm);
119  meshObject::updateMesh<pointMesh>(*this, mpm);
120 
121  // Reset valid directions (could change by faces put into empty patches)
122  geometricD_ = Zero;
123  solutionD_ = Zero;
124 
125  const_cast<Time&>(time()).functionObjects().updateMesh(mpm);
126 }
127 
128 
129 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
const labelList & cellMap() const
Old cell map.
Definition: mapPolyMesh.H:424
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
label size() const
Return number of elements in table.
Definition: HashTableI.H:65
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
virtual void updateMesh(const mapPolyMesh &mpm)
Update the mesh corresponding to given map.
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
void updateMesh()
Correct polyBoundaryMesh after topology update.
const Time & time() const
Return time.
const labelList & pointMap() const
Old point map.
Definition: mapPolyMesh.H:385
void setInstance(const fileName &)
Set the instance for mesh files.
Definition: polyMeshIO.C:32
void setSize(const label)
Reset size of List.
Definition: List.C:281
label newPointi
Definition: readKivaGrid.H:501
void clearAddressing()
Clear addressing.
Definition: MeshZones.C:387
#define InfoInFunction
Report an information message using Foam::Info.