FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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