flowRateOutletVelocityFvPatchVectorField.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) 2017 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::flowRateOutletVelocity2FvPatchVectorField
28 
29 Group
30  grpOutletBoundaryConditions
31 
32 Description
33  Velocity outlet boundary condition which corrects the extrapolated velocity
34  to match the specified flow rate.
35 
36  For a mass-based flux:
37  - the flow rate should be provided in kg/s
38  - if \c rho is "none" the flow rate is in m^3/s
39  - otherwise \c rho should correspond to the name of the density field
40  - if the density field cannot be found in the database, the user must
41  specify the outlet density using the \c rhoOutlet entry
42 
43  For a volumetric-based flux:
44  - the flow rate is in m^3/s
45 
46 Usage
47  \table
48  Property | Description | Required | Default value
49  massFlowRate | mass flow rate [kg/s] | no |
50  volumetricFlowRate | volumetric flow rate [m^3/s]| no |
51  rho | density field name | no | rho
52  rhoOutlet | outlet density | no |
53  \endtable
54 
55  Example of the boundary condition specification for a volumetric flow rate:
56  \verbatim
57  <patchName>
58  {
59  type flowRateOutletVelocity2;
60  volumetricFlowRate 0.2;
61  value uniform (0 0 0);
62  }
63  \endverbatim
64 
65  Example of the boundary condition specification for a mass flow rate:
66  \verbatim
67  <patchName>
68  {
69  type flowRateOutletVelocity2;
70  massFlowRate 0.2;
71  rhoOutlet 1.0;
72  value uniform (0 0 0);
73  }
74  \endverbatim
75 
76  The \c flowRate entry is a \c Function1 of time, see Foam::Function1Types.
77 
78 Note
79  - \c rhoOutlet is required for the case of a mass flow rate, where the
80  density field is not available at start-up
81  - The value is positive out of the domain (as an outlet)
82  - May not work correctly for transonic outlets
83  - Strange behaviour with potentialFoam since the U equation is not solved
84 
85 See also
86  Foam::fixedValueFvPatchField
87  Foam::Function1Types
88  Foam::flowRateInletVelocityFvPatchVectorField
89 
90 SourceFiles
91  flowRateOutletVelocity2FvPatchVectorField.C
92 
93 \*---------------------------------------------------------------------------*/
94 
95 #ifndef flowRateOutletVelocity2FvPatchVectorField_H
96 #define flowRateOutletVelocity2FvPatchVectorField_H
97 
99 #include "Function1.H"
100 
101 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
102 
103 namespace Foam
104 {
105 
106 /*---------------------------------------------------------------------------*\
107  Class flowRateOutletVelocity2FvPatchVectorField Declaration
108 \*---------------------------------------------------------------------------*/
109 
110 class flowRateOutletVelocity2FvPatchVectorField
111 :
112  public fixedValueFvPatchVectorField
113 {
114  // Private Data
115 
116  //- Outlet integral flow rate
117  autoPtr<Function1<scalar>> flowRate_;
118 
119  //- Name of the density field used to normalize the mass flux
120  word rhoName_;
121 
122  //- Rho initialisation value (for start; if value not supplied)
123  scalar rhoOutlet_;
124 
125  //- Is volumetric?
126  bool volumetric_;
127 
128  //- Return the matrix diagonal coefficients corresponding to the
129  // evaluation of the value of this patchField with given weights
130  virtual tmp<Field<Type>> valueInternalCoeffs
131  (
132  const tmp<Field<scalar>>&
133  ) const
134  {
135  return tmp<Field<Type>>::New(this->size(), Foam::zero{});;
136  }
137 
138  //- Return the matrix source coefficients corresponding to the
139  // evaluation of the value of this patchField with given weights
140  virtual tmp<Field<Type>> valueBoundaryCoeffs
141  (
142  const tmp<Field<scalar>>&
143  ) const
144  {
145  return *this;
146  }
147 
148  //- Return the matrix diagonal coefficients corresponding to the
149  // evaluation of the gradient of this patchField
150  virtual tmp<Field<Type>> gradientInternalCoeffs() const
151  {
152  return -pTraits<Type>::one*this->patch().deltaCoeffs();
153  }
154 
155  //- Return the matrix source coefficients corresponding to the
156  // evaluation of the gradient of this patchField
157  virtual tmp<Field<Type>> gradientBoundaryCoeffs() const
158  {
159  return this->patch().deltaCoeffs()*(*this);
160  }
161 
162 
163  // Private Member Functions
164 
165  //- Update the patch values given the appropriate density type and value
166  template<class RhoType>
167  void updateValues(const RhoType& rho);
168 
169 
170 public:
171 
172  //- Runtime type information
173  TypeName("flowRateOutletVelocity2");
174 
175 
176  // Constructors
177 
178  //- Construct from patch and internal field
180  (
181  const fvPatch&,
182  const DimensionedField<vector, volMesh>&
183  );
184 
185  //- Construct from patch, internal field and dictionary
187  (
188  const fvPatch&,
189  const DimensionedField<vector, volMesh>&,
190  const dictionary&
191  );
192 
193  //- Construct by mapping given
194  // flowRateOutletVelocity2FvPatchVectorField
195  // onto a new patch
197  (
199  const fvPatch&,
200  const DimensionedField<vector, volMesh>&,
201  const fvPatchFieldMapper&
202  );
203 
204  //- Construct as copy
206  (
208  );
209 
210  //- Construct as copy setting internal field reference
212  (
214  const DimensionedField<vector, volMesh>&
215  );
216 
217  //- Return a clone
218  virtual tmp<fvPatchField<vector>> clone() const
219  {
220  return fvPatchField<vector>::Clone(*this);
221  }
222 
223  //- Clone with an internal field reference
224  virtual tmp<fvPatchField<vector>> clone
225  (
226  const DimensionedField<vector, volMesh>& iF
227  ) const
228  {
229  return fvPatchField<vector>::Clone(*this, iF);
230  }
231 
232 
233  // Member functions
234 
235  //- Update the coefficients associated with the patch field
236  virtual void updateCoeffs();
237 
238  //- Write
239  virtual void write(Ostream&) const;
240 };
241 
242 
243 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
244 
245 } // End namespace Foam
246 
247 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
248 
249 #endif
250 
251 // ************************************************************************* //
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
TypeName("flowRateOutletVelocity2")
Runtime type information.
flowRateOutletVelocity2FvPatchVectorField(const fvPatch &, const DimensionedField< vector, volMesh > &)
Construct from patch and internal field.
static tmp< fvPatchField< Type > > Clone(const DerivedPatchField &pf, Args &&... args)
Clone a patch field, optionally with internal field reference etc.
Definition: fvPatchField.H:597
const std::string patch
OpenFOAM patch number as a std::string.
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:57
A class for managing temporary objects.
Definition: HashPtrTable.H:50
virtual tmp< fvPatchField< vector > > clone() const
Return a clone.
Namespace for OpenFOAM.