sampledSet.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) 2017-2022 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::sampledSet
29
30Group
31 grpUtilitiesFunctionObjects
32
33Description
34 Holds list of sampling points which is filled at construction time.
35 Various implementations of this base class to e.g. get sampling points
36 at uniform distance along a line (uniformSet) or directly specified
37 (cloudSet)
38
39 Each 'sampledSet' has a name and a specifier of how the axis should be
40 write (x/y/z component or all 3 components)
41
42 For a dictionary specification:
43 \table
44 Property | Description | Required | Default
45 axis | x, y, z, xyz, distance | yes |
46 \endtable
47
48SourceFiles
49 sampledSet.C
50
51\*---------------------------------------------------------------------------*/
52
53#ifndef Foam_sampledSet_H
54#define Foam_sampledSet_H
55
56#include "coordSet.H"
57#include "autoPtr.H"
58#include "typeInfo.H"
60
61// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
62
63namespace Foam
64{
65
66// Forward Declarations
67class polyMesh;
68class meshSearch;
69
70/*---------------------------------------------------------------------------*\
71 Class sampledSet Declaration
72\*---------------------------------------------------------------------------*/
73
74class sampledSet
75:
76 public coordSet
77{
78 // Private Data
79
80 //- Reference to mesh
81 const polyMesh& mesh_;
82
83 //- Reference to mesh searching class
84 const meshSearch& searchEngine_;
85
86
87protected:
88
89 // Protected Data
90
91 //- Segment numbers
93
94 //- Cell numbers
96
97 //- Face numbers (-1 if not known)
99
100
101 // Protected Member Functions
102
103 //- Check for consistent sizing
104 void checkDimensions() const;
105
106 //- Returns cell next to boundary face
107 label getBoundaryCell(const label) const;
108
109 //- Returns the neighbour cell or the owner if face in on the boundary
110 label getNeighbourCell(const label) const;
111
112 //- Return the cell in which the point on the sample line
113 // resides if found otherwise return -1
114 label pointInCell(const point& p, const label samplei) const;
115
116 //- Calculates inproduct of face normal and vector sample-face centre
117 // <0 if sample inside.
118 scalar calcSign(const label facei, const point& sample) const;
119
120 //- Returns face label (or -1) of face which is close to sample
121 label findNearFace
122 (
123 const label celli,
124 const point& sample,
125 const scalar smallDist
126 ) const;
127
128 //- Moves sample in direction of -n to it is 'inside' of facei
130 (
131 const point& sample,
132 const label facei
133 ) const;
134
135 //- Calculates start of tracking given samplePt and first boundary
136 // intersection
137 // (bPoint, bFacei) (bFacei == -1 if no boundary intersection)
138 // Returns true if trackPt is valid sampling point. Sets trackPt,
139 // trackFacei, trackCelli (-1 if no tracking point found)
141 (
142 const point& samplePt,
143 const point& bPoint,
144 const label bFacei,
145 const scalar smallDist,
146
147 point& trackPt,
148 label& trackCelli,
149 label& trackFacei
150 ) const;
151
152 //- Set sample data. Copy list contents.
153 void setSamples
154 (
155 const List<point>& samplingPts,
156 const labelList& samplingCells,
157 const labelList& samplingFaces,
158 const labelList& samplingSegments,
159 const scalarList& samplingDistance
160 );
161
162 //- Set sample data. Move list contents.
163 void setSamples
164 (
165 List<point>&& samplingPts,
166 labelList&& samplingCells,
167 labelList&& samplingFaces,
168 labelList&& samplingSegments,
169 scalarList&& samplingDistance
170 );
171
172public:
173
174 //- Runtime type information
175 TypeName("sampledSet");
176
177
178 // Declare run-time constructor selection table
179
181 (
182 autoPtr,
185 (
186 const word& name,
187 const polyMesh& mesh,
190 ),
192 );
193
194
195 //- Class used for the read-construction of
196 // PtrLists of sampledSet
197 class iNew
198 {
199 //- Reference to the volume mesh
200 const polyMesh& mesh_;
201 const meshSearch& search_;
202
203 public:
204
207 mesh_(mesh),
208 search_(searchEngine)
209 {}
210
212 {
213 word name(is);
215 return sampledSet::New(name, mesh_, search_, dict);
216 }
217 };
218
219
220 //- PtrList read-construction helper that captures dictionaries used
221 //- during creation.
222 class iNewCapture
223 {
224 //- Reference to the volume mesh
225 const polyMesh& mesh_;
226 const meshSearch& search_;
227
228 //- Captured (recorded) dictionaries
229 DynamicList<dictionary>& capture_;
230
231 public:
232
234 (
235 const polyMesh& mesh,
238 )
239 :
240 mesh_(mesh),
241 search_(searchEngine),
242 capture_(capture)
243 {}
244
246 {
247 word name(is);
248 capture_.append(dictionary(is));
249
250 return sampledSet::New(name, mesh_, search_, capture_.last());
251 }
252 };
253
255 // Constructors
256
257 //- Construct from components
259 (
260 const word& name,
261 const polyMesh& mesh,
263 const coordSet::coordFormat axisType
264 );
265
266 //- Construct from components
268 (
269 const word& name,
270 const polyMesh& mesh,
272 const word& axis
273 );
274
275 //- Construct from dictionary
277 (
278 const word& name,
279 const polyMesh& mesh,
281 const dictionary& dict
282 );
283
284 //- Clone
286 {
288 return nullptr;
289 }
290
291
292 // Selectors
293
294 //- Return a reference to the selected sampledSet
296 (
297 const word& name,
298 const polyMesh& mesh,
300 const dictionary& dict
301 );
302
303
304 //- Destructor
305 virtual ~sampledSet() = default;
306
307
308 // Member Functions
309
310 const polyMesh& mesh() const noexcept
311 {
312 return mesh_;
313 }
315 const meshSearch& searchEngine() const noexcept
316 {
317 return searchEngine_;
318 }
320 const labelList& segments() const noexcept
321 {
322 return segments_;
323 }
325 const labelList& cells() const noexcept
326 {
327 return cells_;
328 }
330 const labelList& faces() const noexcept
331 {
332 return faces_;
333 }
335 //- Output for debugging
336 Ostream& write(Ostream&) const;
337
338
339 // Other
340
348};
349
350
351// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
352
353} // End namespace Foam
354
355// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
356
357#endif
358
359// ************************************************************************* //
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition: DynamicList.H:72
void append(const T &val)
Copy append an element to the end of this list.
Definition: DynamicListI.H:503
Minimal example by using system/controlDict.functions:
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:64
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
Definition: Time.C:717
T & last()
Return the last element of the list.
Definition: UListI.H:216
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
Holds list of sampling positions.
Definition: coordSet.H:56
const word & axis() const
The sort axis name.
Definition: coordSet.H:140
const word & name() const noexcept
The coord-set name.
Definition: coordSet.H:134
coordFormat
Enumeration defining the output format for coordinates.
Definition: coordSet.H:63
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
Various (local, not parallel) searches on polyMesh; uses (demand driven) octree to search.
Definition: meshSearch.H:61
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:81
autoPtr< sampledSet > operator()(Istream &is) const
Definition: sampledSet.H:254
iNewCapture(const polyMesh &mesh, const meshSearch &searchEngine, DynamicList< dictionary > &capture)
Definition: sampledSet.H:243
Class used for the read-construction of.
Definition: sampledSet.H:207
autoPtr< sampledSet > operator()(Istream &is) const
Definition: sampledSet.H:220
iNew(const polyMesh &mesh, const meshSearch &searchEngine)
Definition: sampledSet.H:214
Holds list of sampling points which is filled at construction time. Various implementations of this b...
Definition: sampledSet.H:86
labelList faces_
Face numbers (-1 if not known)
Definition: sampledSet.H:107
const labelList & faces() const noexcept
Definition: sampledSet.H:339
const meshSearch & searchEngine() const noexcept
Definition: sampledSet.H:324
void setSamples(const List< point > &samplingPts, const labelList &samplingCells, const labelList &samplingFaces, const labelList &samplingSegments, const scalarList &samplingDistance)
Set sample data. Copy list contents.
Definition: sampledSet.C:379
label pointInCell(const point &p, const label samplei) const
Return the cell in which the point on the sample line.
Definition: sampledSet.C:87
label getNeighbourCell(const label) const
Returns the neighbour cell or the owner if face in on the boundary.
Definition: sampledSet.C:75
scalar calcSign(const label facei, const point &sample) const
Calculates inproduct of face normal and vector sample-face centre.
Definition: sampledSet.C:159
bool getTrackingPoint(const point &samplePt, const point &bPoint, const label bFacei, const scalar smallDist, point &trackPt, label &trackCelli, label &trackFacei) const
Calculates start of tracking given samplePt and first boundary.
Definition: sampledSet.C:283
labelList segments_
Segment numbers.
Definition: sampledSet.H:101
labelList cells_
Cell numbers.
Definition: sampledSet.H:104
label getBoundaryCell(const label) const
Returns cell next to boundary face.
Definition: sampledSet.C:69
void checkDimensions() const
Check for consistent sizing.
Definition: sampledSet.C:47
declareRunTimeSelectionTable(autoPtr, sampledSet, word,(const word &name, const polyMesh &mesh, const meshSearch &searchEngine, const dictionary &dict),(name, mesh, searchEngine, dict))
autoPtr< sampledSet > clone() const
Clone.
Definition: sampledSet.H:294
point pushIn(const point &sample, const label facei) const
Moves sample in direction of -n to it is 'inside' of facei.
Definition: sampledSet.C:218
const polyMesh & mesh() const noexcept
Definition: sampledSet.H:319
const labelList & cells() const noexcept
Definition: sampledSet.H:334
static autoPtr< sampledSet > New(const word &name, const polyMesh &mesh, const meshSearch &searchEngine, const dictionary &dict)
Return a reference to the selected sampledSet.
Definition: sampledSet.C:493
const labelList & segments() const noexcept
Definition: sampledSet.H:329
TypeName("sampledSet")
Runtime type information.
virtual ~sampledSet()=default
Destructor.
label findNearFace(const label celli, const point &sample, const scalar smallDist) const
Returns face label (or -1) of face which is close to sample.
Definition: sampledSet.C:183
A class for handling words, derived from Foam::string.
Definition: word.H:68
volScalarField & p
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:517
Namespace for OpenFOAM.
const direction noexcept
Definition: Scalar.H:223
runTime write()
Macros to ease declaration of run-time selection tables.
#define declareRunTimeSelectionTable(ptrWrapper, baseType, argNames, argList, parList)
Declare a run-time selection (variables and adder classes)
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73