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 -------------------------------------------------------------------------------
10 License
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 
26 Class
27  Foam::functionObjects::ddt2
28 
29 Group
30  grpFieldFunctionObjects
31 
32 Description
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 
49 Usage
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 
95 See also
96  - Foam::functionObject
97  - Foam::functionObjects::fvMeshFunctionObject
98  - ExtendedCodeGuide::functionObjects::field::ddt2
99 
100 SourceFiles
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 
118 namespace Foam
119 {
120 namespace functionObjects
121 {
122 
123 /*---------------------------------------------------------------------------*\
124  Class ddt2 Declaration
125 \*---------------------------------------------------------------------------*/
126 
127 class 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  //- Accept unless field name appears to have already been processed
154  bool accept(const word& fieldName) const;
155 
156  //- Apply for the volume field type
157  template<class FieldType>
158  int apply(const word& inputName, int& state);
159 
160  //- Process by trying to apply for various volume field types
161  int process(const word& inputName);
162 
163 
164 public:
165 
166  //- Runtime type information
167  TypeName("ddt2");
168 
169 
170  // Constructors
171 
172  //- Construct from Time and dictionary
173  ddt2
174  (
175  const word& name,
176  const Time& runTime,
177  const dictionary& dict
178  );
179 
180  //- No copy construct
181  ddt2(const ddt2&) = delete;
182 
183  //- No copy assignment
184  void operator=(const ddt2&) = delete;
185 
186 
187  //- Destructor
188  virtual ~ddt2() = default;
189 
190 
191  // Member Functions
192 
193  //- Read the ddt2 specification
194  virtual bool read(const dictionary&);
195 
196  //- Calculate the ddt2 fields
197  virtual bool execute();
198 
199  //- Write the ddt2 fields
200  virtual bool write();
201 };
202 
203 
204 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
205 
206 } // End namespace functionObjects
207 } // End namespace Foam
208 
209 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
210 
211 #ifdef NoRepository
212  #include "ddt2Templates.C"
213 #endif
214 
215 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
216 
217 #endif
218 
219 // ************************************************************************* //
dictionary dict
virtual bool execute()
Calculate the ddt2 fields.
Definition: ddt2.C:164
Forwards and collection of common volume field types.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
ddt2(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
Definition: ddt2.C:101
virtual ~ddt2()=default
Destructor.
virtual bool write()
Write the ddt2 fields.
Definition: ddt2.C:211
engineTime & runTime
regExpPosix regExp
Selection of preferred regular expression implementation.
Definition: regExpFwd.H:36
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:69
virtual bool read(const dictionary &)
Read the ddt2 specification.
Definition: ddt2.C:120
const word & name() const noexcept
Return the name of this functionObject.
void operator=(const ddt2 &)=delete
No copy assignment.
A class for handling words, derived from Foam::string.
Definition: word.H:63
HashSet< word, Hash< word > > wordHashSet
A HashSet of words, uses string hasher.
Definition: HashSet.H:73
Computes the magnitude or magnitude squared of the Eulerian time derivative of an input volume field ...
Definition: ddt2.H:174
TypeName("ddt2")
Runtime type information.
Namespace for OpenFOAM.