OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

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