mapPolyMesh.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-2018 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 \*---------------------------------------------------------------------------*/
25 
26 #include "mapPolyMesh.H"
27 #include "polyMesh.H"
28 
29 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
30 
32 (
33  const polyMesh& mesh,
34  const label nOldPoints,
35  const label nOldFaces,
36  const label nOldCells,
37  const labelList& pointMap,
38  const List<objectMap>& pointsFromPoints,
39  const labelList& faceMap,
40  const List<objectMap>& facesFromPoints,
41  const List<objectMap>& facesFromEdges,
42  const List<objectMap>& facesFromFaces,
43  const labelList& cellMap,
44  const List<objectMap>& cellsFromPoints,
45  const List<objectMap>& cellsFromEdges,
46  const List<objectMap>& cellsFromFaces,
47  const List<objectMap>& cellsFromCells,
48  const labelList& reversePointMap,
49  const labelList& reverseFaceMap,
50  const labelList& reverseCellMap,
51  const labelHashSet& flipFaceFlux,
52  const labelListList& patchPointMap,
53  const labelListList& pointZoneMap,
54  const labelListList& faceZonePointMap,
55  const labelListList& faceZoneFaceMap,
56  const labelListList& cellZoneMap,
57  const pointField& preMotionPoints,
58  const labelList& oldPatchStarts,
59  const labelList& oldPatchNMeshPoints,
60  const autoPtr<scalarField>& oldCellVolumesPtr
61 )
62 :
63  mesh_(mesh),
64  nOldPoints_(nOldPoints),
65  nOldFaces_(nOldFaces),
66  nOldCells_(nOldCells),
67  pointMap_(pointMap),
68  pointsFromPointsMap_(pointsFromPoints),
69  faceMap_(faceMap),
70  facesFromPointsMap_(facesFromPoints),
71  facesFromEdgesMap_(facesFromEdges),
72  facesFromFacesMap_(facesFromFaces),
73  cellMap_(cellMap),
74  cellsFromPointsMap_(cellsFromPoints),
75  cellsFromEdgesMap_(cellsFromEdges),
76  cellsFromFacesMap_(cellsFromFaces),
77  cellsFromCellsMap_(cellsFromCells),
78  reversePointMap_(reversePointMap),
79  reverseFaceMap_(reverseFaceMap),
80  reverseCellMap_(reverseCellMap),
81  flipFaceFlux_(flipFaceFlux),
82  patchPointMap_(patchPointMap),
83  pointZoneMap_(pointZoneMap),
84  faceZonePointMap_(faceZonePointMap),
85  faceZoneFaceMap_(faceZoneFaceMap),
86  cellZoneMap_(cellZoneMap),
87  preMotionPoints_(preMotionPoints),
88  oldPatchSizes_(oldPatchStarts.size()),
89  oldPatchStarts_(oldPatchStarts),
90  oldPatchNMeshPoints_(oldPatchNMeshPoints),
91  oldCellVolumesPtr_(oldCellVolumesPtr)
92 {
93  if (oldPatchStarts_.size())
94  {
95  // Calculate old patch sizes
96  for (label patchi = 0; patchi < oldPatchStarts_.size() - 1; patchi++)
97  {
98  oldPatchSizes_[patchi] =
99  oldPatchStarts_[patchi + 1] - oldPatchStarts_[patchi];
100  }
101 
102  // Set the last one by hand
103  const label lastPatchID = oldPatchStarts_.size() - 1;
104 
105  oldPatchSizes_[lastPatchID] = nOldFaces_ - oldPatchStarts_[lastPatchID];
106 
107  if (polyMesh::debug)
108  {
109  if (min(oldPatchSizes_) < 0)
110  {
112  << abort(FatalError);
113  }
114  }
115  }
116 }
117 
118 
120 (
121  const polyMesh& mesh,
122  const label nOldPoints,
123  const label nOldFaces,
124  const label nOldCells,
125  labelList& pointMap,
126  List<objectMap>& pointsFromPoints,
127  labelList& faceMap,
128  List<objectMap>& facesFromPoints,
129  List<objectMap>& facesFromEdges,
130  List<objectMap>& facesFromFaces,
131  labelList& cellMap,
132  List<objectMap>& cellsFromPoints,
133  List<objectMap>& cellsFromEdges,
134  List<objectMap>& cellsFromFaces,
135  List<objectMap>& cellsFromCells,
136  labelList& reversePointMap,
137  labelList& reverseFaceMap,
138  labelList& reverseCellMap,
139  labelHashSet& flipFaceFlux,
140  labelListList& patchPointMap,
141  labelListList& pointZoneMap,
142  labelListList& faceZonePointMap,
143  labelListList& faceZoneFaceMap,
144  labelListList& cellZoneMap,
145  pointField& preMotionPoints,
146  labelList& oldPatchStarts,
147  labelList& oldPatchNMeshPoints,
148  autoPtr<scalarField>& oldCellVolumesPtr,
149  const bool reuse
150 )
151 :
152  mesh_(mesh),
153  nOldPoints_(nOldPoints),
154  nOldFaces_(nOldFaces),
155  nOldCells_(nOldCells),
156  pointMap_(pointMap, reuse),
157  pointsFromPointsMap_(pointsFromPoints, reuse),
158  faceMap_(faceMap, reuse),
159  facesFromPointsMap_(facesFromPoints, reuse),
160  facesFromEdgesMap_(facesFromEdges, reuse),
161  facesFromFacesMap_(facesFromFaces, reuse),
162  cellMap_(cellMap, reuse),
163  cellsFromPointsMap_(cellsFromPoints, reuse),
164  cellsFromEdgesMap_(cellsFromEdges, reuse),
165  cellsFromFacesMap_(cellsFromFaces, reuse),
166  cellsFromCellsMap_(cellsFromCells, reuse),
167  reversePointMap_(reversePointMap, reuse),
168  reverseFaceMap_(reverseFaceMap, reuse),
169  reverseCellMap_(reverseCellMap, reuse),
170  flipFaceFlux_(flipFaceFlux),
171  patchPointMap_(patchPointMap, reuse),
172  pointZoneMap_(pointZoneMap, reuse),
173  faceZonePointMap_(faceZonePointMap, reuse),
174  faceZoneFaceMap_(faceZoneFaceMap, reuse),
175  cellZoneMap_(cellZoneMap, reuse),
176  preMotionPoints_(preMotionPoints, reuse),
177  oldPatchSizes_(oldPatchStarts.size()),
178  oldPatchStarts_(oldPatchStarts, reuse),
179  oldPatchNMeshPoints_(oldPatchNMeshPoints, reuse),
180  oldCellVolumesPtr_(oldCellVolumesPtr, reuse)
181 {
182  if (oldPatchStarts_.size() > 0)
183  {
184  // Calculate old patch sizes
185  for (label patchi = 0; patchi < oldPatchStarts_.size() - 1; patchi++)
186  {
187  oldPatchSizes_[patchi] =
188  oldPatchStarts_[patchi + 1] - oldPatchStarts_[patchi];
189  }
190 
191  // Set the last one by hand
192  const label lastPatchID = oldPatchStarts_.size() - 1;
193 
194  oldPatchSizes_[lastPatchID] = nOldFaces_ - oldPatchStarts_[lastPatchID];
195 
196  if (polyMesh::debug)
197  {
198  if (min(oldPatchSizes_) < 0)
199  {
201  << "Calculated negative old patch size."
202  << " Error in mapping data"
203  << abort(FatalError);
204  }
205  }
206  }
207 }
208 
209 
210 // ************************************************************************* //
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
error FatalError
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:323
mapPolyMesh(const polyMesh &mesh, const label nOldPoints, const label nOldFaces, const label nOldCells, const labelList &pointMap, const List< objectMap > &pointsFromPoints, const labelList &faceMap, const List< objectMap > &facesFromPoints, const List< objectMap > &facesFromEdges, const List< objectMap > &facesFromFaces, const labelList &cellMap, const List< objectMap > &cellsFromPoints, const List< objectMap > &cellsFromEdges, const List< objectMap > &cellsFromFaces, const List< objectMap > &cellsFromCells, const labelList &reversePointMap, const labelList &reverseFaceMap, const labelList &reverseCellMap, const labelHashSet &flipFaceFlux, const labelListList &patchPointMap, const labelListList &pointZoneMap, const labelListList &faceZonePointMap, const labelListList &faceZoneFaceMap, const labelListList &cellZoneMap, const pointField &preMotionPoints, const labelList &oldPatchStarts, const labelList &oldPatchNMeshPoints, const autoPtr< scalarField > &oldCellVolumesPtr)
Construct from components. Copy (except for oldCellVolumes).
Definition: mapPolyMesh.C:32
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
errorManip< error > abort(error &err)
Definition: errorManip.H:131
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
label patchi
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74