meanVelocityForce.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::fv::meanVelocityForce
26 
27 Description
28  Calculates and applies the force necessary to maintain the specified mean
29  velocity.
30 
31  Note: Currently only handles kinematic pressure (incompressible solvers).
32 
33 Usage
34  Example usage:
35  \verbatim
36  selectionMode all; // Apply force to all cells
37  fields (U); // Name of velocity field
38  Ubar (10.0 0 0); // Desired mean velocity
39  relaxation 0.2; // Optional relaxation factor
40  \endverbatim
41 
42 SourceFiles
43  meanVelocityForce.C
44 
45 \*---------------------------------------------------------------------------*/
46 
47 #ifndef meanVelocityForce_H
48 #define meanVelocityForce_H
49 
50 #include "autoPtr.H"
51 #include "topoSetSource.H"
52 #include "cellSet.H"
53 #include "fvMesh.H"
54 #include "volFields.H"
55 #include "cellSetOption.H"
56 
57 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
58 
59 namespace Foam
60 {
61 namespace fv
62 {
63 
64 /*---------------------------------------------------------------------------*\
65  Class meanVelocityForce Declaration
66 \*---------------------------------------------------------------------------*/
67 
69 :
70  public cellSetOption
71 {
72 protected:
73 
74  // Protected data
75 
76  //- Average velocity
77  vector Ubar_;
78 
79  //- Pressure gradient before correction
80  scalar gradP0_;
81 
82  //- Change in pressure gradient
83  scalar dGradP_;
84 
85  //- Flow direction
87 
88  //- Relaxation factor
89  scalar relaxation_;
90 
91  //- Matrix 1/A coefficients field pointer
93 
94 
95  // Protected Member Functions
96 
97  //- Calculate and return the magnitude of the mean velocity
98  // averaged over the selected cellSet
99  virtual scalar magUbarAve(const volVectorField& U) const;
100 
101  //- Write the pressure gradient to file (for restarts etc)
102  void writeProps(const scalar gradP) const;
103 
104  //- Correct driving force for a constant mass flow rate
105  void update(fvMatrix<vector>& eqn);
106 
107 
108 private:
109 
110  // Private Member Functions
111 
112  //- Disallow default bitwise copy construct
114 
115  //- Disallow default bitwise assignment
116  void operator=(const meanVelocityForce&);
117 
118 
119 public:
120 
121  //- Runtime type information
122  TypeName("meanVelocityForce");
123 
124 
125  // Constructors
126 
127  //- Construct from explicit source name and mesh
129  (
130  const word& sourceName,
131  const word& modelType,
132  const dictionary& dict,
133  const fvMesh& mesh
134  );
135 
136 
137  // Member Functions
138 
139  // Evaluate
140 
141  //- Correct the pressure gradient
142  virtual void correct(volVectorField& U);
143 
144  //- Add explicit contribution to momentum equation
145  virtual void addSup
146  (
147  fvMatrix<vector>& eqn,
148  const label fieldi
149  );
150 
151  //- Add explicit contribution to compressible momentum equation
152  virtual void addSup
153  (
154  const volScalarField& rho,
155  fvMatrix<vector>& eqn,
156  const label fieldi
157  );
158 
159  //- Set 1/A coefficient
160  virtual void constrain
161  (
162  fvMatrix<vector>& eqn,
163  const label fieldi
164  );
165 
166 
167  // IO
168 
169  //- Read source dictionary
170  virtual bool read(const dictionary& dict);
171 };
172 
173 
174 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
175 
176 } // End namespace fv
177 } // End namespace Foam
178 
179 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
180 
181 #endif
182 
183 // ************************************************************************* //
virtual scalar magUbarAve(const volVectorField &U) const
Calculate and return the magnitude of the mean velocity.
dictionary dict
virtual void correct(volVectorField &U)
Correct the pressure gradient.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
virtual bool read(const dictionary &dict)
Read source dictionary.
dimensionedVector gradP("gradP", dimensionSet(0, 1, -2, 0, 0), Zero)
autoPtr< volScalarField > rAPtr_
Matrix 1/A coefficients field pointer.
const fvMesh & mesh() const
Return const access to the mesh database.
Definition: fvOptionI.H:34
void writeProps(const scalar gradP) const
Write the pressure gradient to file (for restarts etc)
scalar relaxation_
Relaxation factor.
virtual void addSup(fvMatrix< vector > &eqn, const label fieldi)
Add explicit contribution to momentum equation.
A class for handling words, derived from string.
Definition: word.H:59
labelList fv(nPoints)
vector Ubar_
Average velocity.
A special matrix type and solver, designed for finite volume solutions of scalar equations. Face addressing is used to make all matrix assembly and solution loops vectorise.
Definition: fvPatchField.H:72
scalar dGradP_
Change in pressure gradient.
void update(fvMatrix< vector > &eqn)
Correct driving force for a constant mass flow rate.
TypeName("meanVelocityForce")
Runtime type information.
U
Definition: pEqn.H:72
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
Cell-set options abtract base class. Provides a base set of controls, e.g.:
Definition: cellSetOption.H:69
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
scalar gradP0_
Pressure gradient before correction.
vector flowDir_
Flow direction.
Calculates and applies the force necessary to maintain the specified mean velocity.
Namespace for OpenFOAM.
virtual void constrain(fvMatrix< vector > &eqn, const label fieldi)
Set 1/A coefficient.