patchProbes.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 | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2016 OpenFOAM Foundation
9 Copyright (C) 2016-2022 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Class
28 Foam::patchProbes
29
30Description
31 Set of locations to sample at patches
32
33 Call write() to sample and write files.
34 - find nearest location on nearest face
35 - update *this with location (so header contains 'snapped' locations
36 - use *this as the sampling location
37
38 Example of function object specification:
39 \verbatim
40 patchProbes
41 {
42 type patchProbes;
43 libs (sampling);
44
45 // Name of the directory for probe data
46 name patchProbes;
47
48 // Patches to sample (wildcards allowed)
49 patches (".*inl.*");
50
51 // Write at same frequency as fields
52 writeControl writeTime;
53 writeInterval 1;
54
55 // Fields to be probed
56 fields (p U);
57
58 // Locations to probe. These get snapped onto the nearest point
59 // on the selected patches
60 probeLocations
61 (
62 ( -100 0 0.01 ) // at inlet
63 );
64 }
65 \endverbatim
66
67SourceFiles
68 patchProbes.C
69 patchProbesTemplates.C
70
71\*---------------------------------------------------------------------------*/
72
73#ifndef Foam_patchProbes_H
74#define Foam_patchProbes_H
75
76#include "probes.H"
77
78// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
79
80namespace Foam
81{
82
83/*---------------------------------------------------------------------------*\
84 Class patchProbes Declaration
85\*---------------------------------------------------------------------------*/
87class patchProbes
88:
89 public probes
90{
91protected:
92
93 // Protected Data
94
95 //- Patches to sample
97
98
99 // Protected Member Functions
100
101 //- Find elements containing patchProbes
102 virtual void findElements(const fvMesh& mesh); // override
103
104
105private:
106
107 // Private Member Functions
108
109 //- Write field values
110 template<class Type>
111 void writeValues
112 (
113 const word& fieldName,
114 const Field<Type>& values,
115 const scalar timeValue
116 );
117
118 //- Sample and store/write applicable volume/surface fields
119 template<class GeoField>
120 void performAction
121 (
122 const fieldGroup<GeoField>& fieldNames, /* must be sorted */
123 unsigned request
124 );
125
126 //- Perform sampling action with store/write
127 bool performAction(unsigned request);
128
129
130 //- No copy construct
131 patchProbes(const patchProbes&) = delete;
132
133 //- No copy assignment
134 void operator=(const patchProbes&) = delete;
135
136
137public:
138
139 //- Runtime type information
140 TypeName("patchProbes");
141
142
143 // Constructors
144
145 //- Construct from Time and dictionary
147 (
148 const word& name,
149 const Time& runTime,
150 const dictionary& dict,
151 const bool loadFromFiles = false,
152 const bool readFields = true
153 );
154
155 //- Destructor
156 virtual ~patchProbes() = default;
157
158
159 // Member Functions
160
161 //- Sample and store result if the sampleOnExecute is enabled.
162 virtual bool execute();
163
164 //- Sample and write
165 virtual bool write();
166
167 //- Read
168 virtual bool read(const dictionary&);
169
170
171 // Sampling
172
173 //- Sample a volume field at all locations
174 template<class Type>
176
177 //- Sample a surface field at all locations
178 template<class Type>
180
181 //- Sample a single field on all sample locations
182 template<class Type>
183 tmp<Field<Type>> sample(const word& fieldName) const;
184
185 //- Sample a surface field at all locations
186 template<class Type>
187 tmp<Field<Type>> sampleSurfaceField(const word& fieldName) const;
188};
189
190
191// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
192
193} // End namespace Foam
194
195// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
196
197#ifdef NoRepository
198 #include "patchProbesTemplates.C"
199#endif
200
201// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
202
203#endif
204
205// ************************************************************************* //
Generic templated field type.
Definition: Field.H:82
Minimal example by using system/controlDict.functions:
Generic GeometricField class.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:80
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
const word & name() const noexcept
Return the name of this functionObject.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:91
Set of locations to sample at patches.
Definition: patchProbes.H:89
tmp< Field< Type > > sample(const SurfaceField< Type > &) const
Sample a surface field at all locations.
virtual void findElements(const fvMesh &mesh)
Find elements containing patchProbes.
Definition: patchProbes.C:53
TypeName("patchProbes")
Runtime type information.
virtual ~patchProbes()=default
Destructor.
tmp< Field< Type > > sample(const word &fieldName) const
Sample a single field on all sample locations.
tmp< Field< Type > > sampleSurfaceField(const word &fieldName) const
Sample a surface field at all locations.
wordRes patchNames_
Patches to sample.
Definition: patchProbes.H:95
virtual bool execute()
Sample and store result if the sampleOnExecute is enabled.
Definition: patchProbes.C:278
virtual bool write()
Sample and write.
Definition: patchProbes.C:289
tmp< Field< Type > > sample(const VolumeField< Type > &) const
Sample a volume field at all locations.
virtual bool read(const dictionary &)
Read.
Definition: patchProbes.C:295
Set of locations to sample.
Definition: probes.H:166
virtual const wordRes & fieldNames() const noexcept
Return names of fields to probe.
Definition: probes.H:335
A class for managing temporary objects.
Definition: tmp.H:65
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:54
A class for handling words, derived from Foam::string.
Definition: word.H:68
dynamicFvMesh & mesh
engineTime & runTime
Namespace for OpenFOAM.
void readFields(const typename GeoFieldType::Mesh &mesh, const IOobjectList &objects, const wordHashSet &selectedFields, LIFOStack< regIOobject * > &storedObjects)
Read the selected GeometricFields of the templated type.
dictionary dict
Grouping of field names by GeometricField type.
Definition: probes.H:173
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73