flowRateInletVelocityFvPatchVectorField.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-2026 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::flowRateInletVelocityFvPatchVectorField
26 
27 Description
28  Velocity inlet boundary condition creating a velocity field with
29  optionally specified profile normal to the patch adjusted to match the
30  specified mass flow rate, volumetric flow rate or mean velocity.
31 
32  For a mass-based flux:
33  - the flow rate should be provided in kg/s
34  - if \c rho is "none" the flow rate is in m3/s
35  - otherwise \c rho should correspond to the name of the density field
36  - if the density field cannot be found in the database, the user must
37  specify the inlet density using the \c rhoInlet entry
38 
39  For a volumetric-based flux:
40  - the flow rate is in m3/s
41 
42 Usage
43  \table
44  Property | Description | Required | Default value
45  massFlowRate | Mass flow rate [kg/s] | no |
46  volumetricFlowRate | Volumetric flow rate [m^3/s] | no |
47  meanVelocity | Mean velocity [m/s] | no |
48  profile | Velocity profile | no |
49  rho | Density field name | no | rho
50  rhoInlet | Inlet density | no |
51  alpha | Volume fraction field name | no |
52  \endtable
53 
54  Example of the boundary condition specification for a volumetric flow rate:
55  \verbatim
56  <patchName>
57  {
58  type flowRateInletVelocity;
59  volumetricFlowRate 0.2;
60  profile laminarBL;
61  }
62  \endverbatim
63 
64  Example of the boundary condition specification for a mass flow rate:
65  \verbatim
66  <patchName>
67  {
68  type flowRateInletVelocity;
69  massFlowRate 0.2;
70  profile turbulentBL;
71  rho rho;
72  rhoInlet 1.0;
73  }
74  \endverbatim
75 
76  Example of the boundary condition specification for a mean velocity:
77  \verbatim
78  <patchName>
79  {
80  type flowRateInletVelocity;
81  meanVelocity 5;
82  profile turbulentBL;
83  }
84  \endverbatim
85 
86  The \c volumetricFlowRate, \c massFlowRate or \c meanVelocity entries are
87  \c Function1 of time, see Foam::Function1s.
88 
89  The \c profile entry is a \c Function1 of the normalised distance to the
90  wall. Any suitable Foam::Function1s can be used including
91  Foam::Function1s::codedFunction1 but Foam::Function1s::laminarBL and
92  Foam::Function1s::turbulentBL have been created specifically for this
93  purpose and are likely to be appropriate for most cases.
94 
95  Note:
96  - \c rhoInlet is required for the case of a mass flow rate, where the
97  density field is not available at start-up
98  - The value is positive into the domain (as an inlet)
99  - May not work correctly for transonic inlets
100  - Strange behaviour with potentialFoam since the U equation is not solved
101 
102 See also
103  Foam::fixedValueFvPatchField
104  Foam::Function1s::laminarBL
105  Foam::Function1s::turbulentBL
106  Foam::Function1s
107  Foam::flowRateOutletVelocityFvPatchVectorField
108 
109 SourceFiles
110  flowRateInletVelocityFvPatchVectorField.C
111 
112 \*---------------------------------------------------------------------------*/
113 
114 #ifndef flowRateInletVelocityFvPatchVectorField_H
115 #define flowRateInletVelocityFvPatchVectorField_H
116 
117 #include "fixedValueFvPatchFields.H"
118 #include "Function1.H"
119 
120 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
121 
122 namespace Foam
123 {
124 
125 /*---------------------------------------------------------------------------*\
126  Class flowRateInletVelocityFvPatchVectorField Declaration
127 \*---------------------------------------------------------------------------*/
128 
129 class flowRateInletVelocityFvPatchVectorField
130 :
131  public fixedValueFvPatchVectorField
132 {
133  // Private Data
134 
135  //- Inlet integral flow rate
136  autoPtr<Function1<scalar>> flowRate_;
137 
138  //- Is the flow-rate mean velocity?
139  bool meanVelocity_;
140 
141  //- Is the flow-rate volumetric?
142  bool volumetric_;
143 
144  //- Optional velocity profile
145  autoPtr<Function1<scalar>> profile_;
146 
147  //- Name of the density field used to normalise the mass flux
148  word rhoName_;
149 
150  //- Rho initialisation value (for start; if value not supplied)
151  scalar rhoInlet_;
152 
153  //- Name of the volume fraction field used to convert to interstitial
154  // velocity
155  word alphaName_;
156 
157  //- Normalised distance to the wall
158  scalarField y_;
159 
160  //- Total area of patch
161  scalar area_;
162 
163 
164  // Private Member Functions
165 
166  //- Set the wall distance field y_
167  void setWallDist();
168 
169  //- Return the normalised velocity profile
170  virtual tmp<scalarField> profile();
171 
172  //- Update the patch values given the appropriate volume fraction and
173  // density types and values
174  template<class ScaleType, class AlphaType, class RhoType>
175  void updateValues
176  (
177  const ScaleType& scale,
178  const AlphaType& alpha,
179  const RhoType& rho
180  );
181 
182  //- Update the patch values given the appropriate volume fraction type
183  // and values
184  template<class AlphaType>
185  void updateValues(const AlphaType& alpha);
186 
187 
188 public:
189 
190  //- Runtime type information
191  TypeName("flowRateInletVelocity");
192 
193 
194  // Constructors
195 
196  //- Construct from patch, internal field and dictionary
198  (
199  const fvPatch&,
201  const dictionary&
202  );
203 
204  //- Construct by mapping given
205  // flowRateInletVelocityFvPatchVectorField
206  // onto a new patch
208  (
210  const fvPatch&,
212  const fieldMapper&
213  );
214 
215  //- Disallow copy without setting internal field reference
217  (
219  ) = delete;
220 
221  //- Copy constructor setting internal field reference
223  (
226  );
227 
228  //- Construct and return a clone setting internal field reference
230  (
232  ) const
233  {
235  (
237  );
238  }
239 
240 
241  // Member Functions
242 
243  // Mapping functions
244 
245  //- Map the given fvPatchField onto this fvPatchField
246  virtual void map(const fvPatchVectorField&, const fieldMapper&);
247 
248  //- Reset the fvPatchField to the given fvPatchField
249  // Used for mesh to mesh mapping
250  virtual void reset(const fvPatchVectorField&);
251 
252 
253  // Evaluation functions
254 
255  //- Update the coefficients associated with the patch field
256  virtual void updateCoeffs();
257 
258 
259  // I-O
260 
261  //- Write
262  virtual void write(Ostream&) const;
263 
264 
265  // Member Operators
266 
267  //- Inherit assignment
268  using fixedValueFvPatchVectorField::operator=;
269 };
270 
271 
272 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
273 
274 } // End namespace Foam
275 
276 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
277 
278 #endif
279 
280 // ************************************************************************* //
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
Abstract base class for field mapping.
Definition: fieldMapper.H:48
Velocity inlet boundary condition creating a velocity field with optionally specified profile normal ...
TypeName("flowRateInletVelocity")
Runtime type information.
flowRateInletVelocityFvPatchVectorField(const fvPatch &, const DimensionedField< vector, fvMesh > &, const dictionary &)
Construct from patch, internal field and dictionary.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
virtual tmp< fvPatchVectorField > clone(const DimensionedField< vector, fvMesh > &iF) const
Construct and return a clone setting internal field reference.
virtual void reset(const fvPatchVectorField &)
Reset the fvPatchField to the given fvPatchField.
virtual void map(const fvPatchVectorField &, const fieldMapper &)
Map the given fvPatchField onto this fvPatchField.
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:90
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:58
A class for managing temporary objects.
Definition: tmp.H:55
rho
Definition: pEqn.H:1
volScalarField alpha(IOobject("alpha", runTime.name(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE), lambda *max(Ua &U, zeroSensitivity))
Namespace for OpenFOAM.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.