ddt2.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) 2016-2020 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26Class
27 Foam::functionObjects::ddt2
28
29Group
30 grpFieldFunctionObjects
31
32Description
33 Computes the magnitude or magnitude squared of the Eulerian time derivative
34 of an input volume field for time-variant simulations
35 (not appropriate to steady-state simulations).
36
37 The result can be further used for determining e.g. variance or RMS values.
38
39 Operands:
40 \table
41 Operand | Type | Location
42 input | vol<Type>Field | $FOAM_CASE/<time>/<inpField>
43 output file | - | -
44 output field | vol<Type>Field | $FOAM_CASE/<time>/<outField>
45 \endtable
46
47 where \c <Type>=Scalar/Vector/SphericalTensor/SymmTensor/Tensor.
48
49Usage
50 Minimal example by using \c system/controlDict.functions:
51 \verbatim
52 ddt21
53 {
54 // Mandatory entries (unmodifiable)
55 type ddt2;
56 libs (fieldFunctionObjects);
57
58 // Mandatory entries (runtime modifiable)
59 fields (<field1> <field2> ... <fieldN>);
60
61 // Optional entries (unmodifiable)
62 mag false;
63
64 // Optional entries (runtime modifiable)
65 result d@@dt2;
66
67 // Optional (inherited) entries
68 ...
69 }
70 \endverbatim
71
72 where the entries mean:
73 \table
74 Property | Description | Type | Req'd | Dflt
75 type | Type name: ddt2 | word | yes | -
76 libs | Library name: fieldFunctionObjects | word | yes | -
77 fields | Names of the operand fields | wordList | yes | -
78 mag | Compute 'mag' instead of 'magSqr' | bool | no | false
79 result | Name of results | word | no | magSqr(ddt2(@@))
80 \endtable
81
82 The inherited entries are elaborated in:
83 - \link functionObject.H \endlink
84
85 A list of fields can contain exact names or regular expressions.
86 The token '\@\@' in the result name is replaced by the name of the source
87 field. In the special case of a single source field (specified as
88 a non-regex), the '\@\@' token checking is suppressed.
89
90 The function object will skip over fields that appear to have
91 already been processed (ie, their names are similar to the output names).
92
93 Usage by the \c postProcess utility is not available.
94
95See also
96 - Foam::functionObject
97 - Foam::functionObjects::fvMeshFunctionObject
98 - ExtendedCodeGuide::functionObjects::field::ddt2
99
100SourceFiles
101 ddt2.C
102 ddt2Templates.C
103
104\*---------------------------------------------------------------------------*/
105
106#ifndef functionObjects_ddt2_H
107#define functionObjects_ddt2_H
108
109#include "fvMeshFunctionObject.H"
110#include "volFieldsFwd.H"
111#include "OFstream.H"
112#include "regExp.H"
113#include "HashSet.H"
114#include "wordRes.H"
115
116// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
117
118namespace Foam
119{
120namespace functionObjects
121{
122
123/*---------------------------------------------------------------------------*\
124 Class ddt2 Declaration
125\*---------------------------------------------------------------------------*/
126
127class ddt2
128:
129 public fvMeshFunctionObject
130{
131 // Private Data
132
133 //- Name of fields to process
134 wordRes selectFields_;
135
136 //- Formatting for the result fields
137 word resultName_;
138
139 //- Avoid processing the same field twice
140 mutable regExp denyField_;
141
142 //- Hashed names of result fields
143 wordHashSet results_;
144
145 //- Flat to use 'mag' instead of 'magSqr'
146 // Cannot be adjusted during the simulation since it alters the
147 // dimensions of the output field
148 const bool mag_;
149
150
151 // Private Member Functions
152
153 //- Check that string contains the appropriate substitution token(s)
154 static bool checkFormatName(const std::string& str);
155
156
157 //- Accept unless field name appears to have already been processed
158 bool accept(const word& fieldName) const;
159
160 //- Apply for the volume field type
161 template<class FieldType>
162 int apply(const word& inputName, int& state);
163
164 //- Process by trying to apply for various volume field types
165 int process(const word& inputName);
166
167
168public:
169
170 //- Runtime type information
171 TypeName("ddt2");
172
173
174 // Constructors
175
176 //- Construct from Time and dictionary
177 ddt2
179 const word& name,
180 const Time& runTime,
181 const dictionary& dict
182 );
183
184 //- No copy construct
185 ddt2(const ddt2&) = delete;
186
187 //- No copy assignment
188 void operator=(const ddt2&) = delete;
189
190
191 //- Destructor
192 virtual ~ddt2() = default;
193
194
195 // Member Functions
196
197 //- Read the ddt2 specification
198 virtual bool read(const dictionary&);
199
200 //- Calculate the ddt2 fields
201 virtual bool execute();
202
203 //- Write the ddt2 fields
204 virtual bool write();
205};
206
207
208// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
209
210} // End namespace functionObjects
211} // End namespace Foam
212
213// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
214
215#ifdef NoRepository
216 #include "ddt2Templates.C"
217#endif
218
219// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
220
221#endif
223// ************************************************************************* //
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.
Computes the magnitude or magnitude squared of the Eulerian time derivative of an input volume field ...
Definition: ddt2.H:181
TypeName("ddt2")
Runtime type information.
virtual ~ddt2()=default
Destructor.
ddt2(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
Definition: ddt2.C:103
ddt2(const ddt2 &)=delete
No copy construct.
void operator=(const ddt2 &)=delete
No copy assignment.
virtual bool execute()
Calculate the ddt2 fields.
Definition: ddt2.C:166
virtual bool write()
Write the ddt2 fields.
Definition: ddt2.C:212
virtual bool read(const dictionary &)
Read the ddt2 specification.
Definition: ddt2.C:122
Specialization of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
Wrapper around C++11 regular expressions with some additional prefix-handling. The prefix-handling is...
Definition: regExpCxx.H:83
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
engineTime & runTime
Namespace for OpenFOAM.
HashSet< word, Hash< word > > wordHashSet
A HashSet of words, uses string hasher.
Definition: HashSet.H:82
regExpCxx regExp
Selection of preferred regular expression implementation.
Definition: regExpFwd.H:43
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73