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-2023 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  select 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 fvMesh& mesh,
130  const dictionary& dict
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 motion
159  virtual bool movePoints();
160 
161  //- Update topology using the given map
162  virtual void topoChange(const polyTopoChangeMap&);
163 
164  //- Update from another mesh using the given map
165  virtual void mapMesh(const polyMeshMap&);
166 
167  //- Redistribute or update using the given distribution map
168  virtual void distribute(const polyDistributionMap&);
169 
170  //- Read source dictionary
171  virtual bool read(const dictionary& dict);
172 
173 
174  // Member Operators
175 
176  //- Disallow default bitwise assignment
177  void operator=(const meanVelocityForce&) = delete;
178 };
179 
180 
181 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
182 
183 } // End namespace fv
184 } // End namespace Foam
185 
186 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
187 
188 #endif
189 
190 // ************************************************************************* //
Generic GeometricField class.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:160
General run-time selected cell set selection class for fvMesh.
Definition: fvCellSet.H:88
Finite volume options abstract base class.
Definition: fvConstraint.H:57
const fvMesh & mesh() const
Return const access to the mesh database.
Definition: fvConstraintI.H:34
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvMatrix.H:118
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:101
Calculates and applies the force necessary to maintain the specified mean velocity.
virtual bool movePoints()
Update for mesh motion.
void operator=(const meanVelocityForce &)=delete
Disallow default bitwise assignment.
TypeName("meanVelocityForce")
Runtime type information.
virtual bool constrain(fvMatrix< vector > &eqn, const word &fieldName) const
Add the momentum source and set the 1/A coefficient.
virtual void topoChange(const polyTopoChangeMap &)
Update topology using the given map.
virtual void distribute(const polyDistributionMap &)
Redistribute or update using the given distribution map.
virtual bool read(const dictionary &dict)
Read source dictionary.
meanVelocityForce(const word &sourceName, const word &modelType, const fvMesh &mesh, const dictionary &dict)
Construct from explicit source name and mesh.
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
virtual wordList constrainedFields() const
Return the list of fields constrained by the fvConstraint.
const vector & Ubar() const
Return the average velocity.
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
Class containing mesh-to-mesh mapping information.
Definition: polyMeshMap.H:51
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
A class for handling words, derived from string.
Definition: word.H:62
U
Definition: pEqn.H:72
Namespace for OpenFOAM.
labelList fv(nPoints)
dictionary dict
dimensionedVector gradP("gradP", dimensionSet(0, 1, -2, 0, 0), Zero)