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

refinementSurfaces.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::refinementSurfaces
00026 
00027 Description
00028     Container for data on surfaces used for surface-driven refinement.
00029     Contains all the data about the level of refinement needed per
00030     surface.
00031 
00032 SourceFiles
00033     refinementSurfaces.C
00034 
00035 \*---------------------------------------------------------------------------*/
00036 
00037 #ifndef refinementSurfaces_H
00038 #define refinementSurfaces_H
00039 
00040 #include <triSurface/triSurfaceGeoMesh.H>
00041 #include <triSurface/triSurfaceFields.H>
00042 #include <OpenFOAM/vectorList.H>
00043 #include <meshTools/pointIndexHit.H>
00044 
00045 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00046 
00047 namespace Foam
00048 {
00049 
00050 class searchableSurfaces;
00051 class shellSurfaces;
00052 class triSurfaceMesh;
00053 
00054 /*---------------------------------------------------------------------------*\
00055                            Class refinementSurfaces Declaration
00056 \*---------------------------------------------------------------------------*/
00057 
00058 class refinementSurfaces
00059 {
00060     // Private data
00061 
00062         //- Reference to all geometry.
00063         const searchableSurfaces& allGeometry_;
00064 
00065         //- Indices of surfaces that are refinement ones
00066         labelList surfaces_;
00067 
00068         //- Surface name (word)
00069         wordList names_;
00070 
00071         //- Per 'interface' surface : name of faceZone to put faces into
00072         wordList faceZoneNames_;
00073 
00074         //- Per 'interface' surface : name of cellZone to put cells into
00075         wordList cellZoneNames_;
00076 
00077         //- Per 'interface' surface : (only used if surface is closed)
00078         //  whether to zone cells inside or outside surface.
00079         boolList zoneInside_;
00080 
00081 
00082         //- From local region number to global region number
00083         labelList regionOffset_;
00084 
00085         //- From global region number to refinement level
00086         labelList minLevel_;
00087 
00088         //- From global region number to refinement level
00089         labelList maxLevel_;
00090 
00091         //- From global region number to perpendicular angle
00092         scalarField perpendicularAngle_;
00093 
00094 
00095     // Private Member Functions
00096 
00097         //- Disallow default bitwise copy construct
00098         refinementSurfaces(const refinementSurfaces&);
00099 
00100         //- Disallow default bitwise assignment
00101         void operator=(const refinementSurfaces&);
00102 
00103 
00104 public:
00105 
00106     // Constructors
00107 
00108         //- Construct from surfaces and dictionaries
00109         refinementSurfaces
00110         (
00111             const searchableSurfaces& allGeometry,
00112             const PtrList<dictionary>&
00113         );
00114 
00115         //- Construct from surfaces and dictionary
00116         refinementSurfaces
00117         (
00118             const searchableSurfaces& allGeometry,
00119             const dictionary&
00120         );
00121 
00122 
00123     // Member Functions
00124 
00125         // Access
00126 
00127             const searchableSurfaces& geometry() const
00128             {
00129                 return allGeometry_;
00130             }
00131 
00132             const labelList& surfaces() const
00133             {
00134                 return surfaces_;
00135             }
00136 
00137             //- Names of surfaces
00138             const wordList& names() const
00139             {
00140                 return names_;
00141             }
00142 
00143             //- Per 'interface' surface : name of faceZone to put faces into
00144             const wordList& faceZoneNames() const
00145             {
00146                 return faceZoneNames_;
00147             }
00148 
00149             //- Per 'interface' surface : name of cellZone to put cells into
00150             const wordList& cellZoneNames() const
00151             {
00152                 return cellZoneNames_;
00153             }
00154 
00155             //- Get indices of unnamed surfaces (surfaces without faceZoneName)
00156             labelList getUnnamedSurfaces() const;
00157 
00158             //- Get indices of named surfaces (surfaces with faceZoneName)
00159             labelList getNamedSurfaces() const;
00160 
00161             //- Get indices of closed named surfaces
00162             labelList getClosedNamedSurfaces() const;
00163 
00164             //- From local region number to global region number
00165             const labelList& regionOffset() const
00166             {
00167                 return regionOffset_;
00168             }
00169 
00170             //- From global region number to refinement level
00171             const labelList& minLevel() const
00172             {
00173                 return minLevel_;
00174             }
00175 
00176             //- From global region number to refinement level
00177             const labelList& maxLevel() const
00178             {
00179                 return maxLevel_;
00180             }
00181 
00182             //- From global region number to perpendicular angle
00183             const scalarField& perpendicularAngle() const
00184             {
00185                 return perpendicularAngle_;
00186             }
00187 
00188 
00189         // Helper
00190 
00191             //- From surface and region on surface to global region
00192             label globalRegion(const label surfI, const label regionI) const
00193             {
00194                 return regionOffset_[surfI]+regionI;
00195             }
00196 
00197             //- Min level for surface and region on surface
00198             label minLevel(const label surfI, const label regionI) const
00199             {
00200                 return minLevel_[globalRegion(surfI, regionI)];
00201             }
00202 
00203             //- Max level for surface and region on surface
00204             label maxLevel(const label surfI, const label regionI) const
00205             {
00206                 return maxLevel_[globalRegion(surfI, regionI)];
00207             }
00208 
00209             label nRegions() const
00210             {
00211                 return minLevel_.size();
00212             }
00213 
00214             //- Calculate minLevelFields
00215             void setMinLevelFields
00216             (
00217                 const shellSurfaces& shells
00218             );
00219 
00221             //static labelList countRegions(const triSurface&);
00222 
00223 
00224         // Searching
00225 
00226             //- Find intersection of edge. Return -1 or first surface
00227             //  with higher (than currentLevel) minlevel.
00228             //  Return surface number and level.
00229             void findHigherIntersection
00230             (
00231                 const pointField& start,
00232                 const pointField& end,
00233                 const labelList& currentLevel,  // current cell refinement level
00234 
00235                 labelList& surfaces,
00236                 labelList& surfaceLevel
00237             ) const;
00238 
00239             //- Find all intersections of edge. Unsorted order.
00240             void findAllHigherIntersections
00241             (
00242                 const pointField& start,
00243                 const pointField& end,
00244                 const labelList& currentLevel,  // current cell refinement level
00245 
00246                 List<vectorList>& surfaceNormal,
00247                 labelListList& surfaceLevel
00248             ) const;
00249 
00250             //- Find intersection nearest to the endpoints. surface1,2 are
00251             //  not indices into surfacesToTest but refinement surface indices.
00252             //  Returns surface, region on surface (so not global surface)
00253             //  and position on surface.
00254             void findNearestIntersection
00255             (
00256                 const labelList& surfacesToTest,
00257                 const pointField& start,
00258                 const pointField& end,
00259 
00260                 labelList& surface1,
00261                 List<pointIndexHit>& hit1,
00262                 labelList& region1,
00263                 labelList& surface2,
00264                 List<pointIndexHit>& hit2,
00265                 labelList& region2
00266             ) const;
00267 
00268             //- Used for debugging only: find intersection of edge.
00269             void findAnyIntersection
00270             (
00271                 const pointField& start,
00272                 const pointField& end,
00273                 labelList& surfaces,
00274                 List<pointIndexHit>&
00275             ) const;
00276 
00277             //- Find nearest point on surfaces.
00278             void findNearest
00279             (
00280                 const labelList& surfacesToTest,
00281                 const pointField& samples,
00282                 const scalarField& nearestDistSqr,
00283                 labelList& surfaces,
00284                 List<pointIndexHit>&
00285             ) const;
00286 
00287             //- Find nearest point on surfaces. Return surface and region on
00288             //  surface (so not global surface)
00289             void findNearestRegion
00290             (
00291                 const labelList& surfacesToTest,
00292                 const pointField& samples,
00293                 const scalarField& nearestDistSqr,
00294                 labelList& hitSurface,
00295                 labelList& hitRegion
00296             ) const;
00297 
00298             //- Detect if a point is 'inside' (closed) surfaces.
00299             //  Returns -1 if not, returns first surface it is.
00300             void findInside
00301             (
00302                 const labelList& surfacesToTest,
00303                 const pointField& pt,
00304                 labelList& insideSurfaces
00305             ) const;
00306 };
00307 
00308 
00309 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00310 
00311 } // End namespace Foam
00312 
00313 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00314 
00315 #endif
00316 
00317 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines