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-2016 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  grpUtilitiesFunctionObjects
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
75  const meshSearch& searchEngine_;
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 the neigbour cell or the owner if face in on the boundary
96  label getNeighbourCell(const label) const;
97 
98  //- Return the cell in which the point on the sample line
99  // resides if found otherwise return -1
100  label pointInCell(const point& p, const label samplei) 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 point& samplePt,
129  const point& bPoint,
130  const label bFacei,
131  const scalar smallDist,
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  ),
168  (name, mesh, searchEngine, dict)
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:
181  iNew(const polyMesh& mesh, const meshSearch& searchEngine)
182  :
183  mesh_(mesh),
184  searchEngine_(searchEngine)
185  {}
188  {
189  word name(is);
190  dictionary dict(is);
191  return sampledSet::New(name, mesh_, searchEngine_, dict);
192  }
193  };
194 
195 
196  // Constructors
197 
198  //- Construct from components
199  sampledSet
200  (
201  const word& name,
202  const polyMesh& mesh,
203  const meshSearch& searchEngine,
204  const word& axis
205  );
206 
207  //- Construct from dictionary
208  sampledSet
209  (
210  const word& name,
211  const polyMesh& mesh,
212  const meshSearch& searchEngine,
213  const dictionary& dict
214  );
215 
216  //- Clone
217  autoPtr<sampledSet> clone() const
218  {
220  return autoPtr<sampledSet>(NULL);
221  }
222 
223 
224  // Selectors
225 
226  //- Return a reference to the selected sampledSet
227  static autoPtr<sampledSet> New
228  (
229  const word& name,
230  const polyMesh& mesh,
231  const meshSearch& searchEngine,
232  const dictionary& dict
233  );
234 
235 
236  //- Destructor
237  virtual ~sampledSet();
238 
239 
240  // Member Functions
242  const polyMesh& mesh() const
243  {
244  return mesh_;
245  }
247  const meshSearch& searchEngine() const
248  {
249  return searchEngine_;
250  }
252  const labelList& segments() const
253  {
254  return segments_;
255  }
257  const labelList& cells() const
258  {
259  return cells_;
260  }
262  const labelList& faces() const
263  {
264  return faces_;
265  }
266 
267  //- Output for debugging
268  Ostream& write(Ostream&) const;
269 };
270 
271 
272 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
273 
274 } // End namespace Foam
275 
276 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
277 
278 #endif
279 
280 // ************************************************************************* //
label getBoundaryCell(const label) const
Returns cell next to boundary face.
Definition: sampledSet.C:44
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:162
Various (local, not parallel) searches on polyMesh; uses (demand driven) octree to search...
Definition: meshSearch.H:57
dictionary dict
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
iNew(const polyMesh &mesh, const meshSearch &searchEngine)
Definition: sampledSet.H:180
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
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:442
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
const labelList & faces() const
Definition: sampledSet.H:261
virtual ~sampledSet()
Destructor.
Definition: sampledSet.C:435
Ostream & write(Ostream &) const
Output for debugging.
Definition: sampledSet.C:477
autoPtr< sampledSet > clone() const
Clone.
Definition: sampledSet.H:216
void setSamples(const List< point > &samplingPts, const labelList &samplingCells, const labelList &samplingFaces, const labelList &samplingSegments, const scalarList &samplingCurveDist)
Sets sample data.
Definition: sampledSet.C:353
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:254
label pointInCell(const point &p, const label samplei) const
Return the cell in which the point on the sample line.
Definition: sampledSet.C:64
const labelList & segments() const
Definition: sampledSet.H:251
Holds list of sampling positions.
Definition: coordSet.H:49
Holds list of sampling points which is filled at construction time. Various implementations of this b...
Definition: sampledSet.H:64
A class for handling words, derived from string.
Definition: word.H:59
const labelList & cells() const
Definition: sampledSet.H:256
const word & name() const
Definition: coordSet.H:111
point pushIn(const point &sample, const label facei) const
Moves sample in direction of -n to it is &#39;inside&#39; of facei.
Definition: sampledSet.C:197
TypeName("sampledSet")
Runtime type information.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
Class used for the read-construction of.
Definition: sampledSet.H:173
labelList segments_
Segment numbers.
Definition: sampledSet.H:80
declareRunTimeSelectionTable(autoPtr, sampledSet, word,(const word &name, const polyMesh &mesh, const meshSearch &searchEngine, const dictionary &dict),(name, mesh, searchEngine, dict))
sampledSet(const word &name, const polyMesh &mesh, const meshSearch &searchEngine, const word &axis)
Construct from components.
Definition: sampledSet.C:400
scalar calcSign(const label facei, const point &sample) const
Calculates inproduct of face normal and vector sample-face centre.
Definition: sampledSet.C:136
word axis() const
Definition: coordSet.H:116
label getNeighbourCell(const label) const
Returns the neigbour cell or the owner if face in on the boundary.
Definition: sampledSet.C:50
const polyMesh & mesh() const
Definition: sampledSet.H:241
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:53
labelList cells_
Cell numbers.
Definition: sampledSet.H:83
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Macros to ease declaration of run-time selection tables.
const meshSearch & searchEngine() const
Definition: sampledSet.H:246
volScalarField & p
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:366
labelList faces_
Face numbers (-1 if not known)
Definition: sampledSet.H:86
Namespace for OpenFOAM.
autoPtr< sampledSet > operator()(Istream &is) const
Definition: sampledSet.H:186