polyMeshUpdate.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Description
27  Update the polyMesh corresponding to the given map.
28 
29 \*---------------------------------------------------------------------------*/
30 
31 #include "polyMesh.H"
32 #include "mapPolyMesh.H"
33 #include "Time.H"
34 #include "globalMeshData.H"
35 #include "pointMesh.H"
36 #include "indexedOctree.H"
37 #include "treeDataCell.H"
38 
39 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
40 
42 {
43  if (debug)
44  {
46  << "Updating addressing and (optional) pointMesh/pointFields"
47  << endl;
48  }
49 
50  // Update boundaryMesh (note that patches themselves already ok)
51  boundary_.updateMesh();
52 
53  // Update zones
54  pointZones_.clearAddressing();
55  faceZones_.clearAddressing();
56  cellZones_.clearAddressing();
57 
58  // Remove the stored tet base points
59  tetBasePtIsPtr_.clear();
60  // Remove the cell tree
61  cellTreePtr_.clear();
62 
63  // Update parallel data
64  if (globalMeshDataPtr_.valid())
65  {
66  globalMeshDataPtr_->updateMesh();
67  }
68 
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  if (mpm.hasMotionPoints())
84  {
85  newMotionPoints.map(oldMotionPoints, mpm.pointMap());
86 
87  // Any points created out-of-nothing get set to the current
88  // coordinate for lack of anything better.
89  forAll(mpm.pointMap(), newPointi)
90  {
91  if (mpm.pointMap()[newPointi] == -1)
92  {
93  newMotionPoints[newPointi] = points_[newPointi];
94  }
95  }
96  }
97  else
98  {
99  const labelList& pointMap = mpm.pointMap();
100  const labelList& revPointMap = mpm.reversePointMap();
101 
102  forAll(pointMap, newPointi)
103  {
104  label oldPointi = pointMap[newPointi];
105  if (oldPointi >= 0)
106  {
107  if (revPointMap[oldPointi] == newPointi) // master point
108  {
109  newMotionPoints[newPointi] = oldMotionPoints[oldPointi];
110  }
111  else
112  {
113  newMotionPoints[newPointi] = points_[newPointi];
114  }
115  }
116  else
117  {
118  newMotionPoints[newPointi] = points_[newPointi];
119  }
120  }
121  }
122  }
123 
124  meshObject::updateMesh<polyMesh>(*this, mpm);
125  meshObject::updateMesh<pointMesh>(*this, mpm);
126 
127  // Reset valid directions (could change by faces put into empty patches)
128  geometricD_ = Zero;
129  solutionD_ = Zero;
130 
131  const_cast<Time&>(time()).functionObjects().updateMesh(mpm);
132 }
133 
134 
135 // ************************************************************************* //
Foam::expressions::patchExpr::debug
int debug
Static debugging option.
InfoInFunction
#define InfoInFunction
Report an information message using Foam::Info.
Definition: messageStream.H:316
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:73
Foam::Zero
static constexpr const zero Zero
Global zero.
Definition: zero.H:128
globalMeshData.H
mapPolyMesh.H
Foam::objectRegistry::time
const Time & time() const
Return time.
Definition: objectRegistry.H:186
indexedOctree.H
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:337
polyMesh.H
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:290
Foam::Field::map
void map(const UList< Type > &mapF, const labelUList &mapAddressing)
1 to 1 map from the given field
Definition: Field.C:263
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:62
Foam::Field< vector >
Foam::polyMesh::updateMesh
virtual void updateMesh(const mapPolyMesh &mpm)
Update the mesh corresponding to given map.
Definition: polyMeshUpdate.C:41
timeName
word timeName
Definition: getTimeIndex.H:3
newPointi
label newPointi
Definition: readKivaGrid.H:496
treeDataCell.H
Foam::polyBoundaryMesh::updateMesh
void updateMesh()
Correct polyBoundaryMesh after topology update.
Definition: polyBoundaryMesh.C:1141
Time.H
Foam::mapPolyMesh::reversePointMap
const labelList & reversePointMap() const
Reverse point map.
Definition: mapPolyMesh.H:468
Foam::List< label >
Foam::mapPolyMesh::pointMap
const labelList & pointMap() const
Old point map.
Definition: mapPolyMesh.H:395
Foam::mapPolyMesh
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:160
Foam::mapPolyMesh::hasMotionPoints
bool hasMotionPoints() const
Has valid preMotionPoints?
Definition: mapPolyMesh.H:618
Foam::ZoneMesh::clearAddressing
void clearAddressing()
Clear addressing.
Definition: ZoneMesh.C:621
pointMesh.H
Foam::polyMesh::setInstance
void setInstance(const fileName &instance, const IOobject::writeOption wOpt=IOobject::AUTO_WRITE)
Set the instance for mesh files.
Definition: polyMeshIO.C:35