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-2020 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
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 
27 Class
28  Foam::patchProbes
29 
30 Description
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 
67 
68 SourceFiles
69  patchProbes.C
70 
71 \*---------------------------------------------------------------------------*/
72 
73 #ifndef patchProbes_H
74 #define patchProbes_H
75 
76 #include "probes.H"
77 
78 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
79 
80 namespace Foam
81 {
82 
83 // Forward declaration of classes
84 class objectRegistry;
85 class dictionary;
86 class fvMesh;
87 class mapPolyMesh;
88 
89 /*---------------------------------------------------------------------------*\
90  Class patchProbes Declaration
91 \*---------------------------------------------------------------------------*/
92 
93 class patchProbes
94 :
95  public probes
96 {
97 protected:
98 
99  // Protected data
100 
101  //- Patches to sample
103 
104 
105  // Protected Member Functions
106 
107  //- Sample and write a particular volume field
108  template<class Type>
109  void sampleAndWrite
110  (
112  );
113 
114  //- Sample and write a particular surface field
115  template<class Type>
116  void sampleAndWrite
117  (
119  );
120 
121  //- Sample and write all the fields of the given type
122  template<class Type>
123  void sampleAndWrite(const fieldGroup<Type>&);
124 
125  //- Sample and write all the surface fields of the given type
126  template<class Type>
128 
129  //- Sample a volume field at all locations
130  template<class Type>
132  (
134  ) const;
135 
136  //- Sample a surface field at all locations
137  template<class Type>
139  (
141  ) const;
142 
143  //- Sample a single field on all sample locations
144  template<class Type>
145  tmp<Field<Type>> sample(const word& fieldName) const;
146 
147  //- Find elements containing patchProbes
148  virtual void findElements(const fvMesh&);
149 
150 
151 private:
152 
153  //- No copy construct
154  patchProbes(const patchProbes&) = delete;
155 
156  //- No copy assignment
157  void operator=(const patchProbes&) = delete;
158 
159 
160 public:
161 
162  //- Runtime type information
163  TypeName("patchProbes");
164 
165 
166  // Constructors
167 
168  //- Construct from Time and dictionary
170  (
171  const word& name,
172  const Time& time,
173  const dictionary& dict,
174  const bool loadFromFiles = false,
175  const bool readFields = true
176  );
177 
178  //- Destructor
179  virtual ~patchProbes() = default;
180 
181 
182  //- Public members
183 
184  //- Sample and write
185  virtual bool write();
186 
187  //- Read
188  virtual bool read(const dictionary&);
189 };
190 
191 
192 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
193 
194 } // End namespace Foam
195 
196 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
197 
198 #ifdef NoRepository
199  #include "patchProbesTemplates.C"
200 #endif
201 
202 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
203 
204 #endif
205 
206 // ************************************************************************* //
Foam::patchProbes::findElements
virtual void findElements(const fvMesh &)
Find elements containing patchProbes.
Definition: patchProbes.C:53
Foam::patchProbes::~patchProbes
virtual ~patchProbes()=default
Destructor.
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:73
Foam::patchProbes
Set of locations to sample at patches.
Definition: patchProbes.H:92
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::patchProbes::read
virtual bool read(const dictionary &)
Read.
Definition: patchProbes.C:277
probes.H
Foam::probes::fieldGroup
Class used for grouping field types.
Definition: probes.H:121
patchProbesTemplates.C
Foam::patchProbes::sample
tmp< Field< Type > > sample(const GeometricField< Type, fvPatchField, volMesh > &) const
Sample a volume field at all locations.
Foam::probes
Set of locations to sample.
Definition: probes.H:110
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::patchProbes::sampleAndWriteSurfaceFields
void sampleAndWriteSurfaceFields(const fieldGroup< Type > &)
Sample and write all the surface fields of the given type.
Definition: patchProbesTemplates.C:141
Foam::functionObject::name
const word & name() const noexcept
Return the name of this functionObject.
Definition: functionObject.C:143
Foam::functionObjects::timeFunctionObject::time
const Time & time() const
Return time database.
Definition: timeFunctionObject.H:96
Foam::wordRes
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:51
Foam::functionObjects::readFields
Reads fields from the time directories and adds them to the mesh database for further post-processing...
Definition: readFields.H:155
Foam::patchProbes::TypeName
TypeName("patchProbes")
Runtime type information.
Foam::patchProbes::sampleAndWrite
void sampleAndWrite(const GeometricField< Type, fvPatchField, volMesh > &)
Sample and write a particular volume field.
Definition: patchProbesTemplates.C:37
Foam::GeometricField< Type, fvPatchField, volMesh >
Foam::patchProbes::patchNames_
wordRes patchNames_
Patches to sample.
Definition: patchProbes.H:101
Foam::patchProbes::write
virtual bool write()
Public members.
Definition: patchProbes.C:256