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 | Copyright (C) 2011-2015 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::sampledSet
26 
27 Group
28  grpFunctionObjects
29 
30 Description
31  Holds list of sampling points which is filled at construction time.
32  Various implementations of this base class to e.g. get sampling points
33  at uniform distance along a line (uniformSet) or directly specified
34  (cloudSet)
35 
36  Each 'sampledSet' has a name and a specifier of how the axis should be
37  write (x/y/z component or all 3 components)
38 
39 SourceFiles
40  sampledSet.C
41 
42 \*---------------------------------------------------------------------------*/
43 
44 #ifndef sampledSet_H
45 #define sampledSet_H
46 
47 #include "coordSet.H"
48 #include "typeInfo.H"
49 #include "runTimeSelectionTables.H"
50 #include "autoPtr.H"
51 
52 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
53 
54 namespace Foam
55 {
56 
57 // Forward declaration of classes
58 class polyMesh;
59 class meshSearch;
60 
61 /*---------------------------------------------------------------------------*\
62  Class sampledSet Declaration
63 \*---------------------------------------------------------------------------*/
64 
65 class sampledSet
66 :
67  public coordSet
68 {
69  // Private data
70 
71  //- Reference to mesh
72  const polyMesh& mesh_;
73 
74  //- Reference to mesh searching class
76 
77 
78 protected:
79 
80  //- Segment numbers
82 
83  //- Cell numbers
85 
86  //- Face numbers (-1 if not known)
88 
89 
90  // Protected Member Functions
91 
92  //- Returns cell next to boundary face
93  label getBoundaryCell(const label) const;
94 
95  //- Returns cell using face and containing sample
97  (
98  const label faceI,
99  const point& sample
100  ) const;
101 
102  //- Calculates inproduct of face normal and vector sample-face centre
103  // <0 if sample inside.
104  scalar calcSign(const label faceI, const point& sample) const;
105 
106  //- Returns face label (or -1) of face which is close to sample
108  (
109  const label cellI,
110  const point& sample,
111  const scalar smallDist
112  ) const;
113 
114  //- Moves sample in direction of -n to it is 'inside' of faceI
115  point pushIn
116  (
117  const point& sample,
118  const label faceI
119  ) const;
120 
121  //- Calculates start of tracking given samplePt and first boundary
122  // intersection
123  // (bPoint, bFaceI) (bFaceI == -1 if no boundary intersection)
124  // Returns true if trackPt is valid sampling point. Sets trackPt,
125  // trackFaceI, trackCellI (-1 if no tracking point found)
126  bool getTrackingPoint
127  (
128  const vector& offset,
129  const point& samplePt,
130  const point& bPoint,
131  const label bFaceI,
132 
133  point& trackPt,
134  label& trackCellI,
135  label& trackFaceI
136  ) const;
137 
138  //- Sets sample data
139  void setSamples
140  (
141  const List<point>& samplingPts,
142  const labelList& samplingCells,
143  const labelList& samplingFaces,
144  const labelList& samplingSegments,
145  const scalarList& samplingCurveDist
146  );
147 
148 
149 public:
150 
151  //- Runtime type information
152  TypeName("sampledSet");
153 
154 
155  // Declare run-time constructor selection table
156 
158  (
159  autoPtr,
160  sampledSet,
161  word,
162  (
163  const word& name,
164  const polyMesh& mesh,
165  const meshSearch& searchEngine,
166  const dictionary& dict
167  ),
169  );
170 
171 
172  //- Class used for the read-construction of
173  // PtrLists of sampledSet
174  class iNew
175  {
176  const polyMesh& mesh_;
177  const meshSearch& searchEngine_;
178 
179  public:
180 
181  iNew(const polyMesh& mesh, const meshSearch& searchEngine)
182  :
183  mesh_(mesh),
185  {}
186 
188  {
189  word name(is);
190  dictionary dict(is);
192  }
193  };
194 
195 
196  // Static data
197 
198  //- Tolerance when comparing points. Usually relative to difference
199  // between start_ and end_
200  static const scalar tol;
201 
202 
203  // Constructors
204 
205  //- Construct from components
206  sampledSet
207  (
208  const word& name,
209  const polyMesh& mesh,
210  const meshSearch& searchEngine,
211  const word& axis
212  );
213 
214  //- Construct from dictionary
215  sampledSet
216  (
217  const word& name,
218  const polyMesh& mesh,
219  const meshSearch& searchEngine,
220  const dictionary& dict
221  );
222 
223  //- Clone
224  autoPtr<sampledSet> clone() const
225  {
227  return autoPtr<sampledSet>(NULL);
228  }
229 
230 
231  // Selectors
232 
233  //- Return a reference to the selected sampledSet
234  static autoPtr<sampledSet> New
235  (
236  const word& name,
237  const polyMesh& mesh,
238  const meshSearch& searchEngine,
239  const dictionary& dict
240  );
241 
242 
243  //- Destructor
244  virtual ~sampledSet();
245 
246 
247  // Member Functions
248 
249  const polyMesh& mesh() const
250  {
251  return mesh_;
252  }
253 
254  const meshSearch& searchEngine() const
255  {
256  return searchEngine_;
257  }
258 
259  const labelList& segments() const
260  {
261  return segments_;
262  }
263 
264  const labelList& cells() const
265  {
266  return cells_;
267  }
268 
269  const labelList& faces() const
270  {
271  return faces_;
272  }
273 
274  //- Output for debugging
275  Ostream& write(Ostream&) const;
276 };
277 
278 
279 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
280 
281 } // End namespace Foam
282 
283 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
284 
285 #endif
286 
287 // ************************************************************************* //
Foam::sampledSet
Holds list of sampling points which is filled at construction time. Various implementations of this b...
Definition: sampledSet.H:64
Foam::sampledSet::New
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:440
Foam::coordSet::name
const word & name() const
Definition: coordSet.H:111
Foam::sampledSet::searchEngine_
const meshSearch & searchEngine_
Reference to mesh searching class.
Definition: sampledSet.H:74
Foam::sampledSet::iNew::operator()
autoPtr< sampledSet > operator()(Istream &is) const
Definition: sampledSet.H:186
Foam::sampledSet::write
Ostream & write(Ostream &) const
Output for debugging.
Definition: sampledSet.C:475
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::sampledSet::getCell
label getCell(const label faceI, const point &sample) const
Returns cell using face and containing sample.
Definition: sampledSet.C:53
Foam::meshSearch
Various (local, not parallel) searches on polyMesh; uses (demand driven) octree to search.
Definition: meshSearch.H:57
typeInfo.H
Foam::sampledSet::searchEngine
const meshSearch & searchEngine() const
Definition: sampledSet.H:253
coordSet.H
Foam::sampledSet::declareRunTimeSelectionTable
declareRunTimeSelectionTable(autoPtr, sampledSet, word,(const word &name, const polyMesh &mesh, const meshSearch &searchEngine, const dictionary &dict),(name, mesh, searchEngine, dict))
Foam::sampledSet::cells
const labelList & cells() const
Definition: sampledSet.H:263
Foam::sampledSet::pushIn
point pushIn(const point &sample, const label faceI) const
Moves sample in direction of -n to it is 'inside' of faceI.
Definition: sampledSet.C:175
Foam::sampledSet::TypeName
TypeName("sampledSet")
Runtime type information.
Foam::sampledSet::~sampledSet
virtual ~sampledSet()
Destructor.
Definition: sampledSet.C:433
Foam::coordSet::axis
word axis() const
Definition: coordSet.H:116
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Foam::sampledSet::iNew::mesh_
const polyMesh & mesh_
Definition: sampledSet.H:175
NotImplemented
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:365
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Foam::sampledSet::sampledSet
sampledSet(const word &name, const polyMesh &mesh, const meshSearch &searchEngine, const word &axis)
Construct from components.
Definition: sampledSet.C:398
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:57
Foam::sampledSet::iNew::iNew
iNew(const polyMesh &mesh, const meshSearch &searchEngine)
Definition: sampledSet.H:180
Foam::sampledSet::segments_
labelList segments_
Segment numbers.
Definition: sampledSet.H:80
Foam::sampledSet::getTrackingPoint
bool getTrackingPoint(const vector &offset, const point &samplePt, const point &bPoint, const label bFaceI, point &trackPt, label &trackCellI, label &trackFaceI) const
Calculates start of tracking given samplePt and first boundary.
Definition: sampledSet.C:238
Foam::sampledSet::iNew::searchEngine_
const meshSearch & searchEngine_
Definition: sampledSet.H:176
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::sampledSet::segments
const labelList & segments() const
Definition: sampledSet.H:258
Foam::sampledSet::clone
autoPtr< sampledSet > clone() const
Clone.
Definition: sampledSet.H:223
Foam::sampledSet::faces
const labelList & faces() const
Definition: sampledSet.H:268
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::coordSet
Holds list of sampling positions.
Definition: coordSet.H:49
Foam::sampledSet::findNearFace
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:138
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::sampledSet::getBoundaryCell
label getBoundaryCell(const label) const
Returns cell next to boundary face.
Definition: sampledSet.C:46
Foam::sampledSet::cells_
labelList cells_
Cell numbers.
Definition: sampledSet.H:83
Foam::sampledSet::calcSign
scalar calcSign(const label faceI, const point &sample) const
Calculates inproduct of face normal and vector sample-face centre.
Definition: sampledSet.C:111
Foam::autoPtr
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117
Foam::sampledSet::mesh
const polyMesh & mesh() const
Definition: sampledSet.H:248
Foam::sampledSet::setSamples
void setSamples(const List< point > &samplingPts, const labelList &samplingCells, const labelList &samplingFaces, const labelList &samplingSegments, const scalarList &samplingCurveDist)
Sets sample data.
Definition: sampledSet.C:351
runTimeSelectionTables.H
Macros to ease declaration of run-time selection tables.
Foam::Vector< scalar >
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::sampledSet::faces_
labelList faces_
Face numbers (-1 if not known)
Definition: sampledSet.H:86
Foam::sampledSet::tol
static const scalar tol
Tolerance when comparing points. Usually relative to difference.
Definition: sampledSet.H:199
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::sampledSet::mesh_
const polyMesh & mesh_
Reference to mesh.
Definition: sampledSet.H:71
Foam::sampledSet::iNew
Class used for the read-construction of.
Definition: sampledSet.H:173
autoPtr.H