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 -------------------------------------------------------------------------------
11 License
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 
27 Class
28  Foam::fv::meanVelocityForce
29 
30 Group
31  grpFvOptionsSources
32 
33 Description
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 
47 Usage
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 
86 Note
87  - Currently only handles kinematic pressure (incompressible solvers).
88 
89 SourceFiles
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 
104 namespace Foam
105 {
106 namespace fv
107 {
108 
109 /*---------------------------------------------------------------------------*\
110  Class meanVelocityForce Declaration
111 \*---------------------------------------------------------------------------*/
112 
113 class meanVelocityForce
114 :
115  public fv::cellSetOption
116 {
117 protected:
118 
119  // Protected Data
120 
121  //- Desired mean velocity
122  vector Ubar_;
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;
148 
149  //- Correct driving force for a constant mass flow rate
150  void update(fvMatrix<vector>& eqn);
151 
152 
153 public:
154 
155  //- Runtime type information
156  TypeName("meanVelocityForce");
157 
158 
159  // Constructors
160 
161  //- Construct from explicit source name and mesh
163  (
164  const word& sourceName,
165  const word& modelType,
166  const dictionary& dict,
167  const fvMesh& mesh
168  );
169 
170  //- No copy construct
171  meanVelocityForce(const meanVelocityForce&) = delete;
172 
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  (
191  fvMatrix<vector>& eqn,
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  (
206  fvMatrix<vector>& eqn,
207  const label fieldi
208  );
209 
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 // ************************************************************************* //
volFields.H
gradP
volVectorField gradP(fvc::grad(p))
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::fv::cellSetOption
Intermediate abstract class for handling cell-set options for the derived fvOptions.
Definition: cellSetOption.H:163
Foam::fv::meanVelocityForce::meanVelocityForce
meanVelocityForce(const word &sourceName, const word &modelType, const dictionary &dict, const fvMesh &mesh)
Construct from explicit source name and mesh.
Definition: meanVelocityForce.C:78
Foam::fv::meanVelocityForce::rAPtr_
autoPtr< volScalarField > rAPtr_
Matrix 1/A coefficients field pointer.
Definition: meanVelocityForce.H:172
Foam::fv::meanVelocityForce::relaxation_
scalar relaxation_
Relaxation factor.
Definition: meanVelocityForce.H:169
Foam::fv::meanVelocityForce::writeProps
void writeProps(const scalar gradP) const
Write the pressure gradient to file (for restarts etc)
Definition: meanVelocityForce.C:50
rho
rho
Definition: readInitialConditions.H:88
Foam::fv::meanVelocityForce::update
void update(fvMatrix< vector > &eqn)
Correct driving force for a constant mass flow rate.
cellSetOption.H
Foam::fv::meanVelocityForce::flowDir_
vector flowDir_
Flow direction.
Definition: meanVelocityForce.H:166
Foam::fv::meanVelocityForce::Ubar_
vector Ubar_
Desired mean velocity.
Definition: meanVelocityForce.H:157
Foam::fv::meanVelocityForce::read
virtual bool read(const dictionary &dict)
Read source dictionary.
Definition: meanVelocityForce.C:262
Foam::fv::meanVelocityForce::dGradP_
scalar dGradP_
Change in pressure gradient.
Definition: meanVelocityForce.H:163
Foam::fv::meanVelocityForce::addSup
virtual void addSup(fvMatrix< vector > &eqn, const label fieldi)
Add explicit contribution to momentum equation.
Definition: meanVelocityForce.C:190
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
fvMesh.H
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::vector
Vector< scalar > vector
A scalar version of the templated Vector.
Definition: vector.H:51
Foam::fv::meanVelocityForce::~meanVelocityForce
virtual ~meanVelocityForce()=default
Destructor.
Foam::fv::meanVelocityForce::TypeName
TypeName("meanVelocityForce")
Runtime type information.
Foam::volVectorField
GeometricField< vector, fvPatchField, volMesh > volVectorField
Definition: volFieldsFwd.H:62
fv
labelList fv(nPoints)
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::fv::meanVelocityForce
Applies the force within a specified region to maintain the specified mean velocity for incompressibl...
Definition: meanVelocityForce.H:148
U
U
Definition: pEqn.H:72
Foam::fv::option::mesh
const fvMesh & mesh() const noexcept
Return const access to the mesh database.
Definition: fvOptionI.H:37
Foam::fv::meanVelocityForce::constrain
virtual void constrain(fvMatrix< vector > &eqn, const label fieldi)
Set 1/A coefficient.
Definition: meanVelocityForce.C:229
Foam::Vector< scalar >
Foam::fv::meanVelocityForce::magUbarAve
virtual scalar magUbarAve(const volVectorField &U) const
Definition: meanVelocityForce.C:123
Foam::fv::meanVelocityForce::gradP0_
scalar gradP0_
Pressure gradient before correction.
Definition: meanVelocityForce.H:160
Foam::fvMatrix
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvPatchField.H:68
Foam::GeometricField< vector, fvPatchField, volMesh >
Foam::fv::meanVelocityForce::operator=
void operator=(const meanVelocityForce &)=delete
No copy assignment.
Foam::fv::meanVelocityForce::correct
virtual void correct(volVectorField &U)
Correct the pressure gradient.
Definition: meanVelocityForce.C:145
autoPtr.H