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