OpenFOAM logo
Open Source CFD Toolkit

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-2005 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     surfaceToCell
00027 
00028 Description
00029     Selects cells based on relation to surface. Selects:
00030     - all cells inside/outside/cut by surface
00031     - cells with centre nearer than XXX to surface
00032     - cells with centre nearer than XXX to surface AND
00033       with normal at nearest point to centre and cell-corners differing
00034       by more than YYY (i.e. point of high curvature)
00035 
00036 SourceFiles
00037     surfaceToCell.C
00038 
00039 \*---------------------------------------------------------------------------*/
00040 
00041 #ifndef surfaceToCell_H
00042 #define surfaceToCell_H
00043 
00044 #include "topoSetSource.H"
00045 #include "Map.H"
00046 
00047 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00048 
00049 namespace Foam
00050 {
00051 class triSurfaceSearch;
00052 class triSurface;
00053 
00054 /*---------------------------------------------------------------------------*\
00055                            Class surfaceToCell Declaration
00056 \*---------------------------------------------------------------------------*/
00057 
00058 class surfaceToCell
00059 :
00060     public topoSetSource
00061 {
00062 
00063     // Private data
00064 
00065         //- Add usage string
00066         static addToUsageTable usage_;
00067 
00068         //- Name of surface file
00069         fileName surfName_;
00070 
00071         //- Points which are outside
00072         pointField outsidePoints_;
00073 
00074         //- Include cut cells
00075         bool includeCut_;
00076 
00077         //- Include inside cells
00078         bool includeInside_;
00079 
00080         //- Include outside cells
00081         bool includeOutside_;
00082 
00083         //- if > 0 : include cells with distance from cellCentre to surface
00084         //  less than nearDist.
00085         scalar nearDist_;
00086 
00087         //- if > -1 : include cells with normals at nearest surface points
00088         //  varying more than curvature_.
00089         scalar curvature_;
00090 
00091         //- triSurface to search on. On pointer since can be external.
00092         const triSurface* surfPtr_;
00093 
00094         //- search engine on surface.
00095         const triSurfaceSearch* querySurfPtr_;
00096 
00097         //- whether I allocated above surface ptrs or whether they are
00098         //  external.
00099         bool IOwnPtrs_;
00100 
00101 
00102     // Private Member Functions
00103 
00104         //- Find index of nearest triangle to point. Returns triangle or -1 if
00105         //  not found within search span.
00106         //  Cache result under pointI.
00107         static label getNearest
00108         (
00109             const triSurfaceSearch& querySurf,
00110             const label pointI,
00111             const point& pt,
00112             const vector& searchSpan,
00113             Map<label>& cache
00114         );
00115 
00116         //- Return true if surface normal of nearest points to vertices on
00117         //  cell differ from that on cell centre. Points cached in
00118         //  pointToNearest.
00119         bool differingPointNormals
00120         (
00121             const triSurfaceSearch& querySurf,
00122             const vector& span,
00123             const label cellI,
00124             const label cellTriI,
00125 
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(const topoSetSource::setAction action, topoSet&)
00200          const;
00201 
00202 };
00203 
00204 
00205 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00206 
00207 } // End namespace Foam
00208 
00209 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00210 
00211 #endif
00212 
00213 // ************************************************************************* //
For further information go to www.openfoam.org