OpenFOAM logo
The Open Source CFD Toolbox
  Programmer’s C++ Doxygen OpenCFD Solutions Contact OpenFOAM

mapPolyMesh.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2007 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Class
00026     mapPolyMesh
00027 
00028 Description
00029     Class containing mesh-to-mesh mapping information after a change
00030     in polyMesh topology.
00031     General: 
00032         - pointMap/faceMap/cellMap:
00033         from current mesh back to previous mesh.
00034         (so to 'pull' the information onto the current mesh)
00035 
00036         - reversePointMap/faceMap/cellMap:
00037         from previous mesh to current. (so to 'push' information)
00038 
00039     In the topology change points/faces/cells
00040     - can be unchanged. (faces might be renumbered though)
00041     - can be removed (into nothing)
00042     - can be removed into/merged with existing same entity
00043       (so point merged with other point, face with other face, cell with
00044        other cell. Note that probably only cell with cell is relevant)
00045     - can be added from existing same 'master' entity 
00046       (so point from point, face from face and cell from cell)
00047     - can be inflated: face out of edge or point,
00048         cell out of face, edge or point.
00049     - can be appended: added 'out of nothing'.
00050 
00051     All this information is nessecary to correctly map fields.
00052 
00053     points
00054     ------
00055     unchanged:
00056         pointMap[pointI] contains old point label
00057         reversePointMap[oldPointI] contains new point label
00058     removed:
00059         reversePointMap[oldPointI] contains -1
00060     merged into point:
00061         - reversePointMap[oldPointI] contains <-1 : -newPointI-2
00062         - pointMap[pointI] contains the old master point label
00063         - pointsFromPoints gives for pointI all the old point labels
00064           (including the old master point!)
00065     added-from-same:
00066         pointMap[pointI] contains the old master point label 
00067     appended:
00068         pointMap[pointI] contains -1
00069 
00070 
00071     faces
00072     -----
00073     unchanged:
00074         faceMap[faceI] contains old face label
00075         reverseFaceMap[oldFaceI] contains new face label
00076     removed:
00077         reverseFaceMap[oldFaceI] contains -1
00078     merged into face:
00079         - reverseFaceMap[oldFaceI] contains <-1 : -newFaceI-2
00080         - faceMap[faceI] contains the old master face label
00081         - facesFromFaces gives for faceI all the old face labels
00082           (including the old master face!)
00083     added-from-same:
00084         faceMap[faceI] contains the old master face label 
00085     inflated-from-edge:
00086         faceMap[faceI] contains -1
00087         facesFromEdges contains an entry with
00088             - faceI
00089             - list of faces(*) on old mesh that connected to the old edge
00090     inflated-from-point:
00091         faceMap[faceI] contains -1
00092         facesFromPoints contains an entry with
00093             - faceI
00094             - list of faces(*) on old mesh that connected to the old point
00095     appended:
00096         faceMap[faceI] contains -1
00097 
00098     *) if the newly inflated face is a boundary face the list of faces will
00099        only be boundary faces; if the new face is an internal face they
00100        will only be internal faces.
00101 
00102 
00103     cells
00104     -----
00105     unchanged:
00106         cellMap[cellI] contains old cell label
00107         reverseCellMap[oldCellI] contains new cell label
00108     removed:
00109         reverseCellMap[oldCellI] contains -1
00110     merged into cell:
00111         - reverseCellMap[oldCellI] contains <-1 : -newCellI-2
00112         - cellMap[cellI] contains the old master cell label 
00113         - cellsFromCells gives for cellI all the old cell labels
00114           (including the old master cell!)
00115     added-from-same:
00116         cellMap[cellI] contains the old master cell label 
00117     inflated-from-face:
00118         cellMap[cellI] contains -1
00119         cellsFromFaces contains an entry with
00120             - cellI
00121             - list of cells on old mesh that connected to the old face
00122     inflated-from-edge:
00123         cellMap[cellI] contains -1
00124         cellsFromEdges contains an entry with
00125             - cellI
00126             - list of cells on old mesh that connected to the old edge
00127     inflated-from-point:
00128         cellMap[cellI] contains -1
00129         cellsFromPoints contains an entry with
00130             - cellI
00131             - list of cells on old mesh that connected to the old point
00132     appended:
00133         cellMap[cellI] contains -1
00134 
00135 
00136 
00137 SourceFiles
00138     mapPolyMesh.C
00139 
00140 \*---------------------------------------------------------------------------*/
00141 
00142 #ifndef mapPolyMesh_H
00143 #define mapPolyMesh_H
00144 
00145 #include "labelList.H"
00146 #include "objectMap.H"
00147 #include "pointField.H"
00148 #include "labelHashSet.H"
00149 #include "Map.H"
00150 
00151 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00152 
00153 namespace Foam
00154 {
00155 
00156 class polyMesh;
00157 
00158 /*---------------------------------------------------------------------------*\
00159                            Class mapPolyMesh Declaration
00160 \*---------------------------------------------------------------------------*/
00161 
00162 class mapPolyMesh
00163 :
00164     public refCount
00165 {
00166     // Private data
00167 
00168         //- Reference to polyMesh
00169         const polyMesh& mesh_;
00170 
00171         //- Number of old live points
00172         const label nOldPoints_;
00173 
00174         //- Number of old live faces
00175         const label nOldFaces_;
00176 
00177         //- Number of old live cells
00178         const label nOldCells_;
00179 
00180         //- Old point map.
00181         //  Contains the old point label for all new points.
00182         //  - for preserved points this is the old point label.
00183         //  - for added points this is the master point ID
00184         //  - for points added with no master, this is -1
00185         //  Size of the list equals the size of new points
00186         const labelList pointMap_;
00187 
00188         //- Points resulting from merging points
00189         const List<objectMap> pointsFromPointsMap_;
00190 
00191         //- Old face map.
00192         //  Contains a list of old face labels for every new face.
00193         //  Size of the list equals the number of new faces
00194         //  - for preserved faces this is the old face label.
00195         //  - for faces added from faces this is the master face ID
00196         //  - for faces added with no master, this is -1
00197         //  - for faces added from points or edges, this is -1
00198         const labelList faceMap_;
00199 
00200         //- Faces inflated from points
00201         const List<objectMap> facesFromPointsMap_;
00202 
00203         //- Faces inflated from edges
00204         const List<objectMap> facesFromEdgesMap_;
00205 
00206         //- Faces resulting from merging faces
00207         const List<objectMap> facesFromFacesMap_;
00208 
00209         //- Old cell map.
00210         //  Contains old cell label for all preserved cells.
00211         //  Size of the list equals the number or preserved cells
00212         const labelList cellMap_;
00213 
00214         //- Cells inflated from points
00215         const List<objectMap> cellsFromPointsMap_;
00216 
00217         //- Cells inflated from edges
00218         const List<objectMap> cellsFromEdgesMap_;
00219 
00220         //- Cells inflated from faces
00221         const List<objectMap> cellsFromFacesMap_;
00222 
00223         //- Cells resulting from merging cells
00224         const List<objectMap> cellsFromCellsMap_;
00225 
00226         //- Reverse point map
00227         const labelList reversePointMap_;
00228 
00229         //- Reverse face map
00230         const labelList reverseFaceMap_;
00231 
00232         //- Reverse cell map
00233         const labelList reverseCellMap_;
00234 
00235         //- Map of flipped face flux faces
00236         const labelHashSet flipFaceFlux_;
00237 
00238         //- Patch mesh point renumbering
00239         const labelListList patchPointMap_;
00240 
00241         //- Point zone renumbering
00242         //  For every preserved point in zone give the old position.
00243         //  For added points, the index is set to -1
00244         const labelListList pointZoneMap_;
00245 
00246         //- Face zone point renumbering
00247         //  For every preserved point in zone give the old position.
00248         //  For added points, the index is set to -1
00249         const labelListList faceZonePointMap_;
00250 
00251         //- Face zone face renumbering
00252         //  For every preserved face in zone give the old position.
00253         //  For added faces, the index is set to -1
00254         const labelListList faceZoneFaceMap_;
00255 
00256         //- Cell zone renumbering
00257         //  For every preserved cell in zone give the old position.
00258         //  For added cells, the index is set to -1
00259         const labelListList cellZoneMap_;
00260 
00261         //- Pre-motion point positions.
00262         //  This specifies the correct way of blowing up zero-volume objects
00263         const pointField preMotionPoints_;
00264 
00265         //- List of the old patch sizes
00266         labelList oldPatchSizes_;
00267 
00268         //- List of the old patch start labels
00269         const labelList oldPatchStarts_;
00270 
00271         //- List of numbers of mesh points per old patch
00272         const labelList oldPatchNMeshPoints_;
00273 
00274 
00275     // Private Member Functions
00276 
00277         //- Disallow default bitwise copy construct
00278         mapPolyMesh(const mapPolyMesh&);
00279 
00280         //- Disallow default bitwise assignment
00281         void operator=(const mapPolyMesh&);
00282 
00283 
00284 public:
00285 
00286     // Constructors
00287 
00288         //- Construct from components
00289         mapPolyMesh
00290         (
00291             const polyMesh& mesh,
00292             const label nOldPoints,
00293             const label nOldFaces,
00294             const label nOldCells,
00295             const labelList& pointMap,
00296             const List<objectMap>& pointsFromPoints,
00297             const labelList& faceMap,
00298             const List<objectMap>& facesFromPoints,
00299             const List<objectMap>& facesFromEdges,
00300             const List<objectMap>& facesFromFaces,
00301             const labelList& cellMap,
00302             const List<objectMap>& cellsFromPoints,
00303             const List<objectMap>& cellsFromEdges,
00304             const List<objectMap>& cellsFromFaces,
00305             const List<objectMap>& cellsFromCells,
00306             const labelList& reversePointMap,
00307             const labelList& reverseFaceMap,
00308             const labelList& reverseCellMap,
00309             const labelHashSet& flipFaceFlux,
00310             const labelListList& patchPointMap,
00311             const labelListList& pointZoneMap,
00312             const labelListList& faceZonePointMap,
00313             const labelListList& faceZoneFaceMap,
00314             const labelListList& cellZoneMap,
00315             const pointField& preMotionPoints,
00316             const labelList& oldPatchStarts,
00317             const labelList& oldPatchNMeshPoints
00318         );
00319 
00320         //- Construct from components and optionally reuse storage
00321         mapPolyMesh
00322         (
00323             const polyMesh& mesh,
00324             const label nOldPoints,
00325             const label nOldFaces,
00326             const label nOldCells,
00327             labelList& pointMap,
00328             List<objectMap>& pointsFromPoints,
00329             labelList& faceMap,
00330             List<objectMap>& facesFromPoints,
00331             List<objectMap>& facesFromEdges,
00332             List<objectMap>& facesFromFaces,
00333             labelList& cellMap,
00334             List<objectMap>& cellsFromPoints,
00335             List<objectMap>& cellsFromEdges,
00336             List<objectMap>& cellsFromFaces,
00337             List<objectMap>& cellsFromCells,
00338             labelList& reversePointMap,
00339             labelList& reverseFaceMap,
00340             labelList& reverseCellMap,
00341             labelHashSet& flipFaceFlux,
00342             labelListList& patchPointMap,
00343             labelListList& pointZoneMap,
00344             labelListList& faceZonePointMap,
00345             labelListList& faceZoneFaceMap,
00346             labelListList& cellZoneMap,
00347             pointField& preMotionPoints,
00348             labelList& oldPatchStarts,
00349             labelList& oldPatchNMeshPoints,
00350             const bool reUse
00351         );
00352 
00353     // Member Functions
00354 
00355         // Access
00356 
00357             //- Return polyMesh
00358             const polyMesh& mesh() const
00359             {
00360                 return mesh_;
00361             }
00362 
00363             //- Number of old points
00364             label nOldPoints() const
00365             {
00366                 return nOldPoints_;
00367             }
00368 
00369             //- Number of old internal faces
00370             label nOldInternalFaces() const
00371             {
00372                 return oldPatchStarts_[0];
00373             }
00374 
00375             //- Number of old faces
00376             label nOldFaces() const
00377             {
00378                 return nOldFaces_;
00379             }
00380 
00381             //- Number of old cells
00382             label nOldCells() const
00383             {
00384                 return nOldCells_;
00385             }
00386 
00387             //- Old point map.
00388             //  Contains the old point label for all new points.
00389             //  For preserved points this is the old point label.
00390             //  For added points this is the master point ID
00391             const labelList& pointMap() const
00392             {
00393                 return pointMap_;
00394             }
00395 
00396             //- Points originating from points
00397             const List<objectMap>& pointsFromPointsMap() const
00398             {
00399                 return pointsFromPointsMap_;
00400             }
00401 
00402             //- Old face map.
00403             //  Contains a list of old face labels for every new face.
00404             //  Warning: this map contains invalid entries for new faces
00405             const labelList& faceMap() const
00406             {
00407                 return faceMap_;
00408             }
00409 
00410             //- Faces inflated from points
00411             const List<objectMap>& facesFromPointsMap() const
00412             {
00413                 return facesFromPointsMap_;
00414             }
00415 
00416             //- Faces inflated from edges
00417             const List<objectMap>& facesFromEdgesMap() const
00418             {
00419                 return facesFromEdgesMap_;
00420             }
00421 
00422             //- Faces originating from faces
00423             const List<objectMap>& facesFromFacesMap() const
00424             {
00425                 return facesFromFacesMap_;
00426             }
00427 
00428             //- Old cell map.
00429             //  Contains old cell label for all preserved cells.
00430             const labelList& cellMap() const
00431             {
00432                 return cellMap_;
00433             }
00434 
00435             //- Cells inflated from points
00436             const List<objectMap>& cellsFromPointsMap() const
00437             {
00438                 return cellsFromPointsMap_;
00439             }
00440 
00441             //- Cells inflated from edges
00442             const List<objectMap>& cellsFromEdgesMap() const
00443             {
00444                 return cellsFromEdgesMap_;
00445             }
00446 
00447             //- Cells inflated from faces
00448             const List<objectMap>& cellsFromFacesMap() const
00449             {
00450                 return cellsFromFacesMap_;
00451             }
00452 
00453             //- Cells originating from cells
00454             const List<objectMap>& cellsFromCellsMap() const
00455             {
00456                 return cellsFromCellsMap_;
00457             }
00458 
00459 
00460             // Reverse maps
00461 
00462                 //- Reverse point map
00463                 //  Contains new point label for all old and added points
00464                 const labelList& reversePointMap() const
00465                 {
00466                     return reversePointMap_;
00467                 }
00468 
00469                 //- If point is removed return point (on new mesh) it merged
00470                 //  into
00471                 label mergedPoint(const label oldPointI) const
00472                 {
00473                     label i = reversePointMap_[oldPointI];
00474 
00475                     if (i == -1)
00476                     {
00477                         return i;
00478                     }
00479                     else if (i < -1)
00480                     {
00481                         return -i-2;
00482                     }
00483                     else
00484                     {
00485                         FatalErrorIn("mergedPoint(const label) const")
00486                             << "old point label " << oldPointI
00487                             << " has reverseMap " << i << endl
00488                             << "Only call mergedPoint for removed points."
00489                             << abort(FatalError);
00490                         return -1;
00491                     }
00492                 }
00493 
00494                 //- Reverse face map
00495                 //  Contains new face label for all old and added faces
00496                 const labelList& reverseFaceMap() const
00497                 {
00498                     return reverseFaceMap_;
00499                 }
00500 
00501                 //- If face is removed return face (on new mesh) it merged into
00502                 label mergedFace(const label oldFaceI) const
00503                 {
00504                     label i = reverseFaceMap_[oldFaceI];
00505 
00506                     if (i == -1)
00507                     {
00508                         return i;
00509                     }
00510                     else if (i < -1)
00511                     {
00512                         return -i-2;
00513                     }
00514                     else
00515                     {
00516                         FatalErrorIn("mergedFace(const label) const")
00517                             << "old face label " << oldFaceI
00518                             << " has reverseMap " << i << endl
00519                             << "Only call mergedFace for removed faces."
00520                             << abort(FatalError);
00521                         return -1;
00522                     }
00523                 }
00524 
00525                 //- Reverse cell map
00526                 //  Contains new cell label for all old and added cells
00527                 const labelList& reverseCellMap() const
00528                 {
00529                     return reverseCellMap_;
00530                 }
00531 
00532                 //- If cell is removed return cell (on new mesh) it merged into
00533                 label mergedCell(const label oldCellI) const
00534                 {
00535                     label i = reverseCellMap_[oldCellI];
00536 
00537                     if (i == -1)
00538                     {
00539                         return i;
00540                     }
00541                     else if (i < -1)
00542                     {
00543                         return -i-2;
00544                     }
00545                     else
00546                     {
00547                         FatalErrorIn("mergedCell(const label) const")
00548                             << "old cell label " << oldCellI
00549                             << " has reverseMap " << i << endl
00550                             << "Only call mergedCell for removed cells."
00551                             << abort(FatalError);
00552                         return -1;
00553                     }
00554                 }
00555 
00556                 //- Map of flipped face flux faces
00557                 const labelHashSet& flipFaceFlux() const
00558                 {
00559                     return flipFaceFlux_;
00560                 }
00561 
00562                 //- Patch point renumbering
00563                 //  For every preserved point on a patch give the old position.
00564                 //  For added points, the index is set to -1
00565                 const labelListList& patchPointMap() const
00566                 {
00567                     return patchPointMap_;
00568                 }
00569 
00570 
00571             // Zone mapping
00572 
00573                 //- Point zone renumbering
00574                 //  For every preserved point in zone give the old position.
00575                 //  For added points, the index is set to -1
00576                 const labelListList& pointZoneMap() const
00577                 {
00578                     return pointZoneMap_;
00579                 }
00580 
00581                 //- Face zone point renumbering
00582                 //  For every preserved point in zone give the old position.
00583                 //  For added points, the index is set to -1
00584                 const labelListList& faceZonePointMap() const
00585                 {
00586                     return faceZonePointMap_;
00587                 }
00588 
00589                 //- Face zone face renumbering
00590                 //  For every preserved face in zone give the old position.
00591                 //  For added faces, the index is set to -1
00592                 const labelListList& faceZoneFaceMap() const
00593                 {
00594                     return faceZoneFaceMap_;
00595                 }
00596 
00597                 //- Cell zone renumbering
00598                 //  For every preserved cell in zone give the old position.
00599                 //  For added cells, the index is set to -1
00600                 const labelListList& cellZoneMap() const
00601                 {
00602                     return cellZoneMap_;
00603                 }
00604 
00605             //- Pre-motion point positions.
00606             //  This specifies the correct way of blowing up
00607             //  zero-volume objects
00608             const pointField& preMotionPoints() const 
00609             {
00610                 return preMotionPoints_;
00611             }
00612 
00613             //- Has valid preMotionPoints?
00614             bool hasMotionPoints() const
00615             {
00616                 return preMotionPoints_.size() > 0;
00617             }
00618 
00619 
00620             //- Return list of the old patch sizes
00621             const labelList& oldPatchSizes() const
00622             {
00623                 return oldPatchSizes_;
00624             }
00625 
00626             //- Return list of the old patch start labels
00627             const labelList& oldPatchStarts() const
00628             {
00629                 return oldPatchStarts_;
00630             }
00631 
00632             //- Return numbers of mesh points per old patch
00633             const labelList& oldPatchNMeshPoints() const
00634             {
00635                 return oldPatchNMeshPoints_;
00636             }
00637 };
00638 
00639 
00640 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00641 
00642 } // End namespace Foam
00643 
00644 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00645 
00646 #endif
00647 
00648 // ************************************************************************* //
Copyright © 2000-2007 OpenCFD Ltd