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