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 -------------------------------------------------------------------------------
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::fv::meanVelocityForce
28 
29 Group
30  grpFvOptionsSources
31 
32 Description
33  Calculates and applies the force necessary to maintain the specified mean
34  velocity.
35 
36  Note: Currently only handles kinematic pressure (incompressible solvers).
37 
38 Usage
39  Example usage:
40  \verbatim
41  selectionMode all; // Apply force to all cells
42  fields (U); // Name of velocity field
43  Ubar (10.0 0 0); // Desired mean velocity
44  relaxation 0.2; // Optional relaxation factor
45  \endverbatim
46 
47 SourceFiles
48  meanVelocityForce.C
49 
50 \*---------------------------------------------------------------------------*/
51 
52 #ifndef meanVelocityForce_H
53 #define meanVelocityForce_H
54 
55 #include "autoPtr.H"
56 #include "fvMesh.H"
57 #include "volFields.H"
58 #include "cellSetOption.H"
59 
60 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
61 
62 namespace Foam
63 {
64 namespace fv
65 {
66 
67 /*---------------------------------------------------------------------------*\
68  Class meanVelocityForce Declaration
69 \*---------------------------------------------------------------------------*/
70 
72 :
73  public cellSetOption
74 {
75 protected:
76 
77  // Protected data
78 
79  //- Average velocity
80  vector Ubar_;
81 
82  //- Pressure gradient before correction
83  scalar gradP0_;
84 
85  //- Change in pressure gradient
86  scalar dGradP_;
87 
88  //- Flow direction
90 
91  //- Relaxation factor
92  scalar relaxation_;
93 
94  //- Matrix 1/A coefficients field pointer
96 
97 
98  // Protected Member Functions
99 
100  //- Calculate and return the magnitude of the mean velocity
101  // averaged over the selected cellSet
102  virtual scalar magUbarAve(const volVectorField& U) const;
103 
104  //- Write the pressure gradient to file (for restarts etc)
105  void writeProps(const scalar gradP) const;
106 
107  //- Correct driving force for a constant mass flow rate
108  void update(fvMatrix<vector>& eqn);
109 
110 
111 private:
112 
113  // Private Member Functions
114 
115  //- No copy construct
116  meanVelocityForce(const meanVelocityForce&) = delete;
117 
118  //- No copy assignment
119  void operator=(const meanVelocityForce&) = delete;
120 
121 
122 public:
123 
124  //- Runtime type information
125  TypeName("meanVelocityForce");
126 
127 
128  // Constructors
129 
130  //- Construct from explicit source name and mesh
132  (
133  const word& sourceName,
134  const word& modelType,
135  const dictionary& dict,
136  const fvMesh& mesh
137  );
138 
139 
140  // Member Functions
141 
142  // Evaluate
143 
144  //- Correct the pressure gradient
145  virtual void correct(volVectorField& U);
146 
147  //- Add explicit contribution to momentum equation
148  virtual void addSup
149  (
150  fvMatrix<vector>& eqn,
151  const label fieldi
152  );
153 
154  //- Add explicit contribution to compressible momentum equation
155  virtual void addSup
156  (
157  const volScalarField& rho,
158  fvMatrix<vector>& eqn,
159  const label fieldi
160  );
161 
162  //- Set 1/A coefficient
163  virtual void constrain
164  (
165  fvMatrix<vector>& eqn,
166  const label fieldi
167  );
168 
169 
170  // IO
171 
172  //- Read source dictionary
173  virtual bool read(const dictionary& dict);
174 };
175 
176 
177 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
178 
179 } // End namespace fv
180 } // End namespace Foam
181 
182 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
183 
184 #endif
185 
186 // ************************************************************************* //
volFields.H
gradP
volVectorField gradP(fvc::grad(p))
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::fv::cellSetOption
Cell-set options abstract base class. Provides a base set of controls, e.g.:
Definition: cellSetOption.H:72
Foam::fv::meanVelocityForce::rAPtr_
autoPtr< volScalarField > rAPtr_
Matrix 1/A coefficients field pointer.
Definition: meanVelocityForce.H:94
Foam::fv::meanVelocityForce::relaxation_
scalar relaxation_
Relaxation factor.
Definition: meanVelocityForce.H:91
Foam::fv::meanVelocityForce::writeProps
void writeProps(const scalar gradP) const
Write the pressure gradient to file (for restarts etc)
Definition: meanVelocityForce.C:56
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:88
Foam::fv::meanVelocityForce::Ubar_
vector Ubar_
Average velocity.
Definition: meanVelocityForce.H:79
Foam::fv::meanVelocityForce::read
virtual bool read(const dictionary &dict)
Read source dictionary.
Definition: meanVelocityForce.C:268
Foam::fv::meanVelocityForce::dGradP_
scalar dGradP_
Change in pressure gradient.
Definition: meanVelocityForce.H:85
Foam::fv::meanVelocityForce::addSup
virtual void addSup(fvMatrix< vector > &eqn, const label fieldi)
Add explicit contribution to momentum equation.
Definition: meanVelocityForce.C:196
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:121
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:84
fvMesh.H
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::fv::meanVelocityForce::TypeName
TypeName("meanVelocityForce")
Runtime type information.
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
Calculates and applies the force necessary to maintain the specified mean velocity.
Definition: meanVelocityForce.H:70
U
U
Definition: pEqn.H:72
Foam::fv::meanVelocityForce::constrain
virtual void constrain(fvMatrix< vector > &eqn, const label fieldi)
Set 1/A coefficient.
Definition: meanVelocityForce.C:235
Foam::Vector< scalar >
Foam::fv::meanVelocityForce::magUbarAve
virtual scalar magUbarAve(const volVectorField &U) const
Calculate and return the magnitude of the mean velocity.
Definition: meanVelocityForce.C:129
Foam::fv::meanVelocityForce::gradP0_
scalar gradP0_
Pressure gradient before correction.
Definition: meanVelocityForce.H:82
Foam::fv::option::mesh
const fvMesh & mesh() const
Return const access to the mesh database.
Definition: fvOptionI.H:36
Foam::fvMatrix
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvPatchField.H:76
Foam::GeometricField< vector, fvPatchField, volMesh >
Foam::fv::meanVelocityForce::correct
virtual void correct(volVectorField &U)
Correct the pressure gradient.
Definition: meanVelocityForce.C:151
autoPtr.H