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 | Copyright (C) 2011-2016 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  meanVelocityForceCoeffs
37  {
38  selectionMode all; // Apply force to all cells
39  fields (U); // Name of velocity field
40  Ubar (10.0 0 0); // Desired mean velocity
41  relaxation 0.2; // Optional relaxation factor
42  }
43  \endverbatim
44 
45 SourceFiles
46  meanVelocityForce.C
47 
48 \*---------------------------------------------------------------------------*/
49 
50 #ifndef meanVelocityForce_H
51 #define meanVelocityForce_H
52 
53 #include "autoPtr.H"
54 #include "topoSetSource.H"
55 #include "cellSet.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  //- Disallow default bitwise copy construct
117 
118  //- Disallow default bitwise assignment
119  void operator=(const meanVelocityForce&);
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 // ************************************************************************* //
dictionary dict
virtual void correct(volVectorField &U)
Correct the pressure gradient.
U
Definition: pEqn.H:83
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.
autoPtr< volScalarField > rAPtr_
Matrix 1/A coefficients field pointer.
dimensionedVector gradP("gradP", dimensionSet(0, 1,-2, 0, 0), Zero)
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:71
scalar dGradP_
Change in pressure gradient.
void writeProps(const scalar gradP) const
Write the pressure gradient to file (for restarts etc)
void update(fvMatrix< vector > &eqn)
Correct driving force for a constant mass flow rate.
const fvMesh & mesh() const
Return const access to the mesh database.
Definition: fvOptionI.H:34
TypeName("meanVelocityForce")
Runtime type information.
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:72
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:53
virtual scalar magUbarAve(const volVectorField &U) const
Calculate and return the magnitude of the mean velocity.
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.