fixed writing out entries in advective bc
[OpenFOAM-1.6-ext.git] / src / meshTools / sets / cellSources / surfaceToCell / surfaceToCell.H
blob968001f54f472586f72eb34221873a02504cef99
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright held by original author
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
11     OpenFOAM is free software; you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
16     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
19     for more details.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 Class
26     Foam::surfaceToCell
28 Description
29     A topoSetSource to select cells based on relation to surface.
31     Selects:
32     - all cells inside/outside/cut by surface
33     - cells with centre nearer than XXX to surface
34     - cells with centre nearer than XXX to surface @b and with normal
35       at nearest point to centre and cell-corners differing by
36       more than YYY (i.e., point of high curvature)
38 SourceFiles
39     surfaceToCell.C
41 \*---------------------------------------------------------------------------*/
43 #ifndef surfaceToCell_H
44 #define surfaceToCell_H
46 #include "topoSetSource.H"
47 #include "Map.H"
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 namespace Foam
53 class triSurfaceSearch;
54 class triSurface;
56 /*---------------------------------------------------------------------------*\
57                            Class surfaceToCell Declaration
58 \*---------------------------------------------------------------------------*/
60 class surfaceToCell
62     public topoSetSource
65     // Private data
67         //- Add usage string
68         static addToUsageTable usage_;
70         //- Name of surface file
71         fileName surfName_;
73         //- Points which are outside
74         pointField outsidePoints_;
76         //- Include cut cells
77         bool includeCut_;
79         //- Include inside cells
80         bool includeInside_;
82         //- Include outside cells
83         bool includeOutside_;
85         //- if > 0 : include cells with distance from cellCentre to surface
86         //  less than nearDist.
87         scalar nearDist_;
89         //- if > -1 : include cells with normals at nearest surface points
90         //  varying more than curvature_.
91         scalar curvature_;
93         //- triSurface to search on. On pointer since can be external.
94         const triSurface* surfPtr_;
96         //- search engine on surface.
97         const triSurfaceSearch* querySurfPtr_;
99         //- whether I allocated above surface ptrs or whether they are
100         //  external.
101         bool IOwnPtrs_;
104     // Private Member Functions
106         //- Find index of nearest triangle to point. Returns triangle or -1 if
107         //  not found within search span.
108         //  Cache result under pointI.
109         static label getNearest
110         (
111             const triSurfaceSearch& querySurf,
112             const label pointI,
113             const point& pt,
114             const vector& searchSpan,
115             Map<label>& cache
116         );
118         //- Return true if surface normal of nearest points to vertices on
119         //  cell differ from that on cell centre. Points cached in
120         //  pointToNearest.
121         bool differingPointNormals
122         (
123             const triSurfaceSearch& querySurf,
124             const vector& span,
125             const label cellI,
126             const label cellTriI,
127             Map<label>& pointToNearest
128         ) const;
131         //- Depending on surface add to or delete from cellSet.
132         void combine(topoSet& set, const bool add) const;
134         //- Check values at construction time.
135         void checkSettings() const;
137         const triSurfaceSearch& querySurf() const
138         {
139             return *querySurfPtr_;
140         }
143 public:
145     //- Runtime type information
146     TypeName("surfaceToCell");
148     // Constructors
150         //- Construct from components
151         surfaceToCell
152         (
153             const polyMesh& mesh,
154             const fileName& surfName,
155             const pointField& outsidePoints,
156             const bool includeCut,
157             const bool includeInside,
158             const bool includeOutside,
159             const scalar nearDist,
160             const scalar curvature
161         );
163         //- Construct from components (supplied surface, surfaceSearch)
164         surfaceToCell
165         (
166             const polyMesh& mesh,
167             const fileName& surfName,
168             const triSurface& surf,
169             const triSurfaceSearch& querySurf,
170             const pointField& outsidePoints,
171             const bool includeCut,
172             const bool includeInside,
173             const bool includeOutside,
174             const scalar nearDist,
175             const scalar curvature
176         );
178         //- Construct from dictionary
179         surfaceToCell
180         (
181             const polyMesh& mesh,
182             const dictionary& dict
183         );
185         //- Construct from Istream
186         surfaceToCell
187         (
188             const polyMesh& mesh,
189             Istream&
190         );
193     // Destructor
195         virtual ~surfaceToCell();
198     // Member Functions
200         virtual void applyToSet
201         (
202             const topoSetSource::setAction action,
203             topoSet&
204         ) const;
209 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
211 } // End namespace Foam
213 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
215 #endif
217 // ************************************************************************* //