mapPolyMesh.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-2016 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 
31 Foam::mapPolyMesh::mapPolyMesh
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  // Calculate old patch sizes
94  for (label patchi = 0; patchi < oldPatchStarts_.size() - 1; patchi++)
95  {
96  oldPatchSizes_[patchi] =
97  oldPatchStarts_[patchi + 1] - oldPatchStarts_[patchi];
98  }
99 
100  // Set the last one by hand
101  const label lastPatchID = oldPatchStarts_.size() - 1;
102 
103  oldPatchSizes_[lastPatchID] = nOldFaces_ - oldPatchStarts_[lastPatchID];
104 
105  if (polyMesh::debug)
106  {
107  if (min(oldPatchSizes_) < 0)
108  {
110  << abort(FatalError);
111  }
112  }
113 }
114 
115 
116 Foam::mapPolyMesh::mapPolyMesh
117 (
118  const polyMesh& mesh,
119  const label nOldPoints,
120  const label nOldFaces,
121  const label nOldCells,
122  labelList& pointMap,
123  List<objectMap>& pointsFromPoints,
124  labelList& faceMap,
125  List<objectMap>& facesFromPoints,
126  List<objectMap>& facesFromEdges,
127  List<objectMap>& facesFromFaces,
128  labelList& cellMap,
129  List<objectMap>& cellsFromPoints,
130  List<objectMap>& cellsFromEdges,
131  List<objectMap>& cellsFromFaces,
132  List<objectMap>& cellsFromCells,
133  labelList& reversePointMap,
134  labelList& reverseFaceMap,
135  labelList& reverseCellMap,
136  labelHashSet& flipFaceFlux,
137  labelListList& patchPointMap,
138  labelListList& pointZoneMap,
139  labelListList& faceZonePointMap,
140  labelListList& faceZoneFaceMap,
141  labelListList& cellZoneMap,
142  pointField& preMotionPoints,
143  labelList& oldPatchStarts,
144  labelList& oldPatchNMeshPoints,
145  autoPtr<scalarField>& oldCellVolumesPtr,
146  const bool reuse
147 )
148 :
149  mesh_(mesh),
150  nOldPoints_(nOldPoints),
151  nOldFaces_(nOldFaces),
152  nOldCells_(nOldCells),
153  pointMap_(pointMap, reuse),
154  pointsFromPointsMap_(pointsFromPoints, reuse),
155  faceMap_(faceMap, reuse),
156  facesFromPointsMap_(facesFromPoints, reuse),
157  facesFromEdgesMap_(facesFromEdges, reuse),
158  facesFromFacesMap_(facesFromFaces, reuse),
159  cellMap_(cellMap, reuse),
160  cellsFromPointsMap_(cellsFromPoints, reuse),
161  cellsFromEdgesMap_(cellsFromEdges, reuse),
162  cellsFromFacesMap_(cellsFromFaces, reuse),
163  cellsFromCellsMap_(cellsFromCells, reuse),
164  reversePointMap_(reversePointMap, reuse),
165  reverseFaceMap_(reverseFaceMap, reuse),
166  reverseCellMap_(reverseCellMap, reuse),
167  flipFaceFlux_(flipFaceFlux),
168  patchPointMap_(patchPointMap, reuse),
169  pointZoneMap_(pointZoneMap, reuse),
170  faceZonePointMap_(faceZonePointMap, reuse),
171  faceZoneFaceMap_(faceZoneFaceMap, reuse),
172  cellZoneMap_(cellZoneMap, reuse),
173  preMotionPoints_(preMotionPoints, reuse),
174  oldPatchSizes_(oldPatchStarts.size()),
175  oldPatchStarts_(oldPatchStarts, reuse),
176  oldPatchNMeshPoints_(oldPatchNMeshPoints, reuse),
177  oldCellVolumesPtr_(oldCellVolumesPtr, reuse)
178 {
179  if (oldPatchStarts_.size() > 0)
180  {
181  // Calculate old patch sizes
182  for (label patchi = 0; patchi < oldPatchStarts_.size() - 1; patchi++)
183  {
184  oldPatchSizes_[patchi] =
185  oldPatchStarts_[patchi + 1] - oldPatchStarts_[patchi];
186  }
187 
188  // Set the last one by hand
189  const label lastPatchID = oldPatchStarts_.size() - 1;
190 
191  oldPatchSizes_[lastPatchID] = nOldFaces_ - oldPatchStarts_[lastPatchID];
192 
193  if (polyMesh::debug)
194  {
195  if (min(oldPatchSizes_) < 0)
196  {
198  << "Calculated negative old patch size."
199  << " Error in mapping data"
200  << abort(FatalError);
201  }
202  }
203  }
204 }
205 
206 
207 // ************************************************************************* //
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:319
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:163
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