setFlow.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) 2017-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::setFlow
28
29Group
30 grpFieldFunctionObjects
31
32Description
33 Provides options to set the velocity and flux fields as a function of time.
34
35 Useful for testing advection behaviour of numerical schemes by e.g.
36 imposing solid body rotation, vortex flows. All types include a scaling
37 \c Function1 type enabling the strength of the transformation to vary
38 as a function of time.
39
40 Operands:
41 \table
42 Operand | Type | Location
43 input | {vol,surface}<Type>Field <!--
44 --> | $FOAM_CASE/<time>/<inpField>
45 output file | - | -
46 output field | {vol,surface}<Type>Field <!--
47 --> | $FOAM_CASE/<time>/<outField>
48 \endtable
49
50 where \c <Type>=Scalar/Vector/SphericalTensor/SymmTensor/Tensor.
51
52Usage
53 Minimal example by using \c system/controlDict.functions:
54 \verbatim
55 setFlow1
56 {
57 // Mandatory entries (unmodifiable)
58 type setFlow;
59 libs (fieldFunctionObjects);
60
61 // Mandatory entries (runtime modifiable)
62 mode rotation;
63 scale 1;
64
65 // Optional entries (runtime modifiable)
66 U U;
67 rho none;
68 phi phi;
69 reverseTime 1;
70
71 // When mode=function
72 velocity (1 0 0);
73
74 // When mode=rotation
75 omega 6.28318530718;
76 origin (0.5 0 0.5);
77 refDir (1 0 0);
78 axis (0 1 0);
79
80 // When mode=(vortex2D|vortex3D)
81 origin (0.5 0 0.5);
82 refDir (1 0 0);
83 axis (0 1 0);
84
85 // Optional (inherited) entries
86 ...
87 }
88 \endverbatim
89
90 where the entries mean:
91 \table
92 Property | Description | Type | Req'd | Dflt
93 type | Type name: readFields | word | yes | -
94 libs | Library name: fieldFunctionObjects | word | yes | -
95 mode | Operating mode - see below | word | yes | -
96 scale | Scaling function | Function1<scalar> | yes | -
97 U | Name of velocity field | word | no | U
98 rho | Name of density field | word | no | none
99 phi | Name of flux field | word | no | phi
100 reverseTime <!--
101 --> | Specified time to reverse flow direction | scalar | no | VGREAT
102 velocity <!--
103 --> | Velocity function | Function1<vector> | conditional | -
104 omega <!--
105 --> | Rotational speed function | Function1<scalar> | conditional | -
106 origin <!--
107 --> | Rotation vector origin | vector | conditional | -
108 refDir <!--
109 --> | Rotation vector reference direction | vector | conditional | -
110 axis <!--
111 --> | Rotation vector axis | vector | conditional | -
112 \endtable
113
114 Options for the \c mode entry:
115 \verbatim
116 function
117 rotation
118 vortex2D
119 vortex3D
120 \endverbatim
121
122 The inherited entries are elaborated in:
123 - \link functionObject.H \endlink
124
125 Usage by the \c postProcess utility is not available.
126
127See also
128 - Foam::functionObject
129 - Foam::functionObjects::fvMeshFunctionObject
130 - ExtendedCodeGuide::functionObjects::field::setFlow
131
132SourceFiles
133 setFlow.C
134
135\*---------------------------------------------------------------------------*/
136
137#ifndef functionObjects_setFlow_H
138#define functionObjects_setFlow_H
139
140#include "fvMeshFunctionObject.H"
141#include "Function1.H"
142#include "Enum.H"
143#include "point.H"
144#include "volFieldsFwd.H"
145
146// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
147
148namespace Foam
149{
150namespace functionObjects
151{
152
153/*---------------------------------------------------------------------------*\
154 Class setFlow Declaration
155\*---------------------------------------------------------------------------*/
156
157class setFlow
158:
159 public fvMeshFunctionObject
160{
161 // Private Enumerations
162
163 //- Options for the operating mode
164 enum class modeType
165 {
166 FUNCTION,
167 ROTATION,
168 VORTEX2D,
169 VORTEX3D
170 };
171
172 //- Names for modeType
173 static const Enum<modeType> modeTypeNames;
174
175
176 // Private Data
177
178 //- Operating mode
179 modeType mode_;
180
181 //- Name of velocity field
182 word UName_;
183
184 //- Name of density field
185 word rhoName_;
186
187 //- Name of flux field
188 word phiName_;
189
190 //- Reverse time
191 scalar reverseTime_;
192
193 //- Scaling function
194 autoPtr<Function1<scalar>> scalePtr_;
195
196
197 // Rotation
198
199 //- Origin
200 point origin_;
201
202 //- Rotation tensor for rotational mode
203 tensor R_;
204
205 //- Rotational speed function
206 autoPtr<Function1<scalar>> omegaPtr_;
207
208
209 // Function
210
211 //- Velocity function
212 autoPtr<Function1<vector>> velocityPtr_;
213
214
215 // Private Member Functions
216
217 //- Set the flux field
218 void setPhi(const volVectorField& U);
219
220
221public:
222
223 //- Runtime type information
224 TypeName("setFlow");
225
226
227 // Constructors
228
229 //- Construct from Time and dictionary
230 setFlow
231 (
232 const word& name,
233 const Time& runTime,
234 const dictionary& dict
235 );
236
237 //- No copy construct
238 setFlow(const setFlow&) = delete;
239
240 //- No copy assignment
241 void operator=(const setFlow&) = delete;
242
243
244 //- Destructor
245 virtual ~setFlow() = default;
246
247
248 // Member Functions
249
250 //- Read the setFlow data
251 virtual bool read(const dictionary& dict);
252
253 //- Do nothing
254 virtual bool execute();
255
256 //- Calculate the setFlow and write
257 virtual bool write();
258};
259
260
261// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
262
263} // End namespace functionObjects
264} // End namespace Foam
265
266// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
267
268#endif
269
270// ************************************************************************* //
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
Definition: Enum.H:61
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:80
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
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.
Specialization of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
Provides options to set the velocity and flux fields as a function of time.
Definition: setFlow.H:275
setFlow(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
Definition: setFlow.C:101
TypeName("setFlow")
Runtime type information.
virtual bool read(const dictionary &dict)
Read the setFlow data.
Definition: setFlow.C:125
setFlow(const setFlow &)=delete
No copy construct.
virtual bool execute()
Do nothing.
Definition: setFlow.C:199
virtual bool write()
Calculate the setFlow and write.
Definition: setFlow.C:418
virtual ~setFlow()=default
Destructor.
void operator=(const setFlow &)=delete
No copy assignment.
Tensor of scalars, i.e. Tensor<scalar>.
A class for handling words, derived from Foam::string.
Definition: word.H:68
U
Definition: pEqn.H:72
engineTime & runTime
Namespace for OpenFOAM.
GeometricField< vector, fvPatchField, volMesh > volVectorField
Definition: volFieldsFwd.H:83
vector point
Point is a vector.
Definition: point.H:43
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73