Loading...
Searching...
No Matches
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-2023 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
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;
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,
184 word,
185 (
186 const word& name,
187 const polyMesh& mesh,
189 const dictionary& dict
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
206 :
207 mesh_(mesh),
208 search_(searchEngine)
209 {}
210
212 {
213 word name(is);
214 dictionary dict(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 dictionary& dict = capture_.emplace_back(is);
249
250 return sampledSet::New(name, mesh_, search_, dict);
251 }
252 };
253
254
255 // Constructors
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
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 }
314
315 const meshSearch& searchEngine() const noexcept
316 {
317 return searchEngine_;
318 }
319
320 const labelList& segments() const noexcept
321 {
322 return segments_;
323 }
324
325 const labelList& cells() const noexcept
326 {
327 return cells_;
328 }
329
330 const labelList& faces() const noexcept
331 {
332 return faces_;
333 }
334
335 //- Output for debugging
336 Ostream& write(Ostream&) const;
337
338
339 // Other
340
344 /// (
345 /// labelList& sortOrder,
346 /// labelList& allSegments
347 /// ) const;
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:68
T & emplace_back(Args &&... args)
Construct an element at the end of the list, return reference to the new list element.
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:60
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition List.H:72
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
Holds list of sampling positions.
Definition coordSet.H:52
const word & axis() const
The sort axis name.
Definition coordSet.H:160
coordSet(const word &name, const coordFormat axisType)
Default construct with name and axis type.
Definition coordSet.C:70
const word & name() const noexcept
The coord-set name.
Definition coordSet.H:152
coordFormat
Enumeration defining the output format for coordinates.
Definition coordSet.H:61
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
Various (local, not parallel) searches on polyMesh; uses (demand driven) octree to search.
Definition meshSearch.H:57
Mesh consisting of general polyhedral cells.
Definition polyMesh.H:79
PtrList read-construction helper that captures dictionaries used during creation.
Definition sampledSet.H:270
autoPtr< sampledSet > operator()(Istream &is) const
Definition sampledSet.H:296
iNewCapture(const polyMesh &mesh, const meshSearch &searchEngine, DynamicList< dictionary > &capture)
Definition sampledSet.H:285
Class used for the read-construction of.
Definition sampledSet.H:241
autoPtr< sampledSet > operator()(Istream &is) const
Definition sampledSet.H:256
iNew(const polyMesh &mesh, const meshSearch &searchEngine)
Definition sampledSet.H:250
Holds list of sampling points which is filled at construction time. Various implementations of this b...
Definition sampledSet.H:82
labelList faces_
Face numbers (-1 if not known).
Definition sampledSet.H:113
const labelList & faces() const noexcept
Definition sampledSet.H:393
const meshSearch & searchEngine() const noexcept
Definition sampledSet.H:378
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:363
label pointInCell(const point &p, const label samplei) const
Return the cell in which the point on the sample line.
Definition sampledSet.C:80
label getNeighbourCell(const label) const
Returns the neighbour cell or the owner if face in on the boundary.
Definition sampledSet.C:68
scalar calcSign(const label facei, const point &sample) const
Calculates inproduct of face normal and vector sample-face centre.
Definition sampledSet.C:152
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:267
labelList segments_
Segment numbers.
Definition sampledSet.H:103
labelList cells_
Cell numbers.
Definition sampledSet.H:108
sampledSet(const word &name, const polyMesh &mesh, const meshSearch &searchEngine, const coordSet::coordFormat axisType)
Construct from components.
Definition sampledSet.C:405
label getBoundaryCell(const label) const
Returns cell next to boundary face.
Definition sampledSet.C:62
void checkDimensions() const
Check for consistent sizing.
Definition sampledSet.C:40
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:344
point pushIn(const point &sample, const label facei) const
Moves sample in direction of -n to it is 'inside' of facei.
Definition sampledSet.C:202
const polyMesh & mesh() const noexcept
Definition sampledSet.H:373
const labelList & cells() const noexcept
Definition sampledSet.H:388
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:477
const labelList & segments() const noexcept
Definition sampledSet.H:383
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:176
A class for handling words, derived from Foam::string.
Definition word.H:66
volScalarField & p
dynamicFvMesh & mesh
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition error.H:688
Namespace for OpenFOAM.
List< label > labelList
A List of labels.
Definition List.H:62
vector point
Point is a vector.
Definition point.H:37
const direction noexcept
Definition scalarImpl.H:265
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition exprTraits.C:127
List< scalar > scalarList
List of scalar.
Definition scalarList.H:32
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
Basic run-time type information using word as the type's name. Used to enhance the standard RTTI to c...
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition typeInfo.H:68