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-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::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 volumetric flow rate:
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  //- Optional velocity profile
139  autoPtr<Function1<scalar>> profile_;
140 
141  //- Is the flow-rate mean velocity?
142  bool meanVelocity_;
143 
144  //- Is the flow-rate volumetric?
145  bool volumetric_;
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  //- Return whether the flow rate can be evaluated on this case (i.e.,
188  // is not a non-parallel processor case)
189  bool canEvaluate();
190 
191 
192 public:
193 
194  //- Runtime type information
195  TypeName("flowRateInletVelocity");
196 
197 
198  // Constructors
199 
200  //- Construct from patch, internal field and dictionary
202  (
203  const fvPatch&,
205  const dictionary&
206  );
207 
208  //- Construct by mapping given
209  // flowRateInletVelocityFvPatchVectorField
210  // onto a new patch
212  (
214  const fvPatch&,
216  const fvPatchFieldMapper&
217  );
218 
219  //- Disallow copy without setting internal field reference
221  (
223  ) = delete;
224 
225  //- Copy constructor setting internal field reference
227  (
230  );
231 
232  //- Construct and return a clone setting internal field reference
234  (
236  ) const
237  {
239  (
241  );
242  }
243 
244 
245  // Member Functions
246 
247  // Mapping functions
248 
249  //- Map the given fvPatchField onto this fvPatchField
250  virtual void map
251  (
252  const fvPatchVectorField&,
253  const fvPatchFieldMapper&
254  );
255 
256  //- Reset the fvPatchField to the given fvPatchField
257  // Used for mesh to mesh mapping
258  virtual void reset(const fvPatchVectorField&);
259 
260 
261  // Evaluation functions
262 
263  //- Update the coefficients associated with the patch field
264  virtual void updateCoeffs();
265 
266 
267  // I-O
268 
269  //- Write
270  virtual void write(Ostream&) const;
271 };
272 
273 
274 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
275 
276 } // End namespace Foam
277 
278 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
279 
280 #endif
281 
282 // ************************************************************************* //
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 keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:160
Velocity inlet boundary condition creating a velocity field with optionally specified profile normal ...
flowRateInletVelocityFvPatchVectorField(const fvPatch &, const DimensionedField< vector, volMesh > &, const dictionary &)
Construct from patch, internal field and dictionary.
virtual tmp< fvPatchVectorField > clone(const DimensionedField< vector, volMesh > &iF) const
Construct and return a clone setting internal field reference.
TypeName("flowRateInletVelocity")
Runtime type information.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
virtual void map(const fvPatchVectorField &, const fvPatchFieldMapper &)
Map the given fvPatchField onto this fvPatchField.
virtual void reset(const fvPatchVectorField &)
Reset the fvPatchField to the given fvPatchField.
Foam::fvPatchFieldMapper.
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:87
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:64
A class for managing temporary objects.
Definition: tmp.H:55
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.