uniformSet.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) 2021 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::uniformSet
29
30Description
31 A sampler type which provides a uniform distribution of \c nPoints
32 sample locations along a straight line specified between a given
33 \c start and an \c end points.
34
35Usage
36 Example specification:
37 \verbatim
38 sets
39 (
40 <set>
41 {
42 // Mandatory entries
43 type uniform;
44 axis <options>;
45 start <vector>;
46 end <vector>;
47 nPoints <label>;
48
49 // Optional entries
50 tol <scalar>;
51 }
52
53 );
54 \endverbatim
55
56 where the entries mean:
57 \table
58 Property | Description | Type | Reqd | Deflt
59 type | Type name: uniform | word | yes | -
60 axis | Output type of sample locations | word | yes | -
61 start | Start point of sample line | vector | yes | -
62 end | End point of sample line | vector | yes | -
63 nPoints | Number of points between start/end | label | yes | -
64 tol | Relative tolerance | scalar | no | 1e-3
65 \endtable
66
67 Options for the \c axis entry:
68 \verbatim
69 x | x-ordinate of a sample
70 y | y-ordinate of a sample
71 z | z-ordinate of a sample
72 xyz | x-y-z coordinates of a sample
73 distance | Normal distance to the first point of a sample
74 \endverbatim
75
76SourceFiles
77 uniformSet.C
78
79\*---------------------------------------------------------------------------*/
80
81#ifndef uniformSet_H
82#define uniformSet_H
83
85#include "sampledSet.H"
86#include "DynamicList.H"
87
88// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
89
90namespace Foam
91{
92
93/*---------------------------------------------------------------------------*\
94 Class uniformSet Declaration
95\*---------------------------------------------------------------------------*/
96
97class uniformSet
98:
99 public sampledSet
100{
101 // Private Data
102
103 //- Start point of sample line
104 point start_;
105
106 //- End point of sample line
107 point end_;
108
109 //- Relative tolerance when comparing points
110 //- relative to difference between start_ and end_
111 scalar tol_;
112
113 //- Number of sampling points
114 label nPoints_;
115
116
117 // Private Member Functions
118
119 //- Calculates - starting at samplePt - the first sampling point
120 // on or after currentPt. smallDist is the tolerance used to compare
121 // positions. Returns false if end of samples reached.
122 bool nextSample
123 (
124 const point& currentPt,
125 const vector& offset,
126 const scalar smallDist,
127 point& samplePt,
128 label& sampleI
129 ) const;
130
131 //- Samples from startTrackPt/Celli. Updates particle/samplePt/sampleI
132 // and puts
133 // samples in the DynamicLists. Returns false if end of all samples
134 // reached
135 bool trackToBoundary
136 (
137 passiveParticleCloud& particleCloud,
138 passiveParticle& singleParticle,
139 point& samplePt,
140 label& sampleI,
141 DynamicList<point>& samplingPts,
142 DynamicList<label>& samplingCells,
143 DynamicList<label>& samplingFaces,
144 DynamicList<scalar>& samplingCurveDist
145 ) const;
146
147 //- Samples from start_ to end_. samplingSegments contains segmentNo
148 // for each sample.
149 void calcSamples
150 (
151 DynamicList<point>& samplingPts,
152 DynamicList<label>& samplingCells,
153 DynamicList<label>& samplingFaces,
154 DynamicList<label>& samplingSegments,
155 DynamicList<scalar>& samplingCurveDist
156 ) const;
157
158 //- Uses calcSamples to obtain samples. Copies them into *this.
159 void genSamples();
160
161
162public:
163
164 //- Runtime type information
165 TypeName("uniform");
166
167
168 // Constructors
169
170 //- Construct from components
172 (
173 const word& name,
174 const polyMesh& mesh,
176 const word& axis,
177 const point& start,
178 const point& end,
179 const label nPoints
180 );
181
182 //- Construct from dictionary
184 (
185 const word& name,
186 const polyMesh& mesh,
188 const dictionary& dict
189 );
190
191
192 //- Destructor
193 virtual ~uniformSet() = default;
194};
195
196
197// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
198
199} // End namespace Foam
200
201// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
202
203#endif
204
205// ************************************************************************* //
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition: DynamicList.H:72
iterator end() noexcept
Return an iterator to end traversing the UList.
Definition: UListI.H:350
label nPoints() const noexcept
Return the number of points.
Definition: coordSet.H:158
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
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
A Cloud of passive particles.
Copy of base particle.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:81
Holds list of sampling points which is filled at construction time. Various implementations of this b...
Definition: sampledSet.H:86
const meshSearch & searchEngine() const noexcept
Definition: sampledSet.H:324
const polyMesh & mesh() const noexcept
Definition: sampledSet.H:319
A sampler type which provides a uniform distribution of nPoints sample locations along a straight lin...
Definition: uniformSet.H:141
TypeName("uniform")
Runtime type information.
virtual ~uniformSet()=default
Destructor.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
A class for handling words, derived from Foam::string.
Definition: word.H:68
Namespace for OpenFOAM.
vector point
Point is a vector.
Definition: point.H:43
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73