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

mapDistributePolyMesh.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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00024 
00025 Class
00026     mapDistributePolyMesh
00027 
00028 Description
00029     Class containing mesh-to-mesh mapping information after a mesh addition
00030     where we add a mesh ('added mesh') to an old mesh, creating a new mesh.
00031 
00032     We store mapping from the old to the new mesh and from the added mesh
00033     to the new mesh.
00034 
00035     Note: Might need some more access functions or maybe some zone maps?
00036 
00037 SourceFiles
00038     mapDistributePolyMesh.C
00039 
00040 \*---------------------------------------------------------------------------*/
00041 
00042 #ifndef mapDistributePolyMesh_H
00043 #define mapDistributePolyMesh_H
00044 
00045 #include "labelList.H"
00046 #include "polyMesh.H"
00047 
00048 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00049 
00050 namespace Foam
00051 {
00052 
00053 class mapPolyMesh;
00054 
00055 /*---------------------------------------------------------------------------*\
00056                            Class mapDistributePolyMesh Declaration
00057 \*---------------------------------------------------------------------------*/
00058 
00059 class mapDistributePolyMesh
00060 {
00061     // Private data
00062 
00063         const polyMesh& mesh_;
00064 
00065         //- Number of old live points
00066         const label nOldPoints_;
00067 
00068         //- Number of old live faces
00069         const label nOldFaces_;
00070 
00071         //- Number of old live cells
00072         const label nOldCells_;
00073 
00074         //- List of the old patch sizes
00075         labelList oldPatchSizes_;
00076 
00077         //- List of the old patch start labels
00078         const labelList oldPatchStarts_;
00079 
00080         //- List of numbers of mesh points per old patch
00081         const labelList oldPatchNMeshPoints_;
00082 
00083         //- Maps from subsetted mesh back to original mesh
00084         const labelListList subPointMap_;
00085         const labelListList subFaceMap_;
00086         const labelListList subCellMap_;
00087         const labelListList subPatchMap_;
00088 
00089         //- Maps from subsetted mesh to new reconstructed mesh
00090         const labelListList constructPointMap_;
00091         const labelListList constructFaceMap_;
00092         const labelListList constructCellMap_;
00093         const labelListList constructPatchMap_;
00094 
00095     // Private Member Functions
00096 
00097         void calcPatchSizes();
00098 
00099         //- Distribute list data
00100         template<class T>
00101         static void distribute
00102         (
00103             const label newSize,
00104             const labelListList& subMap,        // from subset to original
00105             const labelListList& constructMap,  // from subset to new
00106             List<T>&
00107         );
00108 
00109 
00110 public:
00111 
00112     // Constructors
00113 
00114         //- Construct from components
00115         mapDistributePolyMesh
00116         (
00117             const polyMesh& mesh,
00118 
00119             // mesh before changes
00120             const label nOldPoints,
00121             const label nOldFaces,
00122             const label nOldCells,
00123             const labelList& oldPatchStarts,
00124             const labelList& oldPatchNMeshPoints,
00125 
00126             // how to subset pieces of mesh to send across
00127             const labelListList& subPointMap,
00128             const labelListList& subFaceMap,
00129             const labelListList& subCellMap,
00130             const labelListList& subPatchMap,
00131 
00132             // how to reconstruct received mesh
00133             const labelListList& constructPointMap,
00134             const labelListList& constructFaceMap,
00135             const labelListList& constructCellMap,
00136             const labelListList& constructPatchMap
00137         );
00138 
00139         //- (optionally destructively) construct from components
00140         mapDistributePolyMesh
00141         (
00142             const polyMesh& mesh,
00143             const label nOldPoints,
00144             const label nOldFaces,
00145             const label nOldCells,
00146             labelList& oldPatchStarts,
00147             labelList& oldPatchNMeshPoints,
00148 
00149             labelListList& subPointMap,
00150             labelListList& subFaceMap,
00151             labelListList& subCellMap,
00152             labelListList& subPatchMap,
00153             labelListList& constructPointMap,
00154             labelListList& constructFaceMap,
00155             labelListList& constructCellMap,
00156             labelListList& constructPatchMap,
00157             const bool reUse                // clone or reuse
00158         );
00159 
00160 
00161     // Member Functions
00162 
00163         // Access
00164 
00165             const polyMesh& mesh() const
00166             {
00167                 return mesh_;
00168             }
00169 
00170             //- Number of points in mesh before distribution
00171             label nOldPoints() const
00172             {
00173                 return nOldPoints_;
00174             }
00175 
00176             //- Number of faces in mesh before distribution
00177             label nOldFaces() const
00178             {
00179                 return nOldFaces_;
00180             }
00181 
00182             //- Number of cells in mesh before distribution
00183             label nOldCells() const
00184             {
00185                 return nOldCells_;
00186             }
00187 
00188             //- List of the old patch sizes
00189             const labelList& oldPatchSizes() const
00190             {
00191                 return oldPatchSizes_;
00192             }
00193 
00194             //- List of the old patch start labels
00195             const labelList& oldPatchStarts() const
00196             {
00197                 return oldPatchStarts_;
00198             }
00199 
00200             //- List of numbers of mesh points per old patch
00201             const labelList& oldPatchNMeshPoints() const
00202             {
00203                 return oldPatchNMeshPoints_;
00204             }
00205 
00206             //- From subsetted mesh back to original mesh
00207             //  (these are like the maps in fvMeshSubset)
00208             const labelListList& subPointMap() const
00209             {
00210                 return subPointMap_;
00211             }
00212             //- From subsetted mesh back to original mesh
00213             const labelListList& subFaceMap() const
00214             {
00215                 return subFaceMap_;
00216             }
00217             //- From subsetted mesh back to original mesh
00218             const labelListList& subCellMap() const
00219             {
00220                 return subCellMap_;
00221             }
00222             //- From subsetted mesh back to original mesh
00223             const labelListList& subPatchMap() const
00224             {
00225                 return subPatchMap_;
00226             }
00227 
00228             //- From subsetted mesh to new reconstructed mesh
00229             //  (like the pointProcAddressing in reconstructPar)
00230             const labelListList& constructPointMap() const
00231             {
00232                 return constructPointMap_;
00233             }
00234             //- From subsetted mesh to new reconstructed mesh
00235             const labelListList& constructFaceMap() const
00236             {
00237                 return constructFaceMap_;
00238             }
00239             //- From subsetted mesh to new reconstructed mesh
00240             const labelListList& constructCellMap() const
00241             {
00242                 return constructCellMap_;
00243             }
00244             //- From subsetted mesh to new reconstructed mesh
00245             const labelListList& constructPatchMap() const
00246             {
00247                 return constructPatchMap_;
00248             }
00249 
00250         // Edit
00251 
00252             //- distribute list of point data
00253             template<class T>
00254             void distributePointData(List<T>& lst) const
00255             {
00256                 distribute
00257                 (
00258                     mesh_.nPoints(),
00259                     subPointMap(),
00260                     constructPointMap(),
00261                     lst
00262                 );
00263             }
00264             //- distribute list of face data
00265             template<class T>
00266             void distributeFaceData(List<T>& lst) const
00267             {
00268                 distribute
00269                 (
00270                     mesh_.nFaces(),
00271                     subFaceMap(),
00272                     constructFaceMap(),
00273                     lst
00274                 );
00275             }
00276             //- distribute list of cell data
00277             template<class T>
00278             void distributeCellData(List<T>& lst) const
00279             {
00280                 distribute
00281                 (
00282                     mesh_.nCells(),
00283                     subCellMap(),
00284                     constructCellMap(),
00285                     lst
00286                 );
00287             }
00288             //- distribute list of patch data
00289             template<class T>
00290             void distributePatchData(List<T>& lst) const
00291             {
00292                 distribute
00293                 (
00294                     mesh_.boundaryMesh().size(),
00295                     subPatchMap(),
00296                     constructPatchMap(),
00297                     lst
00298                 );
00299             }
00300 
00301 
00302             //- distribute list of point/face/cell/patch indices.
00303             //  (Converts to boolList, distributes boolList and reconstructs)
00304             void distributePointIndices(labelList& pointIDs) const;
00305             void distributeFaceIndices(labelList& faceIDs) const;
00306             void distributeCellIndices(labelList& cellIDs) const;
00307             void distributePatchIndices(labelList& patchIDs) const;
00308 
00309 
00310             //- Correct for topo change.
00311             void updateMesh(const mapPolyMesh&)
00312             {
00313                 notImplemented
00314                 (
00315                     "mapDistributePolyMesh::updateMesh(const mapPolyMesh&)"
00316                 );
00317             }
00318 };
00319 
00320 
00321 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00322 
00323 } // End namespace Foam
00324 
00325 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00326 
00327 #ifdef NoRepository
00328 #   include "mapDistributePolyMeshTemplates.C"
00329 #endif
00330 
00331 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00332 
00333 #endif
00334 
00335 // ************************************************************************* //
Copyright © 2000-2007 OpenCFD Ltd