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-2021 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 Usage
32  Example usage:
33  \verbatim
34  meanVelocityConstraint
35  {
36  type meanVelocityForce;
37 
38  selectionMode all;
39 
40  U U; // Name of velocity field
41 
42  Ubar (10.0 0 0); // Desired mean velocity
43  relaxation 0.2; // Optional relaxation factor
44  }
45  \endverbatim
46 
47 Note
48  Currently only handles kinematic pressure (incompressible solvers).
49 
50 SourceFiles
51  meanVelocityForce.C
52 
53 \*---------------------------------------------------------------------------*/
54 
55 #ifndef meanVelocityForce_H
56 #define meanVelocityForce_H
57 
58 #include "fvConstraint.H"
59 #include "fvCellSet.H"
60 
61 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
62 
63 namespace Foam
64 {
65 namespace fv
66 {
67 
68 /*---------------------------------------------------------------------------*\
69  Class meanVelocityForce Declaration
70 \*---------------------------------------------------------------------------*/
71 
73 :
74  public fvConstraint
75 {
76  // Private data
77 
78  //- The set of cells the fvConstraint applies to
79  fvCellSet set_;
80 
81  //- Name of the velocity field
82  word UName_;
83 
84  //- Average velocity
85  vector Ubar_;
86 
87  //- Relaxation factor
88  scalar relaxation_;
89 
90  //- Pressure gradient before correction
91  mutable scalar gradP0_;
92 
93  //- Change in pressure gradient
94  mutable scalar dGradP_;
95 
96  //- Matrix 1/A coefficients field pointer
97  mutable autoPtr<volScalarField> rAPtr_;
98 
99 
100  // Private Member Functions
101 
102  //- Non-virtual read
103  void readCoeffs();
104 
105  //- Calculate and return the magnitude of the mean velocity
106  // averaged over the selected cellSet
107  virtual scalar magUbarAve(const volVectorField& U) const;
108 
109  //- Write the pressure gradient to file (for restarts etc)
110  void writeProps(const scalar gradP) const;
111 
112  //- Correct driving force for a constant mass flow rate
113  void update(fvMatrix<vector>& eqn) const;
114 
115 
116 public:
117 
118  //- Runtime type information
119  TypeName("meanVelocityForce");
120 
121 
122  // Constructors
123 
124  //- Construct from explicit source name and mesh
126  (
127  const word& sourceName,
128  const word& modelType,
129  const dictionary& dict,
130  const fvMesh& mesh
131  );
132 
133  //- Disallow default bitwise copy construction
134  meanVelocityForce(const meanVelocityForce&) = delete;
135 
136 
137  // Member Functions
138 
139  //- Return the average velocity
140  const vector& Ubar() const
141  {
142  return Ubar_;
143  }
144 
145  //- Return the list of fields constrained by the fvConstraint
146  virtual wordList constrainedFields() const;
147 
148  //- Add the momentum source and set the 1/A coefficient
149  virtual bool constrain
150  (
151  fvMatrix<vector>& eqn,
152  const word& fieldName
153  ) const;
154 
155  //- Correct the pressure gradient
156  virtual bool constrain(volVectorField& U) const;
157 
158  //- Update for mesh changes
159  virtual void updateMesh(const mapPolyMesh&);
160 
161  //- Read source dictionary
162  virtual bool read(const dictionary& dict);
163 
164 
165  // Member Operators
166 
167  //- Disallow default bitwise assignment
168  void operator=(const meanVelocityForce&) = delete;
169 };
170 
171 
172 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
173 
174 } // End namespace fv
175 } // End namespace Foam
176 
177 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
178 
179 #endif
180 
181 // ************************************************************************* //
dictionary dict
const fvMesh & mesh() const
Return const access to the mesh database.
Definition: fvConstraintI.H:34
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
Cell-set fvConstraint abstract base class. Provides a base set of controls regarding the location whe...
virtual bool read(const dictionary &dict)
Read source dictionary.
virtual bool constrain(fvMatrix< vector > &eqn, const word &fieldName) const
Add the momentum source and set the 1/A coefficient.
dimensionedVector gradP("gradP", dimensionSet(0, 1, -2, 0, 0), Zero)
void operator=(const meanVelocityForce &)=delete
Disallow default bitwise assignment.
const vector & Ubar() const
Return the average velocity.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
meanVelocityForce(const word &sourceName, const word &modelType, const dictionary &dict, const fvMesh &mesh)
Construct from explicit source name and mesh.
A class for handling words, derived from string.
Definition: word.H:59
labelList fv(nPoints)
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
virtual void updateMesh(const mapPolyMesh &)
Update for mesh changes.
virtual wordList constrainedFields() const
Return the list of fields constrained by the fvConstraint.
TypeName("meanVelocityForce")
Runtime type information.
U
Definition: pEqn.H:72
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
Calculates and applies the force necessary to maintain the specified mean velocity.
Finite volume options abstract base class.
Definition: fvConstraint.H:54
Namespace for OpenFOAM.