velocityDampingConstraint.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) 2015 OpenFOAM Foundation
9  Copyright (C) 2015-2022 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::fv::velocityDampingConstraint
29 
30 Group
31  grpFvOptionsConstraints
32 
33 Description
34  Constrain given velocity fields to dampen velocity
35  fluctuations exceeding a given value within a specified region.
36 
37  This constraint is primarily used to dampen velocity fluctuations in
38  the start-up phase of simulations. When the local velocity magnitude
39  exceeds the user-supplied maximum value a sink term is activated in
40  the affected region to lower the velocity to the limiting value.
41 
42  Constraints applied to:
43  \verbatim
44  U | Velocity [m/s]
45  \endverbatim
46 
47  Required fields:
48  \verbatim
49  U | Velocity [m/s]
50  \endverbatim
51 
52 Usage
53  Minimal example by using \c constant/fvOptions:
54  \verbatim
55  velocityDampingConstraint1
56  {
57  // Mandatory entries (unmodifiable)
58  type velocityDampingConstraint;
59 
60  // Mandatory entries (runtime modifiable)
61  UMax 200;
62 
63  // Optional entries (runtime modifiable)
64  UNames (<Uname1> <Uname2> ... <UnameN>);
65  C <scalar>;
66 
67  // Conditional optional entries (runtime modifiable)
68 
69  // when UNames entry is not present
70  U U;
71 
72  // Mandatory/Optional (inherited) entries
73  ...
74  }
75  \endverbatim
76 
77  where the entries mean:
78  \table
79  Property | Description | Type | Reqd | Dflt
80  type | Type name: velocityDampingConstraint | word | yes | -
81  UMax | Maximum velocity magnitude | scalar | yes | -
82  UNames | Names of operand velocity fields | wordList | no | -
83  U | Name of operand velocity field | word | cndtnl | U
84  C | Model factor | scalar | no | 1
85  \endtable
86 
87  The inherited entries are elaborated in:
88  - \link fvOption.H \endlink
89  - \link cellSetOption.H \endlink
90  - \link writeFile.H \endlink
91 
92 Note
93  - When active, this constraint manipulates the system of equations.
94  Users should ensure that it is not active when the case is converged
95  (steady-state) or during the period of interest (transient) to ensure
96  that its presence does not pollute the results.
97 
98 See also
99  - Foam::fv::limitVelocity
100 
101 SourceFiles
102  velocityDampingConstraint.C
103 
104 \*---------------------------------------------------------------------------*/
105 
106 #ifndef fv_velocityDampingConstraint_H
107 #define fv_velocityDampingConstraint_H
108 
109 #include "cellSetOption.H"
110 #include "writeFile.H"
111 
112 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
113 
114 namespace Foam
115 {
116 namespace fv
117 {
118 
119 /*---------------------------------------------------------------------------*\
120  Class velocityDampingConstraint Declaration
121 \*---------------------------------------------------------------------------*/
122 
123 class velocityDampingConstraint
124 :
125  public fv::cellSetOption,
126  public functionObjects::writeFile
127 {
128 protected:
129 
130  // Protected Data
131 
132  //- Maximum velocity magnitude
133  scalar UMax_;
134 
135  //- Model factor
136  scalar C_;
137 
138 
139  // Protected Member Functions
140 
141  //- Constrain the given velocity fields by a given maximum value
142  void addDamping(fvMatrix<vector>& eqn);
143 
144  //- Write file header information
145  void writeFileHeader(Ostream& os);
146 
147 
148 public:
149 
150  //- Runtime type information
151  TypeName("velocityDampingConstraint");
152 
153 
154  // Constructors
155 
156  //- Construct from components
158  (
159  const word& name,
160  const word& modelType,
161  const dictionary& dict,
162  const fvMesh& mesh
163  );
164 
165  //- No copy construct
167 
168  //- No copy assignment
169  void operator=(const velocityDampingConstraint&) = delete;
170 
172  //- Destructor
173  virtual ~velocityDampingConstraint() = default;
174 
175 
176  // Member Functions
177 
178  // Set values directly
179 
180  //- Constrain vector matrix
181  virtual void constrain(fvMatrix<vector>& eqn, const label fieldi);
182 
183 
184  // I-O
185 
186  //- Write data
187  virtual void writeData(Ostream& os) const;
188 
189  //- Read dictionary
190  virtual bool read(const dictionary& dict);
191 };
192 
193 
194 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
195 
196 } // End namespace fv
197 } // End namespace Foam
198 
199 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
200 
201 #endif
202 
203 // ************************************************************************* //
void writeFileHeader(Ostream &os)
Write file header information.
virtual bool read(const dictionary &dict)
Read dictionary.
dictionary dict
const fvMesh & mesh() const noexcept
Return const access to the mesh database.
Definition: fvOptionI.H:30
virtual ~velocityDampingConstraint()=default
Destructor.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
velocityDampingConstraint(const word &name, const word &modelType, const dictionary &dict, const fvMesh &mesh)
Construct from components.
A class for handling words, derived from Foam::string.
Definition: word.H:63
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:64
const word & name() const noexcept
Return const access to the source name.
Definition: fvOptionI.H:24
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
OBJstream os(runTime.globalPath()/outputName)
virtual void constrain(fvMatrix< vector > &eqn, const label fieldi)
Constrain vector matrix.
Constrain given velocity fields to dampen velocity fluctuations exceeding a given value within a spec...
TypeName("velocityDampingConstraint")
Runtime type information.
void addDamping(fvMatrix< vector > &eqn)
Constrain the given velocity fields by a given maximum value.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
void operator=(const velocityDampingConstraint &)=delete
No copy assignment.
scalar UMax_
Maximum velocity magnitude.
virtual void writeData(Ostream &os) const
Write data.
Namespace for OpenFOAM.