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-2013 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  {
109  FatalErrorIn("mapPolyMesh::mapPolyMesh(...)")
110  << "Calculated negative old patch size. Error in mapping data"
111  << abort(FatalError);
112  }
113  }
114 }
115 
116 
117 Foam::mapPolyMesh::mapPolyMesh
118 (
119  const polyMesh& mesh,
120  const label nOldPoints,
121  const label nOldFaces,
122  const label nOldCells,
123  labelList& pointMap,
124  List<objectMap>& pointsFromPoints,
125  labelList& faceMap,
126  List<objectMap>& facesFromPoints,
127  List<objectMap>& facesFromEdges,
128  List<objectMap>& facesFromFaces,
129  labelList& cellMap,
130  List<objectMap>& cellsFromPoints,
131  List<objectMap>& cellsFromEdges,
132  List<objectMap>& cellsFromFaces,
133  List<objectMap>& cellsFromCells,
134  labelList& reversePointMap,
135  labelList& reverseFaceMap,
136  labelList& reverseCellMap,
137  labelHashSet& flipFaceFlux,
138  labelListList& patchPointMap,
139  labelListList& pointZoneMap,
140  labelListList& faceZonePointMap,
141  labelListList& faceZoneFaceMap,
142  labelListList& cellZoneMap,
143  pointField& preMotionPoints,
144  labelList& oldPatchStarts,
145  labelList& oldPatchNMeshPoints,
146  autoPtr<scalarField>& oldCellVolumesPtr,
147  const bool reUse
148 )
149 :
150  mesh_(mesh),
151  nOldPoints_(nOldPoints),
152  nOldFaces_(nOldFaces),
153  nOldCells_(nOldCells),
154  pointMap_(pointMap, reUse),
155  pointsFromPointsMap_(pointsFromPoints, reUse),
156  faceMap_(faceMap, reUse),
157  facesFromPointsMap_(facesFromPoints, reUse),
158  facesFromEdgesMap_(facesFromEdges, reUse),
159  facesFromFacesMap_(facesFromFaces, reUse),
160  cellMap_(cellMap, reUse),
161  cellsFromPointsMap_(cellsFromPoints, reUse),
162  cellsFromEdgesMap_(cellsFromEdges, reUse),
163  cellsFromFacesMap_(cellsFromFaces, reUse),
164  cellsFromCellsMap_(cellsFromCells, reUse),
165  reversePointMap_(reversePointMap, reUse),
166  reverseFaceMap_(reverseFaceMap, reUse),
167  reverseCellMap_(reverseCellMap, reUse),
168  flipFaceFlux_(flipFaceFlux),
169  patchPointMap_(patchPointMap, reUse),
170  pointZoneMap_(pointZoneMap, reUse),
171  faceZonePointMap_(faceZonePointMap, reUse),
172  faceZoneFaceMap_(faceZoneFaceMap, reUse),
173  cellZoneMap_(cellZoneMap, reUse),
174  preMotionPoints_(preMotionPoints, reUse),
175  oldPatchSizes_(oldPatchStarts.size()),
176  oldPatchStarts_(oldPatchStarts, reUse),
177  oldPatchNMeshPoints_(oldPatchNMeshPoints, reUse),
178  oldCellVolumesPtr_(oldCellVolumesPtr, reUse)
179 {
180  if (oldPatchStarts_.size() > 0)
181  {
182  // Calculate old patch sizes
183  for (label patchI = 0; patchI < oldPatchStarts_.size() - 1; patchI++)
184  {
185  oldPatchSizes_[patchI] =
186  oldPatchStarts_[patchI + 1] - oldPatchStarts_[patchI];
187  }
188 
189  // Set the last one by hand
190  const label lastPatchID = oldPatchStarts_.size() - 1;
191 
192  oldPatchSizes_[lastPatchID] = nOldFaces_ - oldPatchStarts_[lastPatchID];
193 
194  if (polyMesh::debug)
195  {
196  if (min(oldPatchSizes_) < 0)
197  {
198  FatalErrorIn("mapPolyMesh::mapPolyMesh(...)")
199  << "Calculated negative old patch size."
200  << " Error in mapping data"
201  << abort(FatalError);
202  }
203  }
204  }
205 }
206 
207 
208 // ************************************************************************* //
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
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:76
errorManip< error > abort(error &err)
Definition: errorManip.H:131
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Definition: error.H:314
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
error FatalError
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117