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