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 | Copyright (C) 2011-2014 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  {
43  Info<< "void polyMesh::updateMesh(const mapPolyMesh&) : "
44  << "updating addressing and (optional) pointMesh/pointFields"
45  << endl;
46  }
47 
48  // Update boundaryMesh (note that patches themselves already ok)
50 
51  // Update zones
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  if (mpm.hasMotionPoints())
82  {
83  newMotionPoints.map(oldMotionPoints, mpm.pointMap());
84 
85  // Any points created out-of-nothing get set to the current
86  // coordinate for lack of anything better.
87  forAll(mpm.pointMap(), newPointI)
88  {
89  if (mpm.pointMap()[newPointI] == -1)
90  {
91  newMotionPoints[newPointI] = points_[newPointI];
92  }
93  }
94  }
95  else
96  {
97  const labelList& pointMap = mpm.pointMap();
98  const labelList& revPointMap = mpm.reversePointMap();
99 
100  forAll(pointMap, newPointI)
101  {
102  label oldPointI = pointMap[newPointI];
103  if (oldPointI >= 0)
104  {
105  if (revPointMap[oldPointI] == newPointI) // master point
106  {
107  newMotionPoints[newPointI] = oldMotionPoints[oldPointI];
108  }
109  else
110  {
111  newMotionPoints[newPointI] = points_[newPointI];
112  }
113  }
114  else
115  {
116  newMotionPoints[newPointI] = points_[newPointI];
117  }
118  }
119  }
120  }
121 
122  meshObject::updateMesh<polyMesh>(*this, mpm);
123  meshObject::updateMesh<pointMesh>(*this, mpm);
124 
125  // Reset valid directions (could change by faces put into empty patches)
128 
129  const_cast<Time&>(time()).functionObjects().updateMesh(mpm);
130 }
131 
132 
133 // ************************************************************************* //
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
globalMeshData.H
mapPolyMesh.H
Foam::objectRegistry::time
const Time & time() const
Return time.
Definition: objectRegistry.H:117
Foam::polyMesh::faceZones_
faceZoneMesh faceZones_
Face zones.
Definition: polyMesh.H:164
indexedOctree.H
Foam::polyMesh::cellTreePtr_
autoPtr< indexedOctree< treeDataCell > > cellTreePtr_
Search tree to allow spatial cell searching.
Definition: polyMesh.H:155
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::polyMesh::geometricD_
Vector< label > geometricD_
Vector of non-constrained directions in mesh.
Definition: polyMesh.H:145
polyMesh.H
Foam::polyMesh::globalMeshDataPtr_
autoPtr< globalMeshData > globalMeshDataPtr_
Parallel info.
Definition: polyMesh.H:171
Foam::Field::map
void map(const UList< Type > &mapF, const labelUList &mapAddressing)
1 to 1 map from the given field
Definition: Field.C:345
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:59
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::Info
messageStream Info
Foam::polyMesh::updateMesh
virtual void updateMesh(const mapPolyMesh &mpm)
Update the mesh corresponding to given map.
Definition: polyMeshUpdate.C:39
Foam::polyMesh::boundary_
polyBoundaryMesh boundary_
Boundary mesh.
Definition: polyMesh.H:134
Foam::polyMesh::pointZones_
pointZoneMesh pointZones_
Point zones.
Definition: polyMesh.H:161
Foam::polyMesh::points_
pointIOField points_
Points.
Definition: polyMesh.H:118
treeDataCell.H
Foam::polyMesh::oldPointsPtr_
autoPtr< pointField > oldPointsPtr_
Old points (for the last mesh motion)
Definition: polyMesh.H:186
Foam::polyBoundaryMesh::updateMesh
void updateMesh()
Correct polyBoundaryMesh after topology update.
Definition: polyBoundaryMesh.C:1049
Foam::polyMesh::setInstance
void setInstance(const fileName &)
Set the instance for mesh files.
Definition: polyMeshIO.C:32
Foam::polyMesh::tetBasePtIsPtr_
autoPtr< labelList > tetBasePtIsPtr_
Base point for face decomposition into tets.
Definition: polyMesh.H:152
Foam::mapPolyMesh::reversePointMap
const labelList & reversePointMap() const
Reverse point map.
Definition: mapPolyMesh.H:465
Foam::Vector
Templated 3D Vector derived from VectorSpace adding construction from 3 components,...
Definition: Vector.H:57
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::mapPolyMesh::pointMap
const labelList & pointMap() const
Old point map.
Definition: mapPolyMesh.H:392
timeName
word timeName
Definition: getTimeIndex.H:3
Foam::mapPolyMesh
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
Foam::mapPolyMesh::hasMotionPoints
bool hasMotionPoints() const
Has valid preMotionPoints?
Definition: mapPolyMesh.H:615
Foam::polyMesh::solutionD_
Vector< label > solutionD_
Vector of valid directions in mesh.
Definition: polyMesh.H:149
Foam::polyMesh::cellZones_
cellZoneMesh cellZones_
Cell zones.
Definition: polyMesh.H:167
Foam::ZoneMesh::clearAddressing
void clearAddressing()
Clear addressing.
Definition: ZoneMesh.C:394
pointMesh.H