surfaceToCell.H
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2016 OpenFOAM Foundation
9 Copyright (C) 2018-2020 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Class
28 Foam::surfaceToCell
29
30Description
31 A \c topoSetCellSource to select cells based on
32 relation to a surface given by an external file.
33
34 \c surfaceToCell can select:
35 - all cells inside/outside/cut by a surface
36 - all cells inside/outside surface (\c useSurfaceOrientation,
37 requires closed surface)
38 - cells with centre nearer than XXX to surface
39 - cells with centre nearer than XXX to surface \b and with normal
40 at nearest point to centre and cell-corners differing by
41 more than YYY (i.e. point of high curvature)
42
43 Operands:
44 \table
45 Operand | Type | Location
46 input | triSurface | $FOAM_CASE/constant/triSurface/<file>
47 output | cellSet | $FOAM_CASE/constant/polyMesh/sets/<set>
48 \endtable
49
50Usage
51 Minimal example by using \c system/topoSetDict.actions:
52 \verbatim
53 {
54 // Mandatory (inherited) entries
55 name <name>;
56 type cellSet;
57 action <action>;
58
59 // Mandatory entries
60 source surfaceToCell;
61 file <surfaceFileName>;
62 outsidePoints
63 (
64 (<p1x> <p1y> <p1z>)
65 (<p2x> <p2y> <p2z>)
66 ...
67 );
68 includeCut false;
69 includeInside false;
70 includeOutside true;
71 nearDistance 0.5;
72 curvature 1.0;
73
74 // Optional entries
75 useSurfaceOrientation false;
76 fileType stl;
77 scale 2.0;
78 }
79 \endverbatim
80
81 where the entries mean:
82 \table
83 Property | Description | Type | Req'd | Dflt
84 name | Name of cellSet | word | yes | -
85 type | Type name: cellSet | word | yes | -
86 action | Action applied on cells - see below | word | yes | -
87 source | Source name: surfaceToCell | word | yes | -
88 file | The surface "filename" | word | yes | -
89 outsidePoints | List of points that define outside of the surface <!--
90 --> | vectorList | yes | -
91 includeCut | Flag to include cut cells | bool | yes | -
92 includeInside | Flag to include inside cells | bool | yes | -
93 includeOutside | Flag to include outside cells | bool | yes | -
94 useSurfaceOrientation | Flag to use inherently the orientation of <!--
95 --> the surface | bool | no | false
96 nearDistance | Near distance to the surface | scalar | yes | -
97 curvature | Surface curvature | scalar | yes | -
98 fileType | The format of the surface file | word | no | ""
99 scale | Surface scaling factor | scalar | no | -1
100 \endtable
101
102 Options for the \c action entry:
103 \verbatim
104 new | Create a new cellSet from selected cells
105 add | Add selected cells into this cellSet
106 subtract | Remove selected cells from this cellSet
107 \endverbatim
108
109See also
110 - Foam::topoSetSource
111 - Foam::topoSetCellSource
112
113SourceFiles
114 surfaceToCell.C
115
116\*---------------------------------------------------------------------------*/
117
118#ifndef surfaceToCell_H
119#define surfaceToCell_H
120
121#include "topoSetCellSource.H"
122#include "Map.H"
123
124// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
125
126namespace Foam
127{
128
129// Forward Declarations
130class triSurface;
131class triSurfaceSearch;
132
133/*---------------------------------------------------------------------------*\
134 Class surfaceToCell Declaration
135\*---------------------------------------------------------------------------*/
136
137class surfaceToCell
138:
139 public topoSetCellSource
140{
141 // Private Data
142
143 //- Add usage string
144 static addToUsageTable usage_;
145
146 //- Name of surface file
147 const fileName surfName_;
148
149 //- Points which are outside
150 const pointField outsidePoints_;
151
152 //- Include cut cells
153 const bool includeCut_;
154
155 //- Include inside cells
156 const bool includeInside_;
157
158 //- Include outside cells
159 const bool includeOutside_;
160
161 //- Determine inside/outside purely using geometric test
162 // (does not allow includeCut)
163 const bool useSurfaceOrientation_;
164
165 //- If > 0 : include cells with distance from cellCentre to surface
166 // less than nearDist.
167 const scalar nearDist_;
168
169 //- If > -1 : include cells with normals at nearest surface points
170 // varying more than curvature_.
171 const scalar curvature_;
172
173 //- triSurface to search on. On pointer since can be external.
174 const triSurface* surfPtr_;
175
176 //- Search engine on surface.
177 const triSurfaceSearch* querySurfPtr_;
178
179 //- Whether I allocated above surface ptrs or whether they are
180 // external.
181 const bool IOwnPtrs_;
182
183
184 // Private Member Functions
185
186 //- Find index of nearest triangle to point. Returns triangle or -1 if
187 // not found within search span.
188 // Cache result under pointi.
189 static label getNearest
190 (
191 const triSurfaceSearch& querySurf,
192 const label pointi,
193 const point& pt,
194 const vector& searchSpan,
195 Map<label>& cache
196 );
197
198 //- Return true if surface normal of nearest points to vertices on
199 // cell differ from that on cell centre. Points cached in
200 // pointToNearest.
201 bool differingPointNormals
202 (
203 const triSurfaceSearch& querySurf,
204 const vector& span,
205 const label celli,
206 const label cellTriI,
207 Map<label>& pointToNearest
208 ) const;
209
210
211 //- Depending on surface add to or delete from cellSet.
212 void combine(topoSet& set, const bool add) const;
213
214 //- Check values at construction time.
215 void checkSettings() const;
216
217 const triSurfaceSearch& querySurf() const
218 {
219 return *querySurfPtr_;
220 }
221
222
223public:
224
225 //- Runtime type information
226 TypeName("surfaceToCell");
227
228 // Constructors
229
230 //- Construct from components
232 (
233 const polyMesh& mesh,
234 const fileName& surfName,
235 const pointField& outsidePoints,
236 const bool includeCut,
237 const bool includeInside,
238 const bool includeOutside,
239 const bool useSurfaceOrientation,
240 const scalar nearDist,
241 const scalar curvature
242 );
243
244 //- Construct from components (supplied surface, surfaceSearch)
246 (
247 const polyMesh& mesh,
248 const fileName& surfName,
249 const triSurface& surf,
250 const triSurfaceSearch& querySurf,
251 const pointField& outsidePoints,
252 const bool includeCut,
253 const bool includeInside,
254 const bool includeOutside,
255 const bool useSurfaceOrientation,
256 const scalar nearDist,
257 const scalar curvature
258 );
259
260 //- Construct from dictionary
261 surfaceToCell(const polyMesh& mesh, const dictionary& dict);
262
263 //- Construct from Istream
264 surfaceToCell(const polyMesh& mesh, Istream& is);
265
266
267 //- Destructor
268 virtual ~surfaceToCell();
269
270
271 // Member Functions
272
273 virtual void applyToSet
274 (
275 const topoSetSource::setAction action,
276 topoSet&
277 ) const;
278};
279
280
281// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
282
283} // End namespace Foam
284
285// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
286
287#endif
288
289// ************************************************************************* //
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:64
A HashTable to objects of type <T> with a label key.
Definition: Map.H:60
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
A class for handling file names.
Definition: fileName.H:76
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:81
A topoSetCellSource to select cells based on relation to a surface given by an external file.
virtual void applyToSet(const topoSetSource::setAction action, topoSet &) const
Apply specified action to the topoSet.
surfaceToCell(const polyMesh &mesh, const fileName &surfName, const pointField &outsidePoints, const bool includeCut, const bool includeInside, const bool includeOutside, const bool useSurfaceOrientation, const scalar nearDist, const scalar curvature)
Construct from components.
virtual ~surfaceToCell()
Destructor.
TypeName("surfaceToCell")
Runtime type information.
The topoSetCellSource is a intermediate class for handling topoSet sources for selecting cells.
Class with constructor to add usage string to table.
setAction
Enumeration defining various actions.
const polyMesh & mesh() const noexcept
Reference to the mesh.
General set of labels of mesh quantity (points, cells, faces).
Definition: topoSet.H:67
Helper class to search on triSurface.
Triangulated surface description with patch information.
Definition: triSurface.H:79
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
Namespace for OpenFOAM.
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:44
vector point
Point is a vector.
Definition: point.H:43
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73