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-2015 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  \heading Patch usage
52 
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  myPatch
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
172  virtual tmp<fvPatchField<Type> > clone
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 
213 
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 // ************************************************************************* //
Foam::advectiveFvPatchField::fieldInf
const Type & fieldInf() const
Return the field at infinity.
Definition: advectiveFvPatchField.H:213
Foam::advectiveFvPatchField::fieldInf_
Type fieldInf_
Field value of the far-field.
Definition: advectiveFvPatchField.H:134
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:118
Foam::advectiveFvPatchField::TypeName
TypeName("advective")
Runtime type information.
Foam::advectiveFvPatchField::rhoName_
word rhoName_
Name of the density field used to normalise the mass flux.
Definition: advectiveFvPatchField.H:131
Foam::advectiveFvPatchField::fieldInf
Type & fieldInf()
Return reference to the field at infinity to allow adjustment.
Definition: advectiveFvPatchField.H:219
Foam::advectiveFvPatchField::lInf
scalar lInf() const
Return the relaxation length-scale.
Definition: advectiveFvPatchField.H:225
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
Foam::advectiveFvPatchField::write
virtual void write(Ostream &) const
Write.
Definition: advectiveFvPatchField.C:338
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::advectiveFvPatchField::updateCoeffs
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: advectiveFvPatchField.C:186
Foam::mixedFvPatchField
This boundary condition provides a base class for 'mixed' type boundary conditions,...
Definition: mixedFvPatchField.H:126
mixedFvPatchFields.H
Foam::advectiveFvPatchField::advectiveFvPatchField
advectiveFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
Definition: advectiveFvPatchField.C:40
advectiveFvPatchField.C
Foam::fvPatchFieldMapper
Foam::fvPatchFieldMapper.
Definition: fvPatchFieldMapper.H:45
Foam::advectiveFvPatchField::clone
virtual tmp< fvPatchField< Type > > clone() const
Construct and return a clone.
Definition: advectiveFvPatchField.H:180
Foam::advectiveFvPatchField::advectionSpeed
virtual tmp< scalarField > advectionSpeed() const
Calculate and return the advection speed at the boundary.
Definition: advectiveFvPatchField.C:156
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::advectiveFvPatchField::lInf_
scalar lInf_
Relaxation length-scale.
Definition: advectiveFvPatchField.H:137
Foam::advectiveFvPatchField
This boundary condition provides an advective outflow condition, based on solving DDt(psi,...
Definition: advectiveFvPatchField.H:118
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:51
Foam::advectiveFvPatchField::phiName_
word phiName_
Name of the flux transporting the field.
Definition: advectiveFvPatchField.H:127