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/>.
28 Class containing mesh-to-mesh mapping information after a change
32 - pointMap/faceMap/cellMap: \n
33 from current mesh back to previous mesh.
34 (so to 'pull' the information onto the current mesh)
35 - reversePointMap/faceMap/cellMap: \n
36 from previous mesh to current. (so to 'push' information)
38 In the topology change points/faces/cells
39 - can be unchanged. (faces might be renumbered though)
40 - can be removed (into nothing)
41 - can be removed into/merged with existing same entity
42 (so point merged with other point, face with other face, cell with
43 other cell. Note that probably only cell with cell is relevant)
44 - can be added from existing same 'master' entity
45 (so point from point, face from face and cell from cell)
46 - can be inflated: face out of edge or point,
47 cell out of face, edge or point.
48 - can be appended: added 'out of nothing'.
50 All this information is nessecary to correctly map fields.
55 - pointMap[pointI] contains old point label
56 - reversePointMap[oldPointI] contains new point label
58 - reversePointMap[oldPointI] contains -1
60 - reversePointMap[oldPointI] contains <-1 : -newPointI-2
61 - pointMap[pointI] contains the old master point label
62 - pointsFromPoints gives for pointI all the old point labels
63 (including the old master point!)
65 - pointMap[pointI] contains the old master point label
67 - pointMap[pointI] contains -1
72 - faceMap[faceI] contains old face label
73 - reverseFaceMap[oldFaceI] contains new face label
75 - reverseFaceMap[oldFaceI] contains -1
77 - reverseFaceMap[oldFaceI] contains <-1 : -newFaceI-2
78 - faceMap[faceI] contains the old master face label
79 - facesFromFaces gives for faceI all the old face labels
80 (including the old master face!)
82 - faceMap[faceI] contains the old master face label
84 - faceMap[faceI] contains -1
85 - facesFromEdges contains an entry with
87 - list of faces(*) on old mesh that connected to the old edge
88 - inflated-from-point:
89 - faceMap[faceI] contains -1
90 - facesFromPoints contains an entry with
92 - list of faces(*) on old mesh that connected to the old point
94 - faceMap[faceI] contains -1
97 if the newly inflated face is a boundary face the list of faces will
98 only be boundary faces; if the new face is an internal face they
99 will only be internal faces.
104 - cellMap[cellI] contains old cell label
105 - reverseCellMap[oldCellI] contains new cell label
107 - reverseCellMap[oldCellI] contains -1
109 - reverseCellMap[oldCellI] contains <-1 : -newCellI-2
110 - cellMap[cellI] contains the old master cell label
111 - cellsFromCells gives for cellI all the old cell labels
112 (including the old master cell!)
114 - cellMap[cellI] contains the old master cell label
115 - inflated-from-face:
116 - cellMap[cellI] contains -1
117 - cellsFromFaces contains an entry with
119 - list of cells on old mesh that connected to the old face
120 - inflated-from-edge:
121 - cellMap[cellI] contains -1
122 - cellsFromEdges contains an entry with
124 - list of cells on old mesh that connected to the old edge
125 - inflated-from-point:
126 - cellMap[cellI] contains -1
127 - cellsFromPoints contains an entry with
129 - list of cells on old mesh that connected to the old point
131 - cellMap[cellI] contains -1
137 \*---------------------------------------------------------------------------*/
139 #ifndef mapPolyMesh_H
140 #define mapPolyMesh_H
142 #include "labelList.H"
143 #include "objectMap.H"
144 #include "pointField.H"
148 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
155 /*---------------------------------------------------------------------------*\
156 Class mapPolyMesh Declaration
157 \*---------------------------------------------------------------------------*/
165 //- Reference to polyMesh
166 const polyMesh& mesh_;
168 //- Number of old live points
169 const label nOldPoints_;
171 //- Number of old live faces
172 const label nOldFaces_;
174 //- Number of old live cells
175 const label nOldCells_;
178 // Contains the old point label for all new points.
179 // - for preserved points this is the old point label.
180 // - for added points this is the master point ID
181 // - for points added with no master, this is -1
182 // Size of the list equals the size of new points
183 const labelList pointMap_;
185 //- Points resulting from merging points
186 const List<objectMap> pointsFromPointsMap_;
189 // Contains a list of old face labels for every new face.
190 // Size of the list equals the number of new faces
191 // - for preserved faces this is the old face label.
192 // - for faces added from faces this is the master face ID
193 // - for faces added with no master, this is -1
194 // - for faces added from points or edges, this is -1
195 const labelList faceMap_;
197 //- Faces inflated from points
198 const List<objectMap> facesFromPointsMap_;
200 //- Faces inflated from edges
201 const List<objectMap> facesFromEdgesMap_;
203 //- Faces resulting from merging faces
204 const List<objectMap> facesFromFacesMap_;
207 // Contains old cell label for all preserved cells.
208 // Size of the list equals the number or preserved cells
209 const labelList cellMap_;
211 //- Cells inflated from points
212 const List<objectMap> cellsFromPointsMap_;
214 //- Cells inflated from edges
215 const List<objectMap> cellsFromEdgesMap_;
217 //- Cells inflated from faces
218 const List<objectMap> cellsFromFacesMap_;
220 //- Cells resulting from merging cells
221 const List<objectMap> cellsFromCellsMap_;
223 //- Reverse point map
224 const labelList reversePointMap_;
227 const labelList reverseFaceMap_;
230 const labelList reverseCellMap_;
232 //- Map of flipped face flux faces
233 const labelHashSet flipFaceFlux_;
235 //- Patch mesh point renumbering
236 const labelListList patchPointMap_;
238 //- Point zone renumbering
239 // For every preserved point in zone give the old position.
240 // For added points, the index is set to -1
241 const labelListList pointZoneMap_;
243 //- Face zone point renumbering
244 // For every preserved point in zone give the old position.
245 // For added points, the index is set to -1
246 const labelListList faceZonePointMap_;
248 //- Face zone face renumbering
249 // For every preserved face in zone give the old position.
250 // For added faces, the index is set to -1
251 const labelListList faceZoneFaceMap_;
253 //- Cell zone renumbering
254 // For every preserved cell in zone give the old position.
255 // For added cells, the index is set to -1
256 const labelListList cellZoneMap_;
258 //- Pre-motion point positions.
259 // This specifies the correct way of blowing up zero-volume objects
260 const pointField preMotionPoints_;
262 //- List of the old patch sizes
263 labelList oldPatchSizes_;
265 //- List of the old patch start labels
266 const labelList oldPatchStarts_;
268 //- List of numbers of mesh points per old patch
269 const labelList oldPatchNMeshPoints_;
272 // Private Member Functions
274 //- Disallow default bitwise copy construct
275 mapPolyMesh(const mapPolyMesh&);
277 //- Disallow default bitwise assignment
278 void operator=(const mapPolyMesh&);
285 //- Construct from components
288 const polyMesh& mesh,
289 const label nOldPoints,
290 const label nOldFaces,
291 const label nOldCells,
292 const labelList& pointMap,
293 const List<objectMap>& pointsFromPoints,
294 const labelList& faceMap,
295 const List<objectMap>& facesFromPoints,
296 const List<objectMap>& facesFromEdges,
297 const List<objectMap>& facesFromFaces,
298 const labelList& cellMap,
299 const List<objectMap>& cellsFromPoints,
300 const List<objectMap>& cellsFromEdges,
301 const List<objectMap>& cellsFromFaces,
302 const List<objectMap>& cellsFromCells,
303 const labelList& reversePointMap,
304 const labelList& reverseFaceMap,
305 const labelList& reverseCellMap,
306 const labelHashSet& flipFaceFlux,
307 const labelListList& patchPointMap,
308 const labelListList& pointZoneMap,
309 const labelListList& faceZonePointMap,
310 const labelListList& faceZoneFaceMap,
311 const labelListList& cellZoneMap,
312 const pointField& preMotionPoints,
313 const labelList& oldPatchStarts,
314 const labelList& oldPatchNMeshPoints
317 //- Construct from components and optionally reuse storage
320 const polyMesh& mesh,
321 const label nOldPoints,
322 const label nOldFaces,
323 const label nOldCells,
325 List<objectMap>& pointsFromPoints,
327 List<objectMap>& facesFromPoints,
328 List<objectMap>& facesFromEdges,
329 List<objectMap>& facesFromFaces,
331 List<objectMap>& cellsFromPoints,
332 List<objectMap>& cellsFromEdges,
333 List<objectMap>& cellsFromFaces,
334 List<objectMap>& cellsFromCells,
335 labelList& reversePointMap,
336 labelList& reverseFaceMap,
337 labelList& reverseCellMap,
338 labelHashSet& flipFaceFlux,
339 labelListList& patchPointMap,
340 labelListList& pointZoneMap,
341 labelListList& faceZonePointMap,
342 labelListList& faceZoneFaceMap,
343 labelListList& cellZoneMap,
344 pointField& preMotionPoints,
345 labelList& oldPatchStarts,
346 labelList& oldPatchNMeshPoints,
355 const polyMesh& mesh() const
360 //- Number of old points
361 label nOldPoints() const
366 //- Number of old internal faces
367 label nOldInternalFaces() const
369 return oldPatchStarts_[0];
372 //- Number of old faces
373 label nOldFaces() const
378 //- Number of old cells
379 label nOldCells() const
385 // Contains the old point label for all new points.
386 // For preserved points this is the old point label.
387 // For added points this is the master point ID
388 const labelList& pointMap() const
393 //- Points originating from points
394 const List<objectMap>& pointsFromPointsMap() const
396 return pointsFromPointsMap_;
400 // Contains a list of old face labels for every new face.
401 // Warning: this map contains invalid entries for new faces
402 const labelList& faceMap() const
407 //- Faces inflated from points
408 const List<objectMap>& facesFromPointsMap() const
410 return facesFromPointsMap_;
413 //- Faces inflated from edges
414 const List<objectMap>& facesFromEdgesMap() const
416 return facesFromEdgesMap_;
419 //- Faces originating from faces
420 const List<objectMap>& facesFromFacesMap() const
422 return facesFromFacesMap_;
426 // Contains old cell label for all preserved cells.
427 const labelList& cellMap() const
432 //- Cells inflated from points
433 const List<objectMap>& cellsFromPointsMap() const
435 return cellsFromPointsMap_;
438 //- Cells inflated from edges
439 const List<objectMap>& cellsFromEdgesMap() const
441 return cellsFromEdgesMap_;
444 //- Cells inflated from faces
445 const List<objectMap>& cellsFromFacesMap() const
447 return cellsFromFacesMap_;
450 //- Cells originating from cells
451 const List<objectMap>& cellsFromCellsMap() const
453 return cellsFromCellsMap_;
459 //- Reverse point map
460 // Contains new point label for all old and added points
461 const labelList& reversePointMap() const
463 return reversePointMap_;
466 //- If point is removed return point (on new mesh) it merged
468 label mergedPoint(const label oldPointI) const
470 label i = reversePointMap_[oldPointI];
482 FatalErrorIn("mergedPoint(const label) const")
483 << "old point label " << oldPointI
484 << " has reverseMap " << i << endl
485 << "Only call mergedPoint for removed points."
486 << abort(FatalError);
492 // Contains new face label for all old and added faces
493 const labelList& reverseFaceMap() const
495 return reverseFaceMap_;
498 //- If face is removed return face (on new mesh) it merged into
499 label mergedFace(const label oldFaceI) const
501 label i = reverseFaceMap_[oldFaceI];
513 FatalErrorIn("mergedFace(const label) const")
514 << "old face label " << oldFaceI
515 << " has reverseMap " << i << endl
516 << "Only call mergedFace for removed faces."
517 << abort(FatalError);
523 // Contains new cell label for all old and added cells
524 const labelList& reverseCellMap() const
526 return reverseCellMap_;
529 //- If cell is removed return cell (on new mesh) it merged into
530 label mergedCell(const label oldCellI) const
532 label i = reverseCellMap_[oldCellI];
544 FatalErrorIn("mergedCell(const label) const")
545 << "old cell label " << oldCellI
546 << " has reverseMap " << i << endl
547 << "Only call mergedCell for removed cells."
548 << abort(FatalError);
553 //- Map of flipped face flux faces
554 const labelHashSet& flipFaceFlux() const
556 return flipFaceFlux_;
559 //- Patch point renumbering
560 // For every preserved point on a patch give the old position.
561 // For added points, the index is set to -1
562 const labelListList& patchPointMap() const
564 return patchPointMap_;
570 //- Point zone renumbering
571 // For every preserved point in zone give the old position.
572 // For added points, the index is set to -1
573 const labelListList& pointZoneMap() const
575 return pointZoneMap_;
578 //- Face zone point renumbering
579 // For every preserved point in zone give the old position.
580 // For added points, the index is set to -1
581 const labelListList& faceZonePointMap() const
583 return faceZonePointMap_;
586 //- Face zone face renumbering
587 // For every preserved face in zone give the old position.
588 // For added faces, the index is set to -1
589 const labelListList& faceZoneFaceMap() const
591 return faceZoneFaceMap_;
594 //- Cell zone renumbering
595 // For every preserved cell in zone give the old position.
596 // For added cells, the index is set to -1
597 const labelListList& cellZoneMap() const
602 //- Pre-motion point positions.
603 // This specifies the correct way of blowing up
604 // zero-volume objects
605 const pointField& preMotionPoints() const
607 return preMotionPoints_;
610 //- Has valid preMotionPoints?
611 bool hasMotionPoints() const
613 return preMotionPoints_.size() > 0;
617 //- Return list of the old patch sizes
618 const labelList& oldPatchSizes() const
620 return oldPatchSizes_;
623 //- Return list of the old patch start labels
624 const labelList& oldPatchStarts() const
626 return oldPatchStarts_;
629 //- Return numbers of mesh points per old patch
630 const labelList& oldPatchNMeshPoints() const
632 return oldPatchNMeshPoints_;
637 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
639 } // End namespace Foam
641 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
645 // ************************************************************************* //