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 -------------------------------------------------------------------------------
11 License
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 
27 Class
28  Foam::uniformSet
29 
30 Description
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 
35 Usage
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 
76 SourceFiles
77  uniformSet.C
78 
79 \*---------------------------------------------------------------------------*/
80 
81 #ifndef uniformSet_H
82 #define uniformSet_H
83 
84 #include "passiveParticleCloud.H"
85 #include "sampledSet.H"
86 #include "DynamicList.H"
87 
88 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
89 
90 namespace Foam
91 {
92 
93 /*---------------------------------------------------------------------------*\
94  Class uniformSet Declaration
95 \*---------------------------------------------------------------------------*/
96 
97 class 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 
162 public:
163 
164  //- Runtime type information
165  TypeName("uniform");
166 
167 
168  // Constructors
169 
170  //- Construct from components
171  uniformSet
172  (
173  const word& name,
174  const polyMesh& mesh,
175  const meshSearch& searchEngine,
176  const word& axis,
177  const point& start,
178  const point& end,
179  const label nPoints
180  );
181 
182  //- Construct from dictionary
183  uniformSet
184  (
185  const word& name,
186  const polyMesh& mesh,
187  const meshSearch& searchEngine,
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 // ************************************************************************* //
Foam::sampledSet
Holds list of sampling points which is filled at construction time. Various implementations of this b...
Definition: sampledSet.H:83
Foam::coordSet::name
const word & name() const
Definition: coordSet.H:125
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::meshSearch
Various (local, not parallel) searches on polyMesh; uses (demand driven) octree to search.
Definition: meshSearch.H:60
Foam::DynamicList< point >
Foam::uniformSet
A sampler type which provides a uniform distribution of nPoints sample locations along a straight lin...
Definition: uniformSet.H:138
Foam::sampledSet::searchEngine
const meshSearch & searchEngine() const
Definition: sampledSet.H:286
Foam::passiveParticle
Copy of base particle.
Definition: passiveParticle.H:53
Foam::coordSet::axis
word axis() const
Definition: coordSet.H:130
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
nPoints
label nPoints
Definition: gmvOutputHeader.H:2
sampledSet.H
Foam::uniformSet::~uniformSet
virtual ~uniformSet()=default
Destructor.
Foam::passiveParticleCloud
A Cloud of passive particles.
Definition: passiveParticleCloud.H:52
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
stdFoam::end
constexpr auto end(C &c) -> decltype(c.end())
Return iterator to the end of the container c.
Definition: stdFoam.H:121
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::vector
Vector< scalar > vector
A scalar version of the templated Vector.
Definition: vector.H:51
Foam::sampledSet::mesh
const polyMesh & mesh() const
Definition: sampledSet.H:281
Foam::uniformSet::TypeName
TypeName("uniform")
Runtime type information.
passiveParticleCloud.H
Foam::Vector< scalar >
Foam::uniformSet::uniformSet
uniformSet(const word &name, const polyMesh &mesh, const meshSearch &searchEngine, const word &axis, const point &start, const point &end, const label nPoints)
Construct from components.
Definition: uniformSet.C:417
DynamicList.H
Foam::point
vector point
Point is a vector.
Definition: point.H:43