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-2022 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();
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 and internal field
202  (
203  const fvPatch&,
205  );
206 
207  //- Construct from patch, internal field and dictionary
209  (
210  const fvPatch&,
212  const dictionary&
213  );
214 
215  //- Construct by mapping given
216  // flowRateInletVelocityFvPatchVectorField
217  // onto a new patch
219  (
221  const fvPatch&,
223  const fvPatchFieldMapper&
224  );
225 
226  //- Disallow copy without setting internal field reference
228  (
230  ) = delete;
231 
232  //- Copy constructor setting internal field reference
234  (
237  );
238 
239  //- Construct and return a clone setting internal field reference
241  (
243  ) const
244  {
246  (
248  );
249  }
250 
251 
252  // Member Functions
253 
254  //- Map (and resize as needed) from self given a mapping object
255  // Used to update fields following mesh topology change
256  virtual void autoMap(const fvPatchFieldMapper&);
257 
258  //- Reverse map the given fvPatchField onto this fvPatchField
259  // Used to reconstruct fields
260  virtual void rmap(const fvPatchVectorField&, const labelList&);
261 
262  //- Reset the fvPatchField to the given fvPatchField
263  // Used for mesh to mesh mapping
264  virtual void reset(const fvPatchVectorField&);
265 
266  //- Update the coefficients associated with the patch field
267  virtual void updateCoeffs();
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 // ************************************************************************* //
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
volScalarField alpha(IOobject("alpha", runTime.timeName(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE), lambda *max(Ua &U, zeroSensitivity))
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:63
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:66
virtual tmp< fvPatchVectorField > clone(const DimensionedField< vector, volMesh > &iF) const
Construct and return a clone setting internal field reference.
virtual void rmap(const fvPatchVectorField &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
flowRateInletVelocityFvPatchVectorField(const fvPatch &, const DimensionedField< vector, volMesh > &)
Construct from patch and internal field.
Foam::fvPatchFieldMapper.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Velocity inlet boundary condition creating a velocity field with optionally specified profile normal ...
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
A class for managing temporary objects.
Definition: PtrList.H:53
TypeName("flowRateInletVelocity")
Runtime type information.
virtual void reset(const fvPatchVectorField &)
Reset the fvPatchField to the given fvPatchField.
Namespace for OpenFOAM.