1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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.
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
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/>.
24 \*---------------------------------------------------------------------------*/
26 #include "mapPolyMesh.H"
29 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
31 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33 // Construct from components
34 Foam::mapPolyMesh::mapPolyMesh
37 const label nOldPoints,
38 const label nOldFaces,
39 const label nOldCells,
40 const labelList& pointMap,
41 const List<objectMap>& pointsFromPoints,
42 const labelList& faceMap,
43 const List<objectMap>& facesFromPoints,
44 const List<objectMap>& facesFromEdges,
45 const List<objectMap>& facesFromFaces,
46 const labelList& cellMap,
47 const List<objectMap>& cellsFromPoints,
48 const List<objectMap>& cellsFromEdges,
49 const List<objectMap>& cellsFromFaces,
50 const List<objectMap>& cellsFromCells,
51 const labelList& reversePointMap,
52 const labelList& reverseFaceMap,
53 const labelList& reverseCellMap,
54 const labelHashSet& flipFaceFlux,
55 const labelListList& patchPointMap,
56 const labelListList& pointZoneMap,
57 const labelListList& faceZonePointMap,
58 const labelListList& faceZoneFaceMap,
59 const labelListList& cellZoneMap,
60 const pointField& preMotionPoints,
61 const labelList& oldPatchStarts,
62 const labelList& oldPatchNMeshPoints
66 nOldPoints_(nOldPoints),
67 nOldFaces_(nOldFaces),
68 nOldCells_(nOldCells),
70 pointsFromPointsMap_(pointsFromPoints),
72 facesFromPointsMap_(facesFromPoints),
73 facesFromEdgesMap_(facesFromEdges),
74 facesFromFacesMap_(facesFromFaces),
76 cellsFromPointsMap_(cellsFromPoints),
77 cellsFromEdgesMap_(cellsFromEdges),
78 cellsFromFacesMap_(cellsFromFaces),
79 cellsFromCellsMap_(cellsFromCells),
80 reversePointMap_(reversePointMap),
81 reverseFaceMap_(reverseFaceMap),
82 reverseCellMap_(reverseCellMap),
83 flipFaceFlux_(flipFaceFlux),
84 patchPointMap_(patchPointMap),
85 pointZoneMap_(pointZoneMap),
86 faceZonePointMap_(faceZonePointMap),
87 faceZoneFaceMap_(faceZoneFaceMap),
88 cellZoneMap_(cellZoneMap),
89 preMotionPoints_(preMotionPoints),
90 oldPatchSizes_(oldPatchStarts.size()),
91 oldPatchStarts_(oldPatchStarts),
92 oldPatchNMeshPoints_(oldPatchNMeshPoints)
94 // Calculate old patch sizes
95 for (label patchI = 0; patchI < oldPatchStarts_.size() - 1; patchI++)
97 oldPatchSizes_[patchI] =
98 oldPatchStarts_[patchI + 1] - oldPatchStarts_[patchI];
101 // Set the last one by hand
102 const label lastPatchID = oldPatchStarts_.size() - 1;
104 oldPatchSizes_[lastPatchID] = nOldFaces_ - oldPatchStarts_[lastPatchID];
108 if (min(oldPatchSizes_) < 0)
110 FatalErrorIn("mapPolyMesh::mapPolyMesh(...)")
111 << "Calculated negative old patch size. Error in mapping data"
112 << abort(FatalError);
118 // Construct from components and optionally reuse storage
119 Foam::mapPolyMesh::mapPolyMesh
121 const polyMesh& mesh,
122 const label nOldPoints,
123 const label nOldFaces,
124 const label nOldCells,
126 List<objectMap>& pointsFromPoints,
128 List<objectMap>& facesFromPoints,
129 List<objectMap>& facesFromEdges,
130 List<objectMap>& facesFromFaces,
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,
152 nOldPoints_(nOldPoints),
153 nOldFaces_(nOldFaces),
154 nOldCells_(nOldCells),
155 pointMap_(pointMap, reUse),
156 pointsFromPointsMap_(pointsFromPoints, reUse),
157 faceMap_(faceMap, reUse),
158 facesFromPointsMap_(facesFromPoints, reUse),
159 facesFromEdgesMap_(facesFromEdges, reUse),
160 facesFromFacesMap_(facesFromFaces, reUse),
161 cellMap_(cellMap, reUse),
162 cellsFromPointsMap_(cellsFromPoints, reUse),
163 cellsFromEdgesMap_(cellsFromEdges, reUse),
164 cellsFromFacesMap_(cellsFromFaces, reUse),
165 cellsFromCellsMap_(cellsFromCells, reUse),
166 reversePointMap_(reversePointMap, reUse),
167 reverseFaceMap_(reverseFaceMap, reUse),
168 reverseCellMap_(reverseCellMap, reUse),
169 flipFaceFlux_(flipFaceFlux),
170 patchPointMap_(patchPointMap, reUse),
171 pointZoneMap_(pointZoneMap, reUse),
172 faceZonePointMap_(faceZonePointMap, reUse),
173 faceZoneFaceMap_(faceZoneFaceMap, reUse),
174 cellZoneMap_(cellZoneMap, reUse),
175 preMotionPoints_(preMotionPoints, reUse),
176 oldPatchSizes_(oldPatchStarts.size()),
177 oldPatchStarts_(oldPatchStarts, reUse),
178 oldPatchNMeshPoints_(oldPatchNMeshPoints, reUse)
180 // Calculate old patch sizes
181 for (label patchI = 0; patchI < oldPatchStarts_.size() - 1; patchI++)
183 oldPatchSizes_[patchI] =
184 oldPatchStarts_[patchI + 1] - oldPatchStarts_[patchI];
187 // Set the last one by hand
188 const label lastPatchID = oldPatchStarts_.size() - 1;
190 oldPatchSizes_[lastPatchID] = nOldFaces_ - oldPatchStarts_[lastPatchID];
194 if (min(oldPatchSizes_) < 0)
196 FatalErrorIn("mapPolyMesh::mapPolyMesh(...)")
197 << "Calculated negative old patch size. Error in mapping data"
198 << abort(FatalError);
204 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
207 // ************************************************************************* //