probes.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::probes
26 
27 Group
28  grpFunctionObjects
29 
30 Description
31  Set of locations to sample.
32 
33  Call write() to sample and write files.
34 
35  Example of function object specification:
36  \verbatim
37  probes
38  {
39  type probes;
40  functionObjectLibs ( "libsampling.so" );
41 
42  // Name of the directory for probe data
43  name probes;
44 
45  // Write at same frequency as fields
46  outputControl outputTime;
47  outputInterval 1;
48 
49  // Fields to be probed
50  fields
51  (
52  p U
53  );
54 
55  // Optional: do not recalculate cells if mesh moves
56  fixedLocations false;
57 
58  // Optional: interpolation scheme to use (default is cell)
59  interpolationScheme cellPoint;
60 
61  probeLocations
62  (
63  ( 1e-06 0 0.01 ) // at inlet
64  (0.21 -0.20999 0.01) // at outlet1
65  (0.21 0.20999 0.01) // at outlet2
66  (0.21 0 0.01) // at central block
67  );
68  }
69  \endverbatim
70 
71 SourceFiles
72  probes.C
73 
74 \*---------------------------------------------------------------------------*/
75 
76 #ifndef probes_H
77 #define probes_H
78 
79 #include "HashPtrTable.H"
80 #include "OFstream.H"
81 #include "polyMesh.H"
82 #include "pointField.H"
83 #include "volFieldsFwd.H"
84 #include "surfaceFieldsFwd.H"
85 #include "surfaceMesh.H"
86 #include "wordReList.H"
87 
88 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
89 
90 namespace Foam
91 {
92 
93 // Forward declaration of classes
94 class objectRegistry;
95 class dictionary;
96 class fvMesh;
97 class mapPolyMesh;
98 
99 /*---------------------------------------------------------------------------*\
100  Class probes Declaration
101 \*---------------------------------------------------------------------------*/
102 
103 class probes
104 :
105  public pointField
106 {
107 protected:
108 
109  // Protected classes
110 
111  //- Class used for grouping field types
112  template<class Type>
113  class fieldGroup
114  :
115  public DynamicList<word>
116  {
117  public:
118  //- Construct null
119  fieldGroup()
120  :
121  DynamicList<word>(0)
122  {}
123  };
124 
125 
126  // Private data
127 
128  //- Name of this set of probes,
129  // Also used as the name of the probes directory.
130  const word name_;
131 
132  //- Const reference to fvMesh
133  const fvMesh& mesh_;
134 
135  //- Load fields from files (not from objectRegistry)
136  const bool loadFromFiles_;
137 
138 
139  // Read from dictonary
140 
141  //- Names of fields to probe
143 
144  //- Fixed locations, default = yes
145  // Note: set to false for moving mesh calculations where locations
146  // should move with the mesh
147  bool fixedLocations_;
148 
149  //- Interpolation scheme name
150  // Note: only possible when fixedLocations_ is true
152 
153 
154  // Calculated
155 
156  //- Categorized scalar/vector/tensor vol fields
162 
163  //- Categorized scalar/vector/tensor surf fields
169 
170  // Cells to be probed (obtained from the locations)
172 
173  // Faces to be probed
175 
176  //- Current open files
178 
179 
180  // Protected Member Functions
181 
182  //- Clear old field groups
183  void clearFieldGroups();
184 
185  //- Append fieldName to the appropriate group
186  label appendFieldGroup(const word& fieldName, const word& fieldType);
187 
188  //- Classify field types, returns the number of fields
190 
191  //- Find cells and faces containing probes
192  virtual void findElements(const fvMesh&);
193 
194  //- Classify field type and Open/close file streams,
195  // returns number of fields to sample
196  label prepare();
197 
198  //- Read dictionary settings
199  void readDict(const dictionary& dict);
200 
201 private:
202 
203  //- Sample and write a particular volume field
204  template<class Type>
205  void sampleAndWrite
206  (
208  );
209 
210 
211  //- Sample and write a particular surface field
212  template<class Type>
213  void sampleAndWrite
214  (
216  );
217 
218  //- Sample and write all the fields of the given type
219  template<class Type>
220  void sampleAndWrite(const fieldGroup<Type>&);
221 
222  //- Sample and write all the surface fields of the given type
223  template<class Type>
225 
226  //- Disallow default bitwise copy construct
227  probes(const probes&);
228 
229  //- Disallow default bitwise assignment
230  void operator=(const probes&);
231 
232 
233 public:
234 
235  //- Runtime type information
236  TypeName("probes");
237 
238 
239  // Constructors
240 
241  //- Construct for given objectRegistry and dictionary.
242  // Allow the possibility to load fields from files
243  probes
244  (
245  const word& name,
246  const objectRegistry&,
247  const dictionary&,
248  const bool loadFromFiles = false,
249  const bool findElements = true
250  );
251 
252 
253  //- Destructor
254  virtual ~probes();
255 
256 
257  // Member Functions
258 
259  //- Return name of the set of probes
260  virtual const word& name() const
261  {
262  return name_;
263  }
264 
265  //- Return names of fields to probe
266  virtual const wordReList& fieldNames() const
267  {
268  return fieldSelection_;
269  }
270 
271  //- Return locations to probe
272  virtual const pointField& probeLocations() const
273  {
274  return *this;
275  }
276 
277  //- Return location for probe i
278  virtual const point& probe(const label i) const
279  {
280  return operator[](i);
281  }
282 
283  //- Cells to be probed (obtained from the locations)
284  const labelList& elements() const
285  {
286  return elementList_;
287  }
288 
289  //- Execute, currently does nothing
290  virtual void execute();
291 
292  //- Execute at the final time-loop, currently does nothing
293  virtual void end();
294 
295  //- Called when time was set at the end of the Time::operator++
296  virtual void timeSet();
297 
298  //- Sample and write
299  virtual void write();
300 
301  //- Read the probes
302  virtual void read(const dictionary&);
303 
304  //- Update for changes of mesh
305  virtual void updateMesh(const mapPolyMesh&);
306 
307  //- Update for changes of mesh
308  virtual void movePoints(const polyMesh&);
309 
310  //- Update for changes of mesh due to readUpdate
311  virtual void readUpdate(const polyMesh::readUpdateState state)
312  {}
313 
314  //- Sample a volume field at all locations
315  template<class Type>
317  (
319  ) const;
320 
321  //- Sample a single vol field on all sample locations
322  template<class Type>
323  tmp<Field<Type> > sample(const word& fieldName) const;
324 
325  //- Sample a single scalar field on all sample locations
326  template<class Type>
327  tmp<Field<Type> > sampleSurfaceFields(const word& fieldName) const;
328 
329  //- Sample a surface field at all locations
330  template<class Type>
332  (
334  ) const;
335 };
336 
337 
338 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
339 
340 } // End namespace Foam
341 
342 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
343 
344 #ifdef NoRepository
345 # include "probesTemplates.C"
346 #endif
347 
348 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
349 
350 #endif
351 
352 // ************************************************************************* //
Foam::probes::sphericalTensorFields_
fieldGroup< sphericalTensor > sphericalTensorFields_
Definition: probes.H:158
volFieldsFwd.H
Foam::probes::symmTensorFields_
fieldGroup< symmTensor > symmTensorFields_
Definition: probes.H:159
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::probes::fieldNames
virtual const wordReList & fieldNames() const
Return names of fields to probe.
Definition: probes.H:265
Foam::probes::tensorFields_
fieldGroup< tensor > tensorFields_
Definition: probes.H:160
probesTemplates.C
Foam::probes::scalarFields_
fieldGroup< scalar > scalarFields_
Categorized scalar/vector/tensor vol fields.
Definition: probes.H:156
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:118
Foam::DynamicList
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition: DynamicList.H:56
Foam::probes::TypeName
TypeName("probes")
Runtime type information.
Foam::probes::clearFieldGroups
void clearFieldGroups()
Clear old field groups.
Definition: probesGrouping.C:34
Foam::probes::appendFieldGroup
label appendFieldGroup(const word &fieldName, const word &fieldType)
Append fieldName to the appropriate group.
Definition: probesGrouping.C:51
Foam::probes::fixedLocations_
bool fixedLocations_
Fixed locations, default = yes.
Definition: probes.H:146
Foam::probes::surfaceVectorFields_
fieldGroup< vector > surfaceVectorFields_
Definition: probes.H:164
polyMesh.H
Foam::probes::fieldGroup
Class used for grouping field types.
Definition: probes.H:112
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
OFstream.H
Foam::probes::surfaceSphericalTensorFields_
fieldGroup< sphericalTensor > surfaceSphericalTensorFields_
Definition: probes.H:165
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:50
Foam::probes::mesh_
const fvMesh & mesh_
Const reference to fvMesh.
Definition: probes.H:132
Foam::probes::end
virtual void end()
Execute at the final time-loop, currently does nothing.
Definition: probes.C:333
Foam::probes::sample
tmp< Field< Type > > sample(const GeometricField< Type, fvPatchField, volMesh > &) const
Sample a volume field at all locations.
Foam::probes::updateMesh
virtual void updateMesh(const mapPolyMesh &)
Update for changes of mesh.
Definition: probes.C:389
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::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::probes::fieldSelection_
wordReList fieldSelection_
Names of fields to probe.
Definition: probes.H:141
Foam::probes::write
virtual void write()
Sample and write.
Definition: probes.C:345
Foam::probes::probeFilePtrs_
HashPtrTable< OFstream > probeFilePtrs_
Current open files.
Definition: probes.H:176
Foam::probes::faceList_
labelList faceList_
Definition: probes.H:173
Foam::probes::elements
const labelList & elements() const
Cells to be probed (obtained from the locations)
Definition: probes.H:283
Foam::probes::probes
probes(const probes &)
Disallow default bitwise copy construct.
Foam::probes::elementList_
labelList elementList_
Definition: probes.H:170
Foam::probes
Set of locations to sample.
Definition: probes.H:102
Foam::probes::prepare
label prepare()
Classify field type and Open/close file streams,.
Definition: probes.C:158
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::probes::sampleSurfaceFields
tmp< Field< Type > > sampleSurfaceFields(const word &fieldName) const
Sample a single scalar field on all sample locations.
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::probes::fieldGroup::fieldGroup
fieldGroup()
Construct null.
Definition: probes.H:118
surfaceMesh.H
Foam::probes::surfaceSymmTensorFields_
fieldGroup< symmTensor > surfaceSymmTensorFields_
Definition: probes.H:166
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::probes::loadFromFiles_
const bool loadFromFiles_
Load fields from files (not from objectRegistry)
Definition: probes.H:135
Foam::probes::read
virtual void read(const dictionary &)
Read the probes.
Definition: probes.C:364
Foam::probes::findElements
virtual void findElements(const fvMesh &)
Find cells and faces containing probes.
Definition: probes.C:43
Foam::probes::vectorFields_
fieldGroup< vector > vectorFields_
Definition: probes.H:157
Foam::polyMesh::readUpdateState
readUpdateState
Enumeration defining the state of the mesh after a read update.
Definition: polyMesh.H:88
pointField.H
Foam::probes::surfaceScalarFields_
fieldGroup< scalar > surfaceScalarFields_
Categorized scalar/vector/tensor surf fields.
Definition: probes.H:163
Foam::probes::probe
virtual const point & probe(const label i) const
Return location for probe i.
Definition: probes.H:277
Foam::probes::classifyFields
label classifyFields()
Classify field types, returns the number of fields.
Definition: probesGrouping.C:111
Foam::probes::operator=
void operator=(const probes &)
Disallow default bitwise assignment.
Foam::probes::surfaceTensorFields_
fieldGroup< tensor > surfaceTensorFields_
Definition: probes.H:167
Foam::probes::sampleAndWrite
void sampleAndWrite(const GeometricField< Type, fvPatchField, volMesh > &)
Sample and write a particular volume field.
Definition: probesTemplates.C:69
Foam::probes::probeLocations
virtual const pointField & probeLocations() const
Return locations to probe.
Definition: probes.H:271
Foam::HashPtrTable
A HashTable specialization for hashing pointers.
Definition: HashPtrTable.H:50
Foam::Vector< scalar >
wordReList.H
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::probes::name_
const word name_
Name of this set of probes,.
Definition: probes.H:129
Foam::probes::sampleAndWriteSurfaceFields
void sampleAndWriteSurfaceFields(const fieldGroup< Type > &)
Sample and write all the surface fields of the given type.
Definition: probesTemplates.C:165
Foam::probes::execute
virtual void execute()
Execute, currently does nothing.
Definition: probes.C:327
HashPtrTable.H
surfaceFieldsFwd.H
Foam::mapPolyMesh
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
Foam::probes::name
virtual const word & name() const
Return name of the set of probes.
Definition: probes.H:259
Foam::probes::interpolationScheme_
word interpolationScheme_
Interpolation scheme name.
Definition: probes.H:150
Foam::probes::movePoints
virtual void movePoints(const polyMesh &)
Update for changes of mesh.
Definition: probes.C:482
Foam::GeometricField
Generic GeometricField class.
Definition: surfaceFieldsFwd.H:52
Foam::probes::readDict
void readDict(const dictionary &dict)
Read dictionary settings.
Definition: probes.C:266
Foam::probes::~probes
virtual ~probes()
Destructor.
Definition: probes.C:321
Foam::probes::timeSet
virtual void timeSet()
Called when time was set at the end of the Time::operator++.
Definition: probes.C:339
Foam::probes::readUpdate
virtual void readUpdate(const polyMesh::readUpdateState state)
Update for changes of mesh due to readUpdate.
Definition: probes.H:310