meanVelocityForce.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-2017 OpenFOAM Foundation
9 Copyright (C) 2020 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
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
27Class
28 Foam::fv::meanVelocityForce
29
30Group
31 grpFvOptionsSources
32
33Description
34 Applies the force within a specified region to maintain
35 the specified mean velocity for incompressible flows.
36
37 Sources applied to:
38 \verbatim
39 U | Velocity [m/s]
40 \endverbatim
41
42 Required fields:
43 \verbatim
44 U | Velocity [m/s]
45 \endverbatim
46
47Usage
48 Minimal example by using \c constant/fvOptions:
49 \verbatim
50 meanVelocityForce1
51 {
52 // Mandatory entries (unmodifiable)
53 type meanVelocityForce;
54
55 // Mandatory entries (unmodifiable)
56 Ubar (1 0 0);
57 fields (<fieldName>);
58
59 // Optional entries (unmodifiable)
60 relaxation 1.0;
61
62 // Conditional mandatory entries (unmodifiable)
63
64 // when <timePath>/uniform/<name>Properties file exists
65 gradient <vectorField>; // reading from the aforementioned file
66
67 // Mandatory/Optional (inherited) entries
68 ...
69 }
70 \endverbatim
71
72 where the entries mean:
73 \table
74 Property | Description | Type | Reqd | Dflt
75 type | Type name: meanVelocityForce | word | yes | -
76 Ubar | Desired mean velocity | vector | yes | -
77 fields | Name of operand velocity field | word | yes | -
78 relaxation | Relaxation factor | scalar | no | 1
79 gradient | Initial pressure gradient field | vectorField | cndtnl | -
80 \endtable
81
82 The inherited entries are elaborated in:
83 - \link fvOption.H \endlink
84 - \link cellSetOption.H \endlink
85
86Note
87 - Currently only handles kinematic pressure (incompressible solvers).
88
89SourceFiles
90 meanVelocityForce.C
91
92\*---------------------------------------------------------------------------*/
93
94#ifndef meanVelocityForce_H
95#define meanVelocityForce_H
96
97#include "autoPtr.H"
98#include "fvMesh.H"
99#include "volFields.H"
100#include "cellSetOption.H"
101
102// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
103
104namespace Foam
105{
106namespace fv
107{
108
109/*---------------------------------------------------------------------------*\
110 Class meanVelocityForce Declaration
111\*---------------------------------------------------------------------------*/
112
113class meanVelocityForce
114:
115 public fv::cellSetOption
116{
117protected:
118
119 // Protected Data
120
121 //- Desired mean velocity
123
124 //- Pressure gradient before correction
125 scalar gradP0_;
126
127 //- Change in pressure gradient
128 scalar dGradP_;
129
130 //- Flow direction
132
133 //- Relaxation factor
134 scalar relaxation_;
135
136 //- Matrix 1/A coefficients field pointer
137 autoPtr<volScalarField> rAPtr_;
138
139
140 // Protected Member Functions
141
142 //- Calculate and return the magnitude of the mean velocity
143 //- averaged over the selected cellSet
144 virtual scalar magUbarAve(const volVectorField& U) const;
145
146 //- Write the pressure gradient to file (for restarts etc)
147 void writeProps(const scalar gradP) const;
149 //- Correct driving force for a constant mass flow rate
150 void update(fvMatrix<vector>& eqn);
151
152
153public:
154
155 //- Runtime type information
156 TypeName("meanVelocityForce");
158
159 // Constructors
161 //- Construct from explicit source name and mesh
164 const word& sourceName,
165 const word& modelType,
167 const fvMesh& mesh
168 );
170 //- No copy construct
171 meanVelocityForce(const meanVelocityForce&) = delete;
173 //- No copy assignment
174 void operator=(const meanVelocityForce&) = delete;
175
176
177 //- Destructor
178 virtual ~meanVelocityForce() = default;
179
180
181 // Member Functions
182
183 // Evaluation
184
185 //- Correct the pressure gradient
186 virtual void correct(volVectorField& U);
187
188 //- Add explicit contribution to momentum equation
189 virtual void addSup
190 (
192 const label fieldi
193 );
194
195 //- Add explicit contribution to compressible momentum equation
196 virtual void addSup
197 (
198 const volScalarField& rho,
199 fvMatrix<vector>& eqn,
200 const label fieldi
201 );
202
203 //- Set 1/A coefficient
204 virtual void constrain
205 (
207 const label fieldi
208 );
210
211 // IO
212
213 //- Read source dictionary
214 virtual bool read(const dictionary& dict);
215};
216
217
218// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
219
220} // End namespace fv
221} // End namespace Foam
222
223// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
224
225#endif
226
227// ************************************************************************* //
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
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvMatrix.H:121
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:91
Intermediate abstract class for handling cell-set options for the derived fvOptions.
Applies the force within a specified region to maintain the specified mean velocity for incompressibl...
vector Ubar_
Desired mean velocity.
void operator=(const meanVelocityForce &)=delete
No copy assignment.
TypeName("meanVelocityForce")
Runtime type information.
meanVelocityForce(const meanVelocityForce &)=delete
No copy construct.
virtual bool read(const dictionary &dict)
Read source dictionary.
scalar dGradP_
Change in pressure gradient.
autoPtr< volScalarField > rAPtr_
Matrix 1/A coefficients field pointer.
virtual void constrain(fvMatrix< vector > &eqn, const label fieldi)
Set 1/A coefficient.
scalar gradP0_
Pressure gradient before correction.
virtual ~meanVelocityForce()=default
Destructor.
scalar relaxation_
Relaxation factor.
virtual void addSup(fvMatrix< vector > &eqn, const label fieldi)
Add explicit contribution to momentum equation.
void writeProps(const scalar gradP) const
Write the pressure gradient to file (for restarts etc)
virtual scalar magUbarAve(const volVectorField &U) const
void update(fvMatrix< vector > &eqn)
Correct driving force for a constant mass flow rate.
vector flowDir_
Flow direction.
const fvMesh & mesh() const noexcept
Return const access to the mesh database.
Definition: fvOptionI.H:37
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
A class for handling words, derived from Foam::string.
Definition: word.H:68
U
Definition: pEqn.H:72
thermo correct()
volVectorField gradP(fvc::grad(p))
mesh update()
Namespace for OpenFOAM.
GeometricField< vector, fvPatchField, volMesh > volVectorField
Definition: volFieldsFwd.H:83
labelList fv(nPoints)
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73