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

surfaceToCell.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::surfaceToCell
00026 
00027 Description
00028     A topoSetSource to select cells based on relation to surface.
00029 
00030     Selects:
00031     - all cells inside/outside/cut by surface
00032     - cells with centre nearer than XXX to surface
00033     - cells with centre nearer than XXX to surface @b and with normal
00034       at nearest point to centre and cell-corners differing by
00035       more than YYY (i.e., point of high curvature)
00036 
00037 SourceFiles
00038     surfaceToCell.C
00039 
00040 \*---------------------------------------------------------------------------*/
00041 
00042 #ifndef surfaceToCell_H
00043 #define surfaceToCell_H
00044 
00045 #include <meshTools/topoSetSource.H>
00046 #include <OpenFOAM/Map.H>
00047 
00048 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00049 
00050 namespace Foam
00051 {
00052 class triSurfaceSearch;
00053 class triSurface;
00054 
00055 /*---------------------------------------------------------------------------*\
00056                            Class surfaceToCell Declaration
00057 \*---------------------------------------------------------------------------*/
00058 
00059 class surfaceToCell
00060 :
00061     public topoSetSource
00062 {
00063 
00064     // Private data
00065 
00066         //- Add usage string
00067         static addToUsageTable usage_;
00068 
00069         //- Name of surface file
00070         fileName surfName_;
00071 
00072         //- Points which are outside
00073         pointField outsidePoints_;
00074 
00075         //- Include cut cells
00076         bool includeCut_;
00077 
00078         //- Include inside cells
00079         bool includeInside_;
00080 
00081         //- Include outside cells
00082         bool includeOutside_;
00083 
00084         //- if > 0 : include cells with distance from cellCentre to surface
00085         //  less than nearDist.
00086         scalar nearDist_;
00087 
00088         //- if > -1 : include cells with normals at nearest surface points
00089         //  varying more than curvature_.
00090         scalar curvature_;
00091 
00092         //- triSurface to search on. On pointer since can be external.
00093         const triSurface* surfPtr_;
00094 
00095         //- search engine on surface.
00096         const triSurfaceSearch* querySurfPtr_;
00097 
00098         //- whether I allocated above surface ptrs or whether they are
00099         //  external.
00100         bool IOwnPtrs_;
00101 
00102 
00103     // Private Member Functions
00104 
00105         //- Find index of nearest triangle to point. Returns triangle or -1 if
00106         //  not found within search span.
00107         //  Cache result under pointI.
00108         static label getNearest
00109         (
00110             const triSurfaceSearch& querySurf,
00111             const label pointI,
00112             const point& pt,
00113             const vector& searchSpan,
00114             Map<label>& cache
00115         );
00116 
00117         //- Return true if surface normal of nearest points to vertices on
00118         //  cell differ from that on cell centre. Points cached in
00119         //  pointToNearest.
00120         bool differingPointNormals
00121         (
00122             const triSurfaceSearch& querySurf,
00123             const vector& span,
00124             const label cellI,
00125             const label cellTriI,
00126             Map<label>& pointToNearest
00127         ) const;
00128 
00129 
00130         //- Depending on surface add to or delete from cellSet.
00131         void combine(topoSet& set, const bool add) const;
00132 
00133         //- Check values at construction time.
00134         void checkSettings() const;
00135 
00136         const triSurfaceSearch& querySurf() const
00137         {
00138             return *querySurfPtr_;
00139         }
00140 
00141 
00142 public:
00143 
00144     //- Runtime type information
00145     TypeName("surfaceToCell");
00146 
00147     // Constructors
00148 
00149         //- Construct from components
00150         surfaceToCell
00151         (
00152             const polyMesh& mesh,
00153             const fileName& surfName,
00154             const pointField& outsidePoints,
00155             const bool includeCut,
00156             const bool includeInside,
00157             const bool includeOutside,
00158             const scalar nearDist,
00159             const scalar curvature
00160         );
00161 
00162         //- Construct from components (supplied surface, surfaceSearch)
00163         surfaceToCell
00164         (
00165             const polyMesh& mesh,
00166             const fileName& surfName,
00167             const triSurface& surf,
00168             const triSurfaceSearch& querySurf,
00169             const pointField& outsidePoints,
00170             const bool includeCut,
00171             const bool includeInside,
00172             const bool includeOutside,
00173             const scalar nearDist,
00174             const scalar curvature
00175         );
00176 
00177         //- Construct from dictionary
00178         surfaceToCell
00179         (
00180             const polyMesh& mesh,
00181             const dictionary& dict
00182         );
00183 
00184         //- Construct from Istream
00185         surfaceToCell
00186         (
00187             const polyMesh& mesh,
00188             Istream&
00189         );
00190 
00191 
00192     // Destructor
00193 
00194         virtual ~surfaceToCell();
00195 
00196 
00197     // Member Functions
00198 
00199         virtual void applyToSet
00200         (
00201             const topoSetSource::setAction action,
00202             topoSet&
00203         ) const;
00204 
00205 };
00206 
00207 
00208 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00209 
00210 } // End namespace Foam
00211 
00212 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00213 
00214 #endif
00215 
00216 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines