All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
advectiveFvPatchField.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-2020 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::advectiveFvPatchField
26 
27 Description
28  This boundary condition provides an advective outflow condition, based on
29  solving DDt(W, field) = 0 at the boundary where \c W is the wave velocity
30  and \c field is the field to which this boundary condition is applied.
31 
32  The standard (Euler, backward, CrankNicolson, localEuler) time schemes are
33  supported. Additionally an optional mechanism to relax the value at
34  the boundary to a specified far-field value is provided which is
35  switched on by specifying the relaxation length-scale \c lInf and the
36  far-field value \c fieldInf.
37 
38  The flow/wave speed \c (w) at the outlet is provided by the virtual function
39  advectionSpeed() the default implementation of which requires the name of
40  the flux field \c (phi) and optionally the density \c (rho) if the
41  mass-flux rather than the volumetric-flux is given.
42 
43  The flow/wave speed at the outlet can be changed by deriving a specialised
44  BC from this class and over-riding advectionSpeed() e.g. in
45  waveTransmissiveFvPatchField the advectionSpeed() calculates and returns
46  the flow-speed plus the acoustic wave speed creating an acoustic wave
47  transmissive boundary condition.
48 
49 Usage
50  \table
51  Property | Description | Required | Default value
52  phi | flux field name | no | phi
53  rho | density field name | no | rho
54  fieldInf | value of field beyond patch | no |
55  lInf | distance beyond patch for \c fieldInf | no |
56  \endtable
57 
58  Example of the boundary condition specification:
59  \verbatim
60  <patchName>
61  {
62  type advective;
63  phi phi;
64  }
65  \endverbatim
66 
67 Note
68  If \c lInf is specified, \c fieldInf will be required; \c rho is only
69  required in the case of a mass-based flux.
70 
71 SourceFiles
72  advectiveFvPatchField.C
73 
74 \*---------------------------------------------------------------------------*/
75 
76 #ifndef advectiveFvPatchField_H
77 #define advectiveFvPatchField_H
78 
79 #include "mixedFvPatchFields.H"
80 
81 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
82 
83 namespace Foam
84 {
85 
86 /*---------------------------------------------------------------------------*\
87  Class advectiveFvPatchField Declaration
88 \*---------------------------------------------------------------------------*/
89 
90 template<class Type>
91 class advectiveFvPatchField
92 :
93  public mixedFvPatchField<Type>
94 {
95 protected:
96 
97  // Private Data
98 
99  //- Name of the flux transporting the field
100  word phiName_;
101 
102  //- Name of the density field used to normalise the mass flux
103  // if necessary
104  word rhoName_;
105 
106  //- Field value of the far-field
107  Type fieldInf_;
108 
109  //- Relaxation length-scale
110  scalar lInf_;
111 
112 
113 public:
114 
115  //- Runtime type information
116  TypeName("advective");
117 
118 
119  // Constructors
120 
121  //- Construct from patch and internal field
123  (
124  const fvPatch&,
126  );
127 
128  //- Construct from patch, internal field and dictionary
130  (
131  const fvPatch&,
133  const dictionary&
134  );
135 
136  //- Construct by mapping given advectiveFvPatchField
137  // onto a new patch
139  (
141  const fvPatch&,
143  const fvPatchFieldMapper&
144  );
145 
146  //- Disallow copy without setting internal field reference
148 
149  //- Copy constructor setting internal field reference
151  (
152  const advectiveFvPatchField&,
154  );
155 
156  //- Construct and return a clone setting internal field reference
158  (
160  ) const
161  {
162  return tmp<fvPatchField<Type>>
163  (
164  new advectiveFvPatchField<Type>(*this, iF)
165  );
166  }
167 
168 
169  // Member Functions
170 
171  // Access
172 
173  //- Return the field at infinity
174  const Type& fieldInf() const
175  {
176  return fieldInf_;
177  }
178 
179  //- Return reference to the field at infinity to allow adjustment
180  Type& fieldInf()
181  {
182  return fieldInf_;
183  }
184 
185  //- Return the relaxation length-scale
186  scalar lInf() const
187  {
188  return lInf_;
189  }
190 
191  //- Return reference to the relaxation length-scale
192  // to allow adjustment
193  scalar& lInf()
194  {
195  return lInf_;
196  }
197 
199  // Evaluation functions
200 
201  //- Calculate and return the advection speed at the boundary
202  virtual tmp<scalarField> advectionSpeed() const;
203 
204  //- Update the coefficients associated with the patch field
205  virtual void updateCoeffs();
206 
207 
208  //- Write
209  virtual void write(Ostream&) const;
210 };
211 
212 
213 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
214 
215 } // End namespace Foam
216 
217 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
218 
219 #ifdef NoRepository
220  #include "advectiveFvPatchField.C"
221 #endif
222 
223 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
224 
225 #endif
226 
227 // ************************************************************************* //
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
word phiName_
Name of the flux transporting the field.
scalar lInf_
Relaxation length-scale.
word rhoName_
Name of the density field used to normalise the mass flux.
Type fieldInf_
Field value of the far-field.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:62
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
advectiveFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
Foam::fvPatchFieldMapper.
virtual tmp< scalarField > advectionSpeed() const
Calculate and return the advection speed at the boundary.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
scalar lInf() const
Return the relaxation length-scale.
virtual void write(Ostream &) const
Write.
const Type & fieldInf() const
Return the field at infinity.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
This boundary condition provides an advective outflow condition, based on solving DDt(W...
A class for managing temporary objects.
Definition: PtrList.H:53
TypeName("advective")
Runtime type information.
tmp< fvPatchField< Type > > clone() const
Disallow clone without setting internal field reference.
Definition: fvPatchField.H:199
Namespace for OpenFOAM.