FreeFOAM The Cross-Platform CFD Toolkit
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) 1991-2010 OpenCFD Ltd.
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  Advective outflow boundary condition based on solving DDt(psi, U) = 0
29  at the boundary.
30 
31  The standard (Euler, backward, CrankNicholson) time schemes are
32  supported. Additionally an optional mechanism to relax the value at
33  the boundary to a specified far-field value is provided which is
34  switched on by specifying the relaxation length-scale lInf and the
35  far-field value fieldInf.
36 
37  The flow/wave speed at the outlet is provided by the virtual function
38  advectionSpeed() the default implementation of which requires the name of
39  flux field a the outlet (phi) and optionally the density (rho) if the
40  mass-flux rather than the volumetric-flux is given.
41  @verbatim
42  outlet
43  {
44  type advective;
45  phi phi;
46  // rho rho; // Not needed, phi volumetric
47  // fieldInf 1e5; // Optional
48  // lInf 0.1; // Optional
49  }
50  @endverbatim
51 
52  The flow/wave speed at the outlet can be changed by deriving a specialised
53  BC fron this class and overriding advectionSpeed() e.g. in
54  waveTransmissiveFvPatchField the advectionSpeed() calculates and returns
55  the flow-speed plus the acoustic wave speed creating an acoustic wave
56  transmissive boundary condition.
57 
58 SourceFiles
59  advectiveFvPatchField.C
60 
61 \*---------------------------------------------------------------------------*/
62 
63 #ifndef advectiveFvPatchField_H
64 #define advectiveFvPatchField_H
65 
67 
68 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
69 
70 namespace Foam
71 {
72 
73 /*---------------------------------------------------------------------------*\
74  Class advectiveFvPatch Declaration
75 \*---------------------------------------------------------------------------*/
76 
77 template<class Type>
79 :
80  public mixedFvPatchField<Type>
81 {
82 protected:
83 
84  // Private data
85 
86  //- Name of the flux transporting the field
88 
89  //- Name of the density field used to normalise the mass flux
90  // if neccessary
92 
93  //- Field value of the far-field
94  Type fieldInf_;
95 
96  //- Relaxation length-scale
97  scalar lInf_;
98 
99 
100 public:
101 
102  //- Runtime type information
103  TypeName("advective");
104 
105 
106  // Constructors
107 
108  //- Construct from patch and internal field
110  (
111  const fvPatch&,
113  );
114 
115  //- Construct from patch, internal field and dictionary
117  (
118  const fvPatch&,
120  const dictionary&
121  );
122 
123  //- Construct by mapping given advectiveFvPatchField
124  // onto a new patch
126  (
128  const fvPatch&,
130  const fvPatchFieldMapper&
131  );
132 
133  //- Construct as copy
135  (
136  const advectiveFvPatchField&
137  );
138 
139  //- Construct and return a clone
140  virtual tmp<fvPatchField<Type> > clone() const
141  {
142  return tmp<fvPatchField<Type> >
143  (
144  new advectiveFvPatchField<Type>(*this)
145  );
146  }
147 
148  //- Construct as copy setting internal field reference
150  (
151  const advectiveFvPatchField&,
153  );
154 
155  //- Construct and return a clone setting internal field reference
156  virtual tmp<fvPatchField<Type> > clone
157  (
159  ) const
160  {
161  return tmp<fvPatchField<Type> >
162  (
163  new advectiveFvPatchField<Type>(*this, iF)
164  );
165  }
166 
167 
168  // Member functions
169 
170  // Access
171 
172  //- Return the field at infinity
173  const Type& fieldInf() const
174  {
175  return fieldInf_;
176  }
177 
178  //- Return reference to the field at infinity to allow adjustment
179  Type& fieldInf()
180  {
181  return fieldInf_;
182  }
183 
184  //- Return the relaxation length-scale
185  scalar lInf() const
186  {
187  return lInf_;
188  }
189 
190  //- Return reference to the relaxation length-scale
191  // to allow adjustment
192  scalar& lInf()
193  {
194  return lInf_;
195  }
196 
197 
198  // Evaluation functions
199 
200  //- Calculate and return the advection speed at the boundary
201  virtual tmp<scalarField> advectionSpeed() const;
202 
203  //- Update the coefficients associated with the patch field
204  virtual void updateCoeffs();
205 
206 
207  //- Write
208  virtual void write(Ostream&) const;
209 };
210 
211 
212 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
213 
214 } // End namespace Foam
215 
216 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
217 
218 #ifdef NoRepository
220 #endif
221 
222 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
223 
224 #endif
225 
226 // ************************ vim: set sw=4 sts=4 et: ************************ //