OpenFOAM logo
Open Source CFD Toolkit

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-2005 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.
00042     - can be added from existing same 'master' entity 
00043       (so point from point, face from face and cell from cell)
00044     - can be inflated: face out of edge or point,
00045         cell out of face, edge or point.
00046     - can be appended: added 'out of nothing'.
00047 
00048     All this information is nessecary to correctly map fields.
00049 
00050     points
00051     ------
00052     unchanged:
00053         pointMap[pointI] contains old point label
00054         reversePointMap[oldPointI] contains new point label
00055     removed:
00056         reversePointMap[oldPointI] contains -1
00057     added-from-same:
00058         pointMap[pointI] contains the old master point label 
00059     appended:
00060         pointMap[pointI] contains -1
00061 
00062 
00063     faces
00064     -----
00065     unchanged:
00066         faceMap[faceI] contains old face label
00067         reverseFaceMap[oldFaceI] contains new face label
00068     removed:
00069         reverseFaceMap[oldFaceI] contains -1
00070     added-from-same:
00071         faceMap[faceI] contains the old master face label 
00072     inflated-from-edge:
00073         faceMap[faceI] contains -1
00074         facesFromEdges contains an entry with
00075             - faceI
00076             - list of faces(*) on old mesh that connected to the old edge
00077     inflated-from-point:
00078         faceMap[faceI] contains -1
00079         facesFromPoints contains an entry with
00080             - faceI
00081             - list of faces(*) on old mesh that connected to the old point
00082     appended:
00083         faceMap[faceI] contains -1
00084 
00085     *) if the newly inflated face is a boundary face the list of faces will
00086        only be boundary faces; if the new face is an internal face they
00087        will only be internal faces.
00088 
00089 
00090     cells
00091     -----
00092     unchanged:
00093         cellMap[cellI] contains old cell label
00094         reverseCellMap[oldCellI] contains new cell label
00095     removed:
00096         reverseCellMap[oldCellI] contains -1
00097     added-from-same:
00098         cellMap[cellI] contains the old master cell label 
00099     inflated-from-face:
00100         cellMap[cellI] contains -1
00101         cellsFromFaces contains an entry with
00102             - cellI
00103             - list of cells on old mesh that connected to the old face
00104     inflated-from-edge:
00105         cellMap[cellI] contains -1
00106         cellsFromEdges contains an entry with
00107             - cellI
00108             - list of cells on old mesh that connected to the old edge
00109     inflated-from-point:
00110         cellMap[cellI] contains -1
00111         cellsFromPoints contains an entry with
00112             - cellI
00113             - list of cells on old mesh that connected to the old point
00114     appended:
00115         cellMap[cellI] contains -1
00116 
00117 
00118 
00119 SourceFiles
00120     mapPolyMesh.C
00121 
00122 \*---------------------------------------------------------------------------*/
00123 
00124 #ifndef mapPolyMesh_H
00125 #define mapPolyMesh_H
00126 
00127 #include "labelList.H"
00128 #include "objectMap.H"
00129 #include "pointField.H"
00130 #include "labelHashSet.H"
00131 
00132 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00133 
00134 namespace Foam
00135 {
00136 
00137 class polyMesh;
00138 
00139 /*---------------------------------------------------------------------------*\
00140                            Class mapPolyMesh Declaration
00141 \*---------------------------------------------------------------------------*/
00142 
00143 class mapPolyMesh
00144 :
00145     public refCount
00146 {
00147     // Private data
00148 
00149         //- Reference to polyMesh
00150         const polyMesh& mesh_;
00151 
00152         //- Number of old live points
00153         label nOldPoints_;
00154 
00155         //- Number of old live faces
00156         label nOldFaces_;
00157 
00158         //- Number of old live cells
00159         label nOldCells_;
00160 
00161         //- Old point map.
00162         //  Contains the old point label for all new points.
00163         //  - for preserved points this is the old point label.
00164         //  - for added points this is the master point ID
00165         //  - for points added with no master, this is -1
00166         //  Size of the list equals the size of new points
00167         labelList pointMap_;
00168 
00169         //- Old face map.
00170         //  Contains a list of old face labels for every new face.
00171         //  Size of the list equals the number of new faces
00172         //  - for preserved faces this is the old face label.
00173         //  - for faces added from faces this is the master face ID
00174         //  - for faces added with no master, this is -1
00175         //  - for faces added from points or edges, this is -1
00176         labelList faceMap_;
00177 
00178         //- Faces inflated from points
00179         List<objectMap> facesFromPointsMap_;
00180 
00181         //- Faces inflated from edges
00182         List<objectMap> facesFromEdgesMap_;
00183 
00184         //- Old cell map.
00185         //  Contains old cell label for all preserved cells.
00186         //  Size of the list equals the number or preserved cells
00187         labelList cellMap_;
00188 
00189         //- Cells inflated from points
00190         List<objectMap> cellsFromPointsMap_;
00191 
00192         //- Cells inflated from edges
00193         List<objectMap> cellsFromEdgesMap_;
00194 
00195         //- Cells inflated from faces
00196         List<objectMap> cellsFromFacesMap_;
00197 
00198         //- Reverse point map
00199         labelList reversePointMap_;
00200 
00201         //- Reverse face map
00202         labelList reverseFaceMap_;
00203 
00204         //- Reverse cell map
00205         labelList reverseCellMap_;
00206 
00207         //- Map of flipped face flux faces
00208         labelHashSet flipFaceFlux_;
00209 
00210         //- Patch mesh point renumbering
00211         labelListList patchPointMap_;
00212 
00213         //- Point zone renumbering
00214         //  For every preserved point in zone give the old position.
00215         //  For added points, the index is set to -1
00216         labelListList pointZoneMap_;
00217 
00218         //- Face zone point renumbering
00219         //  For every preserved point in zone give the old position.
00220         //  For added points, the index is set to -1
00221         labelListList faceZonePointMap_;
00222 
00223         //- Face zone face renumbering
00224         //  For every preserved face in zone give the old position.
00225         //  For added faces, the index is set to -1
00226         labelListList faceZoneFaceMap_;
00227 
00228         //- Cell zone renumbering
00229         //  For every preserved cell in zone give the old position.
00230         //  For added cells, the index is set to -1
00231         labelListList cellZoneMap_;
00232 
00233         //- Pre-motion point positions.
00234         //  This specifies the correct way of blowing up zero-volume objects
00235         pointField preMotionPoints_;
00236 
00237         //- List of the old patch sizes
00238         labelList oldPatchSizes_;
00239 
00240         //- List of the old patch start labels
00241         labelList oldPatchStarts_;
00242 
00243         //- List of numbers of mesh points per old patch
00244         labelList oldPatchNMeshPoints_;
00245 
00246 
00247     // Private Member Functions
00248 
00249         //- Disallow default bitwise copy construct
00250         mapPolyMesh(const mapPolyMesh&);
00251 
00252         //- Disallow default bitwise assignment
00253         void operator=(const mapPolyMesh&);
00254 
00255         // Private member functions to calculate demand driven data
00256 
00257 
00258 public:
00259 
00260     // Constructors
00261 
00262         //- Construct from components
00263         mapPolyMesh
00264         (
00265             const polyMesh& mesh,
00266             const label nOldPoints,
00267             const label nOldFaces,
00268             const label nOldCells,
00269             const labelList& pointMap,
00270             const labelList& faceMap,
00271             const List<objectMap>& facesFromPoints,
00272             const List<objectMap>& facesFromEdges,
00273             const labelList& cellMap,
00274             const List<objectMap>& cellsFromPoints,
00275             const List<objectMap>& cellsFromEdges,
00276             const List<objectMap>& cellsFromFaces,
00277             const labelList& reversePointMap,
00278             const labelList& reverseFaceMap,
00279             const labelList& reverseCellMap,
00280             const labelHashSet& flipFaceFlux,
00281             const labelListList& patchPointMap,
00282             const labelListList& pointZoneMap,
00283             const labelListList& faceZonePointMap,
00284             const labelListList& faceZoneFaceMap,
00285             const labelListList& cellZoneMap,
00286             const pointField& preMotionPoints,
00287             const labelList& oldPatchStarts,
00288             const labelList& oldPatchNMeshPoints
00289         );
00290 
00291 
00292     // Member Functions
00293 
00294         // Access
00295 
00296             //- Return polyMesh
00297             const polyMesh& mesh() const
00298             {
00299                 return mesh_;
00300             }
00301 
00302             //- Number of old points
00303             label nOldPoints() const
00304             {
00305                 return nOldPoints_;
00306             }
00307 
00308             //- Number of old internal faces
00309             label nOldInternalFaces() const
00310             {
00311                 return oldPatchStarts_[0];
00312             }
00313 
00314             //- Number of old faces
00315             label nOldFaces() const
00316             {
00317                 return nOldFaces_;
00318             }
00319 
00320             //- Number of old cells
00321             label nOldCells() const
00322             {
00323                 return nOldCells_;
00324             }
00325 
00326             //- Old point map.
00327             //  Contains the old point label for all new points.
00328             //  For preserved points this is the old point label.
00329             //  For added points this is the master point ID
00330             const labelList& pointMap() const
00331             {
00332                 return pointMap_;
00333             }
00334 
00335             //- Old face map.
00336             //  Contains a list of old face labels for every new face.
00337             //  Warning: this map contains invalid entries for new faces
00338             const labelList& faceMap() const
00339             {
00340                 return faceMap_;
00341             }
00342 
00343             //- Faces inflated from points
00344             const List<objectMap>& facesFromPointsMap() const
00345             {
00346                 return facesFromPointsMap_;
00347             }
00348 
00349             //- Faces inflated from edges
00350             const List<objectMap>& facesFromEdgesMap() const
00351             {
00352                 return facesFromEdgesMap_;
00353             }
00354 
00355             //- Old cell map.
00356             //  Contains old cell label for all preserved cells.
00357             const labelList& cellMap() const
00358             {
00359                 return cellMap_;
00360             }
00361 
00362             //- Cells inflated from points
00363             const List<objectMap>& cellsFromPointsMap() const
00364             {
00365                 return cellsFromPointsMap_;
00366             }
00367 
00368             //- Cells inflated from edges
00369             const List<objectMap>& cellsFromEdgesMap() const
00370             {
00371                 return cellsFromEdgesMap_;
00372             }
00373 
00374             //- Cells inflated from faces
00375             const List<objectMap>& cellsFromFacesMap() const
00376             {
00377                 return cellsFromFacesMap_;
00378             }
00379 
00380 
00381             // Reverse maps
00382 
00383                 //- Reverse point map
00384                 //  Contains new point label for all old and added points
00385                 const labelList& reversePointMap() const
00386                 {
00387                     return reversePointMap_;
00388                 }
00389 
00390 
00391                 //- Reverse face map
00392                 //  Contains new face label for all old and added faces
00393                 const labelList& reverseFaceMap() const
00394                 {
00395                     return reverseFaceMap_;
00396                 }
00397 
00398                 //- Reverse cell map
00399                 //  Contains new cell label for all old and added cells
00400                 const labelList& reverseCellMap() const
00401                 {
00402                     return reverseCellMap_;
00403                 }
00404 
00405 
00406             //- Map of flipped face flux faces
00407             const labelHashSet& flipFaceFlux() const
00408             {
00409                 return flipFaceFlux_;
00410             }
00411 
00412                 //- Patch point renumbering
00413                 //  For every preserved point on a patch give the old position.
00414                 //  For added points, the index is set to -1
00415                 const labelListList& patchPointMap() const
00416                 {
00417                     return patchPointMap_;
00418                 }
00419 
00420 
00421             // Zone mapping
00422 
00423                 //- Point zone renumbering
00424                 //  For every preserved point in zone give the old position.
00425                 //  For added points, the index is set to -1
00426                 const labelListList& pointZoneMap() const
00427                 {
00428                     return pointZoneMap_;
00429                 }
00430 
00431                 //- Face zone point renumbering
00432                 //  For every preserved point in zone give the old position.
00433                 //  For added points, the index is set to -1
00434                 const labelListList& faceZonePointMap() const
00435                 {
00436                     return faceZonePointMap_;
00437                 }
00438 
00439                 //- Face zone face renumbering
00440                 //  For every preserved face in zone give the old position.
00441                 //  For added faces, the index is set to -1
00442                 const labelListList& faceZoneFaceMap() const
00443                 {
00444                     return faceZoneFaceMap_;
00445                 }
00446 
00447                 //- Cell zone renumbering
00448                 //  For every preserved cell in zone give the old position.
00449                 //  For added cells, the index is set to -1
00450                 const labelListList& cellZoneMap() const
00451                 {
00452                     return cellZoneMap_;
00453                 }
00454 
00455             //- Pre-motion point positions.
00456             //  This specifies the correct way of blowing up
00457             //  zero-volume objects
00458             const pointField& preMotionPoints() const 
00459             {
00460                 return preMotionPoints_;
00461             }
00462 
00463             //- Has valid preMotionPoints?
00464             bool hasMotionPoints() const
00465             {
00466                 return preMotionPoints_.size() > 0;
00467             }
00468 
00469 
00470             //- Return list of the old patch sizes
00471             const labelList& oldPatchSizes() const
00472             {
00473                 return oldPatchSizes_;
00474             }
00475 
00476             //- Return list of the old patch start labels
00477             const labelList& oldPatchStarts() const
00478             {
00479                 return oldPatchStarts_;
00480             }
00481 
00482             //- Return numbers of mesh points per old patch
00483             const labelList& oldPatchNMeshPoints() const
00484             {
00485                 return oldPatchNMeshPoints_;
00486             }
00487 };
00488 
00489 
00490 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00491 
00492 } // End namespace Foam
00493 
00494 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00495 
00496 #endif
00497 
00498 // ************************************************************************* //
For further information go to www.openfoam.org