sampledSet.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2021 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 Description
28  Holds list of sampling points which is filled at construction time.
29  Various implementations of this base class to e.g. get sampling points
30  at uniform distance along a line (lineUniformSet) or directly specified
31  (pointsSet)
32 
33  Each 'sampledSet' has a name and a specifier of how the axis should be
34  write (x/y/z component or all 3 components)
35 
36 SourceFiles
37  sampledSet.C
38 
39 \*---------------------------------------------------------------------------*/
40 
41 #ifndef sampledSet_H
42 #define sampledSet_H
43 
44 #include "coordSet.H"
45 #include "typeInfo.H"
46 #include "runTimeSelectionTables.H"
47 #include "autoPtr.H"
48 
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 
51 namespace Foam
52 {
53 
54 // Forward declaration of classes
55 class polyMesh;
56 class meshSearch;
57 
58 /*---------------------------------------------------------------------------*\
59  Class sampledSet Declaration
60 \*---------------------------------------------------------------------------*/
61 
62 class sampledSet
63 :
64  public coordSet
65 {
66  // Private Data
67 
68  //- Name of the set
69  const word name_;
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  // Protected data
81 
82  //- Cell numbers
84 
85  //- Face numbers (-1 if not known)
87 
88 
89  // Protected Member Functions
90 
91  //- Sets sample data
92  void setSamples
93  (
94  const List<point>& samplingPositions,
95  const labelList& samplingSegments,
96  const labelList& samplingCells,
97  const labelList& samplingFaces
98  );
99 
100  //- Sets sample data
101  void setSamples
102  (
103  const List<point>& samplingPositions,
104  const List<scalar>& samplingDistances,
105  const labelList& samplingSegments,
106  const labelList& samplingCells,
107  const labelList& samplingFaces
108  );
109 
110 
111 public:
112 
113  //- Runtime type information
114  TypeName("sampledSet");
115 
116 
117  // Declare run-time constructor selection table
118 
120  (
121  autoPtr,
122  sampledSet,
123  word,
124  (
125  const word& name,
126  const polyMesh& mesh,
127  const meshSearch& searchEngine,
128  const dictionary& dict
129  ),
131  );
132 
133 
134  //- Class used for the read-construction of
135  // PtrLists of sampledSet
136  class iNew
137  {
138  const polyMesh& mesh_;
139  const meshSearch& searchEngine_;
140 
141  public:
142 
143  iNew(const polyMesh& mesh, const meshSearch& searchEngine)
144  :
145  mesh_(mesh),
146  searchEngine_(searchEngine)
147  {}
148 
150  {
151  word name(is);
152  dictionary dict(is);
153  return sampledSet::New(name, mesh_, searchEngine_, dict);
154  }
155  };
156 
157 
158  // Constructors
159 
160  //- Construct from components
161  sampledSet
162  (
163  const word& name,
164  const polyMesh& mesh,
165  const meshSearch& searchEngine,
166  const word& axis
167  );
168 
169  //- Construct from dictionary
170  sampledSet
171  (
172  const word& name,
173  const polyMesh& mesh,
174  const meshSearch& searchEngine,
175  const dictionary& dict
176  );
177 
178  //- Clone
179  autoPtr<sampledSet> clone() const
180  {
182  return autoPtr<sampledSet>(nullptr);
183  }
184 
185 
186  // Selectors
187 
188  //- Return a reference to the selected sampledSet
189  static autoPtr<sampledSet> New
190  (
191  const word& name,
192  const polyMesh& mesh,
193  const meshSearch& searchEngine,
194  const dictionary& dict
195  );
196 
197 
198  //- Destructor
199  virtual ~sampledSet();
200 
201 
202  // Member Functions
203 
204  //- Access the name
205  const word& name() const
206  {
207  return name_;
208  }
209 
210  //- Access the mesh
211  const polyMesh& mesh() const
212  {
213  return mesh_;
214  }
215 
216  //- Access the search engine
217  const meshSearch& searchEngine() const
218  {
219  return searchEngine_;
220  }
221 
222  //- Access the positions
223  const pointField& positions() const
224  {
225  return positions_();
226  }
227 
228  //- Access the cells
229  const labelList& cells() const
230  {
231  return cells_;
232  }
233 
234  //- Access the faces
235  const labelList& faces() const
236  {
237  return faces_;
238  }
239 };
240 
241 
242 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
243 
244 } // End namespace Foam
245 
246 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
247 
248 #endif
249 
250 // ************************************************************************* //
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:60
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
Holds list of sampling positions.
Definition: coordSet.H:51
autoPtr< pointField > positions_
Point positions.
Definition: coordSet.H:83
word axis() const
Return the axis name.
Definition: coordSet.H:147
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
Various (local, not parallel) searches on polyMesh; uses (demand driven) octree to search.
Definition: meshSearch.H:58
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:80
Class used for the read-construction of.
Definition: sampledSet.H:136
autoPtr< sampledSet > operator()(Istream &is) const
Definition: sampledSet.H:148
iNew(const polyMesh &mesh, const meshSearch &searchEngine)
Definition: sampledSet.H:142
Holds list of sampling points which is filled at construction time. Various implementations of this b...
Definition: sampledSet.H:64
labelList faces_
Face numbers (-1 if not known)
Definition: sampledSet.H:85
const labelList & faces() const
Access the faces.
Definition: sampledSet.H:234
sampledSet(const word &name, const polyMesh &mesh, const meshSearch &searchEngine, const word &axis)
Construct from components.
Definition: sampledSet.C:136
const pointField & positions() const
Access the positions.
Definition: sampledSet.H:222
const meshSearch & searchEngine() const
Access the search engine.
Definition: sampledSet.H:216
labelList cells_
Cell numbers.
Definition: sampledSet.H:82
virtual ~sampledSet()
Destructor.
Definition: sampledSet.C:183
const labelList & cells() const
Access the cells.
Definition: sampledSet.H:228
autoPtr< sampledSet > clone() const
Clone.
Definition: sampledSet.H:178
declareRunTimeSelectionTable(autoPtr, sampledSet, word,(const word &name, const polyMesh &mesh, const meshSearch &searchEngine, const dictionary &dict),(name, mesh, searchEngine, dict))
const word & name() const
Access the name.
Definition: sampledSet.H:204
void setSamples(const List< point > &samplingPositions, const labelList &samplingSegments, const labelList &samplingCells, const labelList &samplingFaces)
Sets sample data.
Definition: sampledSet.C:47
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:190
const polyMesh & mesh() const
Access the mesh.
Definition: sampledSet.H:210
TypeName("sampledSet")
Runtime type information.
A class for handling words, derived from string.
Definition: word.H:62
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:381
Namespace for OpenFOAM.
Macros to ease declaration of run-time selection tables.
dictionary dict
Basic run-time type information using word as the type's name. Used to enhance the standard RTTI to c...