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-2023 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, internal field and dictionary
123  (
124  const fvPatch&,
126  const dictionary&
127  );
128 
129  //- Construct by mapping given advectiveFvPatchField
130  // onto a new patch
132  (
134  const fvPatch&,
136  const fieldMapper&
137  );
138 
139  //- Disallow copy without setting internal field reference
141 
142  //- Copy constructor setting internal field reference
144  (
145  const advectiveFvPatchField&,
147  );
148 
149  //- Construct and return a clone setting internal field reference
151  (
153  ) const
154  {
156  (
157  new advectiveFvPatchField<Type>(*this, iF)
158  );
159  }
160 
161 
162  // Member Functions
163 
164  // Access
165 
166  //- Return the field at infinity
167  const Type& fieldInf() const
168  {
169  return fieldInf_;
170  }
171 
172  //- Return reference to the field at infinity to allow adjustment
173  Type& fieldInf()
174  {
175  return fieldInf_;
176  }
177 
178  //- Return the relaxation length-scale
179  scalar lInf() const
180  {
181  return lInf_;
182  }
183 
184  //- Return reference to the relaxation length-scale
185  // to allow adjustment
186  scalar& lInf()
187  {
188  return lInf_;
189  }
190 
191 
192  // Evaluation functions
193 
194  //- Calculate and return the advection speed at the boundary
195  virtual tmp<scalarField> advectionSpeed() const;
196 
197  //- Update the coefficients associated with the patch field
198  virtual void updateCoeffs();
199 
200 
201  //- Write
202  virtual void write(Ostream&) const;
203 };
204 
205 
206 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
207 
208 } // End namespace Foam
209 
210 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
211 
212 #ifdef NoRepository
213  #include "advectiveFvPatchField.C"
214 #endif
215 
216 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
217 
218 #endif
219 
220 // ************************************************************************* //
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
This boundary condition provides an advective outflow condition, based on solving DDt(W,...
TypeName("advective")
Runtime type information.
advectiveFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &, const dictionary &)
Construct from patch, internal field and dictionary.
virtual void write(Ostream &) const
Write.
scalar lInf_
Relaxation length-scale.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
word phiName_
Name of the flux transporting the field.
Type fieldInf_
Field value of the far-field.
word rhoName_
Name of the density field used to normalise the mass flux.
virtual tmp< scalarField > advectionSpeed() const
Calculate and return the advection speed at the boundary.
scalar lInf() const
Return the relaxation length-scale.
const Type & fieldInf() const
Return the field at infinity.
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
Abstract base class for field mapping.
Definition: fieldMapper.H:48
tmp< fvPatchField< Type > > clone() const
Disallow clone without setting internal field reference.
Definition: fvPatchField.H:204
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:64
A class for managing temporary objects.
Definition: tmp.H:55
Namespace for OpenFOAM.