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