Loading...
Searching...
No Matches
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 | <time>/inputField
44 output file | - | -
45 output field | {vol,surface}<Type>Field | <time>/outputField
46 \endtable
47
48 where \c Type can be one of:
49 \c Scalar, \c Vector, \c SphericalTensor, \c SymmTensor, or \c Tensor.
50
51Usage
52 Minimal example by using \c system/controlDict.functions:
53 \verbatim
54 setFlowFO
55 {
56 // Mandatory entries
57 type setFlow;
58 libs (fieldFunctionObjects);
59 mode <word>;
60 scale <Function1<scalar>>;
61
62 // Optional entries
63 U <word>;
64 rho <word>;
65 phi <word>;
66 reverseTime <scalar>;
67
68 // Conditional entries
69
70 // when 'mode' is 'function'
71 velocity <Function1<vector>>;
72
73 // when 'mode' is 'rotation'
74 omega <Function1<scalar>>;
75 origin <vector>;
76 refDir <vector>;
77 axis <vector>;
78
79 // when 'mode' is 'vortex2D' or 'vortex3D'
80 origin <vector>;
81 refDir <vector>;
82 axis <vector>;
83
84 // Inherited entries
85 ...
86 }
87 \endverbatim
88
89 where the entries mean:
90 \table
91 Property | Description | Type | Reqd | Deflt
92 type | Type name: readFields | word | yes | -
93 libs | Library name: fieldFunctionObjects | word | yes | -
94 mode | Operating mode - see below | word | yes | -
95 scale | Scaling function | Function1<scalar> | yes | -
96 U | Name of velocity field | word | no | U
97 rho | Name of density field | word | no | none
98 phi | Name of flux field | word | no | phi
99 reverseTime <!--
100 --> | Specified time to reverse flow direction | scalar | no | VGREAT
101 velocity <!--
102 --> | Velocity function | Function1<vector> | conditional | -
103 omega <!--
104 --> | Rotational speed function | Function1<scalar> | conditional | -
105 origin <!--
106 --> | Rotation vector origin | vector | conditional | -
107 refDir <!--
108 --> | Rotation vector reference direction | vector | conditional | -
109 axis <!--
110 --> | Rotation vector axis | vector | conditional | -
111 \endtable
112
113 Options for the \c mode entry:
114 \verbatim
115 function | Uses a velocity function to set the flow field
116 rotation | Applies rotational flow based on specified parameters
117 vortex2D | Imposes a 2D vortex flow
118 vortex3D | Imposes a 3D vortex flow
119 \endverbatim
120
121 The inherited entries are elaborated in:
122 - \link functionObject.H \endlink
123
124SourceFiles
125 setFlow.C
126
127\*---------------------------------------------------------------------------*/
128
129#ifndef Foam_functionObjects_setFlow_H
130#define Foam_functionObjects_setFlow_H
131
132#include "fvMeshFunctionObject.H"
133#include "Function1.H"
134#include "Enum.H"
135#include "point.H"
136#include "volFieldsFwd.H"
137
138// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
139
140namespace Foam
141{
142namespace functionObjects
143{
144
145/*---------------------------------------------------------------------------*\
146 Class setFlow Declaration
147\*---------------------------------------------------------------------------*/
148
149class setFlow
150:
152{
153 // Private Enumerations
154
155 //- Options for the operating mode
156 enum class modeType
157 {
158 FUNCTION,
159 ROTATION,
160 VORTEX2D,
161 VORTEX3D
162 };
163
164 //- Names for modeType
165 static const Enum<modeType> modeTypeNames;
166
167
168 // Private Data
169
170 //- Operating mode
171 modeType mode_;
172
173 //- Name of velocity field
174 word UName_;
175
176 //- Name of density field
177 word rhoName_;
178
179 //- Name of flux field
180 word phiName_;
181
182 //- Reverse time
183 scalar reverseTime_;
184
185 //- Scaling function
186 autoPtr<Function1<scalar>> scalePtr_;
187
188
189 // Rotation
190
191 //- Origin
192 point origin_;
193
194 //- Rotation tensor for rotational mode
195 tensor R_;
196
197 //- Rotational speed function
198 autoPtr<Function1<scalar>> omegaPtr_;
199
200
201 // Function
202
203 //- Velocity function
204 autoPtr<Function1<vector>> velocityPtr_;
205
206
207 // Private Member Functions
208
209 //- Set the flux field
210 void setPhi(const volVectorField& U);
211
212
213public:
214
215 //- Runtime type information
216 TypeName("setFlow");
217
218
219 // Constructors
220
221 //- Construct from name, Time and dictionary
222 setFlow
223 (
224 const word& name,
225 const Time& runTime,
226 const dictionary& dict
227 );
228
229 //- No copy construct
230 setFlow(const setFlow&) = delete;
231
232 //- No copy assignment
233 void operator=(const setFlow&) = delete;
234
235
236 //- Destructor
237 virtual ~setFlow() = default;
238
239
240 // Member Functions
241
242 //- Read the function-object dictionary
243 virtual bool read(const dictionary& dict);
244
245 //- Execute the function-object operations
246 virtual bool execute();
247
248 //- Write the function-object results
249 virtual bool write();
250};
251
252
253// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
254
255} // End namespace functionObjects
256} // End namespace Foam
257
258// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
259
260#endif
261
262// ************************************************************************* //
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
Definition Enum.H:57
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition Time.H:75
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
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...
fvMeshFunctionObject(const fvMeshFunctionObject &)=delete
No copy construct.
Provides options to set the velocity and flux fields as a function of time.
Definition setFlow.H:259
setFlow(const word &name, const Time &runTime, const dictionary &dict)
Construct from name, Time and dictionary.
Definition setFlow.C:94
TypeName("setFlow")
Runtime type information.
virtual bool read(const dictionary &dict)
Read the function-object dictionary.
Definition setFlow.C:118
setFlow(const setFlow &)=delete
No copy construct.
virtual bool execute()
Execute the function-object operations.
Definition setFlow.C:192
virtual bool write()
Write the function-object results.
Definition setFlow.C:424
virtual ~setFlow()=default
Destructor.
void operator=(const setFlow &)=delete
No copy assignment.
A class for handling words, derived from Foam::string.
Definition word.H:66
U
Definition pEqn.H:72
engineTime & runTime
Function objects are OpenFOAM utilities to ease workflow configurations and enhance workflows.
Namespace for OpenFOAM.
GeometricField< vector, fvPatchField, volMesh > volVectorField
Tensor< scalar > tensor
Definition symmTensor.H:57
vector point
Point is a vector.
Definition point.H:37
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition exprTraits.C:127
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition typeInfo.H:68
Forwards and collection of common volume field types.