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

localPointRegion.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     localPointRegion
00027 
00028 Description
00029     Takes mesh with 'baffles' (= boundary faces sharing points).
00030     Determines for selected points on boundary faces the 'point region' it is
00031     connected to. Each region can be visited by a cell-face-cell walk.
00032     Used in duplicating points after splitting baffles.
00033 
00034     Regions are not consecutive per processor. They will be -1..nRegions_.
00035 
00036     Note: coupled boundaries (cyclics, parallel) not fully tested.
00037 
00038 SourceFiles
00039     localPointRegion.C
00040 
00041 \*---------------------------------------------------------------------------*/
00042 
00043 #ifndef localPointRegion_H
00044 #define localPointRegion_H
00045 
00046 #include "typeInfo.H"
00047 #include "Map.H"
00048 #include "labelList.H"
00049 #include "labelHashSet.H"
00050 
00051 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00052 
00053 namespace Foam
00054 {
00055 
00056 // Class forward declarations
00057 class primitiveMesh;
00058 class polyMesh;
00059 class face;
00060 class mapPolyMesh;
00061 
00062 /*---------------------------------------------------------------------------*\
00063                            Class localPointRegion Declaration
00064 \*---------------------------------------------------------------------------*/
00065 
00066 class localPointRegion
00067 {
00068     // Private data
00069 
00070         //- (global) number of regions
00071         label nRegions_;
00072 
00073         //- From mesh face to local face
00074         Map<label> localFaces_;
00075 
00076         //- From local face addressing to mesh faces.
00077         labelList meshFaces_;
00078 
00079         //- Per local face the region
00080         labelList faceRegion_;
00081 
00082         //- Per local point (i.e. index in pointsToBeDuplicated) the list
00083         //  of regions
00084         labelListList pointRegions_;
00085 
00086 
00087     // Private Member Functions
00088 
00089         //- Set face (and its connected points) to global region nRegions_.
00090         void setFaceRegion
00091         (
00092             const polyMesh&,
00093             const Map<label>&,
00094             const label faceI,
00095             labelListList& pointFaceRegion // in pointFaces addressing.
00096         );
00097 
00098         //- Set point (and its connected faces) to global region nRegions_
00099         void setPointRegion
00100         (
00101             const polyMesh&,
00102             const Map<label>&,
00103             const label pointI,
00104             const label localPointI,
00105             const label faceI,
00106             labelListList& pointFaceRegion
00107         );
00108 
00109         //- Gets local face regions (local to each point) and merges them into
00110         //  global face region (always possible since faces cannot cross
00111         //  a baffle.
00112         void mergeLocalRegions
00113         (
00114             const polyMesh&,
00115             const labelList& pointsToBeDuplicated,
00116             labelListList& pointFaceRegion
00117         );
00118 
00119         //- Change region
00120         void changeRegion
00121         (
00122             const polyMesh&,
00123             const label faceI,
00124             const label oldRegionI,
00125             const label newRegionI,
00126             labelHashSet& changedFaces
00127         );
00128 
00129         //- See walkPointConnectedFaces
00130         static label walkCellFaceCell
00131         (
00132             const primitiveMesh&,
00133             const label startCellI,
00134             const label startPointI,
00135             const label regionI,
00136             labelList& regionPerFace
00137         );
00138 
00139         //- Check if two faces are equal. If forward = false checks f1 in
00140         //  reverse order.
00141         static bool isDuplicate
00142         (
00143             const face& f0,
00144             const face& f1,
00145             const bool forward
00146         );
00147 
00148 public:
00149 
00150     //- Runtime type information
00151     ClassName("localPointRegion");
00152 
00153 
00154     // Constructors
00155 
00156         //- Construct from mesh and points that should be separated.
00157         localPointRegion
00158         (
00159             const polyMesh& mesh,
00160             const labelList& pointsToBeDuplicated
00161         );
00162 
00163 
00164     // Member Functions
00165 
00166         // Static Member Functions
00167 
00168             //- Helper routine to find baffles (two boundary faces using the
00169             //  same points but in reverse order)
00170             //  Gets list of (boundary!) faces to check. Returns labelList
00171             //  of same size as the input list
00172             //  with -1 or index of other face in the input list.
00173             //  Does not handle duplicate faces on both sides of processor patch
00174             static labelList findDuplicateFaces
00175             (
00176                 const primitiveMesh&,
00177                 const labelList&
00178             );
00179 
00180             //- Are all the cells using pointI reachable through (processor
00181             //  local) cell-face-cell walk.
00182             static bool isSingleCellRegion
00183             (
00184                 const primitiveMesh& mesh,
00185                 const label pointI
00186             );
00187 
00188 
00189         // Access
00190 
00191             //- Global number of regions
00192             label nRegions() const
00193             {
00194                 return nRegions_;
00195             }
00196 
00197             //- From local face addressing to mesh faces.
00198             const labelList& meshFaces() const
00199             {   
00200                 return meshFaces_;
00201             }
00202 
00203             //- From mesh face to local face
00204             const Map<label>& localFaces() const
00205             {   
00206                 return localFaces_;
00207             }
00208 
00209             //- Per local face the global region. Regions are not consecutive
00210             //  per processor. They will be -1..nRegions_.
00211             const labelList& faceRegion() const
00212             {
00213                 return faceRegion_;
00214             }
00215 
00216             //- Per pointsToBeDuplicated the list of regions
00217             const labelListList& pointRegions() const
00218             {
00219                 return pointRegions_;
00220             }
00221 
00222         // Edit
00223 
00224             //- Force recalculation of locally stored data on topological change
00225             void updateMesh(const mapPolyMesh&);
00226 };
00227 
00228 
00229 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00230 
00231 } // End namespace Foam
00232 
00233 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00234 
00235 #endif
00236 
00237 // ************************************************************************* //
Copyright © 2000-2007 OpenCFD Ltd