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-2019 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  //- Copy constructor
148  (
149  const advectiveFvPatchField&
150  );
151 
152  //- Construct and return a clone
153  virtual tmp<fvPatchField<Type>> clone() const
154  {
155  return tmp<fvPatchField<Type>>
156  (
157  new advectiveFvPatchField<Type>(*this)
158  );
159  }
160 
161  //- Copy constructor setting internal field reference
163  (
164  const advectiveFvPatchField&,
166  );
167 
168  //- Construct and return a clone setting internal field reference
170  (
172  ) const
173  {
174  return tmp<fvPatchField<Type>>
175  (
176  new advectiveFvPatchField<Type>(*this, iF)
177  );
178  }
179 
180 
181  // Member Functions
182 
183  // Access
184 
185  //- Return the field at infinity
186  const Type& fieldInf() const
187  {
188  return fieldInf_;
189  }
190 
191  //- Return reference to the field at infinity to allow adjustment
192  Type& fieldInf()
193  {
194  return fieldInf_;
195  }
196 
197  //- Return the relaxation length-scale
198  scalar lInf() const
199  {
200  return lInf_;
201  }
202 
203  //- Return reference to the relaxation length-scale
204  // to allow adjustment
205  scalar& lInf()
206  {
207  return lInf_;
208  }
209 
211  // Evaluation functions
212 
213  //- Calculate and return the advection speed at the boundary
214  virtual tmp<scalarField> advectionSpeed() const;
215 
216  //- Update the coefficients associated with the patch field
217  virtual void updateCoeffs();
218 
219 
220  //- Write
221  virtual void write(Ostream&) const;
222 };
223 
224 
225 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
226 
227 } // End namespace Foam
228 
229 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
230 
231 #ifdef NoRepository
232  #include "advectiveFvPatchField.C"
233 #endif
234 
235 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
236 
237 #endif
238 
239 // ************************************************************************* //
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
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:61
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.
virtual tmp< fvPatchField< Type > > clone() const
Construct and return a clone.
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.
Namespace for OpenFOAM.