probes.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-2026 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 Description
28  Set of locations to sample.
29 
30  Call write() to sample and write files.
31 
32 SourceFiles
33  probes.C
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef probes_H
38 #define probes_H
39 
40 #include "functionObject.H"
41 #include "HashPtrTable.H"
42 #include "OFstream.H"
43 #include "polyMesh.H"
44 #include "pointField.H"
45 #include "volFieldsFwd.H"
46 #include "surfaceFieldsFwd.H"
47 
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 
50 namespace Foam
51 {
52 
53 // Forward declaration of classes
54 class Time;
55 class objectRegistry;
56 class dictionary;
57 class fvMesh;
58 class polyTopoChangeMap;
59 
60 /*---------------------------------------------------------------------------*\
61  Class probes Declaration
62 \*---------------------------------------------------------------------------*/
63 
64 class probes
65 :
66  public functionObject
67 {
68 protected:
69 
70  // Protected classes
71 
72  //- Class used for grouping field types
73  template<class Type>
74  class fieldGroup
75  :
76  public DynamicList<word>
77  {
78  public:
79 
80  //- Construct null
81  fieldGroup()
82  :
83  DynamicList<word>(0)
84  {}
85  };
86 
87 
88  // Protected Data
89 
90  //- Const reference to fvMesh
91  const fvMesh& mesh_;
92 
93 
94  // Read from dictionary
95 
96  //- Probe locations
98 
99  //- Names of fields to probe
101 
102  //- Fixed locations, default = yes
103  // Note: set to false for moving mesh calculations where locations
104  // should move with the mesh
105  bool fixedLocations_;
106 
107  //- Interpolation scheme name
108  // Note: only possible when fixedLocations_ is true
110 
111 
112  // Calculated
113 
114  //- Categorised scalar/vector/tensor vol fields
120 
121  //- Categorised scalar/vector/tensor surf fields
127 
128  // Cells to be probed (obtained from the locations)
130 
131  // Faces to be probed
133 
134  //- Current open files
136 
137 
138  // Protected Member Functions
139 
140  //- Clear old field groups
141  void clearFieldGroups();
142 
143  //- Append fieldName to the appropriate group
144  label appendFieldGroup(const word& fieldName, const word& fieldType);
145 
146  //- Classify field types, returns the number of fields
148 
149  //- Find cells and faces containing probes
150  virtual void findElements(const fvMesh&);
151 
152  //- Classify field type and Open/close file streams,
153  // returns number of fields to sample
154  label prepare();
155 
156 
157 private:
158 
159  //- Sample and write a particular volume field
160  template<class Type>
161  void sampleAndWrite(const VolField<Type>&);
162 
163  //- Sample and write a particular surface field
164  template<class Type>
165  void sampleAndWrite(const SurfaceField<Type>&);
166 
167  //- Sample and write all the fields of the given type
168  template<class Type>
169  void sampleAndWrite(const fieldGroup<Type>&);
170 
171  //- Sample and write all the surface fields of the given type
172  template<class Type>
173  void sampleAndWriteSurfaceFields(const fieldGroup<Type>&);
174 
175  //- Sample a volume field at all locations
176  template<class Type>
177  tmp<Field<Type>> sample(const VolField<Type>&) const;
178 
179  //- Sample a surface field at all locations
180  template<class Type>
181  tmp<Field<Type>> sample(const SurfaceField<Type>&) const;
182 
183  //- Sample a single vol field on all sample locations
184  template<class Type>
185  tmp<Field<Type>> sample(const word& fieldName) const;
186 
187  //- Sample a single surface field on all sample locations
188  template<class Type>
189  tmp<Field<Type>> sampleSurfaceFields(const word& fieldName) const;
190 
191 
192 public:
193 
194  //- Runtime type information
195  TypeName("probes");
196 
197 
198  // Constructors
199 
200  //- Construct from Time and dictionary
201  probes
202  (
203  const word& name,
204  const Time& time,
205  const dictionary& dict,
206  const bool initialise = true
207  );
208 
209  //- Disallow default bitwise copy construction
210  probes(const probes&) = delete;
211 
212 
213  //- Destructor
214  virtual ~probes();
215 
216 
217  // Member Functions
218 
219  //- Return the list of fields required
220  virtual wordList fields() const;
221 
222  //- Read the probes
223  bool read(const dictionary&, const bool initialise);
224 
225  //- Read the probes
226  virtual bool read(const dictionary&);
227 
228  //- Execute, currently does nothing
229  virtual bool execute();
230 
231  //- Sample and write
232  virtual bool write();
233 
234  //- Update topology using the given map
235  virtual void movePoints(const polyMesh&);
236 
237  //- Update topology using the given map
238  virtual void topoChange(const polyTopoChangeMap&);
239 
240  //- Update from another mesh using the given map
241  virtual void mapMesh(const polyMeshMap&);
242 
243  //- Update using the given distribution map
244  virtual void distribute(const polyDistributionMap&);
245 
246 
247  // Member Operators
248 
249  //- Disallow default bitwise assignment
250  void operator=(const probes&) = delete;
251 };
252 
253 
254 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
255 
256 } // End namespace Foam
257 
258 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
259 
260 #ifdef NoRepository
261  #include "probesTemplates.C"
262 #endif
263 
264 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
265 
266 #endif
267 
268 // ************************************************************************* //
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition: DynamicList.H:78
Generic GeometricField class.
A HashTable specialisation for hashing pointers.
Definition: HashPtrTable.H:68
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:76
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
Abstract base-class for Time/database functionObjects.
const word & name() const
Return the name of this functionObject.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:98
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
Class containing mesh-to-mesh mapping information.
Definition: polyMeshMap.H:51
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:78
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Class used for grouping field types.
Definition: probes.H:76
fieldGroup()
Construct null.
Definition: probes.H:80
Set of locations to sample.
Definition: probes.H:66
fieldGroup< symmTensor > surfaceSymmTensorFields_
Definition: probes.H:124
HashPtrTable< OFstream > probeFilePtrs_
Current open files.
Definition: probes.H:134
virtual ~probes()
Destructor.
Definition: probes.C:290
void operator=(const probes &)=delete
Disallow default bitwise assignment.
fieldGroup< tensor > tensorFields_
Definition: probes.H:118
const fvMesh & mesh_
Const reference to fvMesh.
Definition: probes.H:90
labelList cellList_
Definition: probes.H:128
void clearFieldGroups()
Clear old field groups.
pointField locations_
Probe locations.
Definition: probes.H:96
label classifyFields()
Classify field types, returns the number of fields.
TypeName("probes")
Runtime type information.
virtual wordList fields() const
Return the list of fields required.
Definition: probes.C:332
fieldGroup< tensor > surfaceTensorFields_
Definition: probes.H:125
virtual void topoChange(const polyTopoChangeMap &)
Update topology using the given map.
Definition: probes.C:378
label prepare()
Classify field type and Open/close file streams,.
Definition: probes.C:170
virtual void distribute(const polyDistributionMap &)
Update using the given distribution map.
Definition: probes.C:468
fieldGroup< symmTensor > symmTensorFields_
Definition: probes.H:117
fieldGroup< sphericalTensor > surfaceSphericalTensorFields_
Definition: probes.H:123
wordList fields_
Names of fields to probe.
Definition: probes.H:99
probes(const word &name, const Time &time, const dictionary &dict, const bool initialise=true)
Construct from Time and dictionary.
Definition: probes.C:262
fieldGroup< scalar > surfaceScalarFields_
Categorised scalar/vector/tensor surf fields.
Definition: probes.H:121
virtual void findElements(const fvMesh &)
Find cells and faces containing probes.
Definition: probes.C:53
bool read(const dictionary &, const bool initialise)
Read the probes.
Definition: probes.C:296
fieldGroup< vector > surfaceVectorFields_
Definition: probes.H:122
bool fixedLocations_
Fixed locations, default = yes.
Definition: probes.H:104
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
Definition: probes.C:458
virtual void movePoints(const polyMesh &)
Update topology using the given map.
Definition: probes.C:365
fieldGroup< scalar > scalarFields_
Categorised scalar/vector/tensor vol fields.
Definition: probes.H:114
labelList faceList_
Definition: probes.H:131
word interpolationScheme_
Interpolation scheme name.
Definition: probes.H:108
label appendFieldGroup(const word &fieldName, const word &fieldType)
Append fieldName to the appropriate group.
fieldGroup< sphericalTensor > sphericalTensorFields_
Definition: probes.H:116
virtual bool execute()
Execute, currently does nothing.
Definition: probes.C:338
virtual bool write()
Sample and write.
Definition: probes.C:344
fieldGroup< vector > vectorFields_
Definition: probes.H:115
A class for managing temporary objects.
Definition: tmp.H:55
A class for handling words, derived from string.
Definition: word.H:63
const dimensionSet time
Namespace for OpenFOAM.
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
dictionary dict