mixedFvPatchField.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-2012 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::mixedFvPatchField
26 
27 Group
28  grpGenericBoundaryConditions
29 
30 Description
31  This boundary condition provides a base class for 'mixed' type boundary
32  conditions, i.e. conditions that mix fixed value and patch-normal gradient
33  conditions.
34 
35  The respective contributions from each is determined by a weight field:
36 
37  \f[
38  x_p = w x_p + (1-w) \left(x_c + \frac{\nabla_\perp x}{\Delta}\right)
39  \f]
40 
41  where
42  \vartable
43  x_p | patch values
44  x_c | patch internal cell values
45  w | weight field
46  \Delta| inverse distance from face centre to internal cell centre
47  w | weighting (0-1)
48  \endvartable
49 
50 
51  \heading Patch usage
52 
53  \table
54  Property | Description | Required | Default value
55  valueFraction | weight field | yes |
56  refValue | fixed value | yes |
57  refGrad | patch normal gradient | yes |
58  \endtable
59 
60 Note
61  This condition is not usually applied directly; instead, use a derived
62  mixed condition such as \c inletOutlet
63 
64 SeeAlso
65  Foam::inletOutletFvPatchField
66 
67 SourceFiles
68  mixedFvPatchField.C
69 
70 \*---------------------------------------------------------------------------*/
71 
72 #ifndef mixedFvPatchField_H
73 #define mixedFvPatchField_H
74 
75 #include "fvPatchField.H"
76 
77 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
78 
79 namespace Foam
80 {
81 
82 /*---------------------------------------------------------------------------*\
83  Class mixedFvPatchField Declaration
84 \*---------------------------------------------------------------------------*/
85 
86 template<class Type>
87 class mixedFvPatchField
88 :
89  public fvPatchField<Type>
90 {
91  // Private data
92 
93  //- Value field
94  Field<Type> refValue_;
95 
96  //- Normal gradient field
97  Field<Type> refGrad_;
98 
99  //- Fraction (0-1) of value used for boundary condition
101 
102 
103 public:
104 
105  //- Runtime type information
106  TypeName("mixed");
107 
108 
109  // Constructors
110 
111  //- Construct from patch and internal field
113  (
114  const fvPatch&,
115  const DimensionedField<Type, volMesh>&
116  );
117 
118  //- Construct from patch, internal field and dictionary
120  (
121  const fvPatch&,
122  const DimensionedField<Type, volMesh>&,
123  const dictionary&
124  );
125 
126  //- Construct by mapping the given mixedFvPatchField onto a new patch
128  (
130  const fvPatch&,
132  const fvPatchFieldMapper&
133  );
134 
135  //- Construct as copy
137  (
139  );
140 
141  //- Construct and return a clone
142  virtual tmp<fvPatchField<Type> > clone() const
143  {
144  return tmp<fvPatchField<Type> >
145  (
146  new mixedFvPatchField<Type>(*this)
147  );
148  }
149 
150  //- Construct as copy setting internal field reference
152  (
155  );
156 
157  //- Construct and return a clone setting internal field reference
158  virtual tmp<fvPatchField<Type> > clone
159  (
161  ) const
162  {
163  return tmp<fvPatchField<Type> >
164  (
165  new mixedFvPatchField<Type>(*this, iF)
166  );
167  }
168 
169 
170  // Member functions
171 
172  // Access
173 
174  //- Return true if this patch field fixes a value.
175  // Needed to check if a level has to be specified while solving
176  // Poissons equations.
177  virtual bool fixesValue() const
178  {
179  return true;
180  }
181 
182 
183  // Return defining fields
184 
185  virtual Field<Type>& refValue()
186  {
187  return refValue_;
188  }
189 
190  virtual const Field<Type>& refValue() const
191  {
192  return refValue_;
193  }
194 
195  virtual Field<Type>& refGrad()
196  {
197  return refGrad_;
198  }
199 
200  virtual const Field<Type>& refGrad() const
201  {
202  return refGrad_;
203  }
204 
205  virtual scalarField& valueFraction()
206  {
207  return valueFraction_;
208  }
209 
210  virtual const scalarField& valueFraction() const
211  {
212  return valueFraction_;
213  }
214 
215 
216  // Mapping functions
217 
218  //- Map (and resize as needed) from self given a mapping object
219  virtual void autoMap
220  (
221  const fvPatchFieldMapper&
222  );
223 
224  //- Reverse map the given fvPatchField onto this fvPatchField
225  virtual void rmap
226  (
227  const fvPatchField<Type>&,
228  const labelList&
229  );
230 
231 
232  // Evaluation functions
233 
234  //- Return gradient at boundary
235  virtual tmp<Field<Type> > snGrad() const;
236 
237  //- Evaluate the patch field
238  virtual void evaluate
239  (
240  const Pstream::commsTypes commsType=Pstream::blocking
241  );
242 
243  //- Return the matrix diagonal coefficients corresponding to the
244  // evaluation of the value of this patchField with given weights
246  (
247  const tmp<scalarField>&
248  ) const;
249 
250  //- Return the matrix source coefficients corresponding to the
251  // evaluation of the value of this patchField with given weights
253  (
254  const tmp<scalarField>&
255  ) const;
256 
257  //- Return the matrix diagonal coefficients corresponding to the
258  // evaluation of the gradient of this patchField
259  virtual tmp<Field<Type> > gradientInternalCoeffs() const;
260 
261  //- Return the matrix source coefficients corresponding to the
262  // evaluation of the gradient of this patchField
263  virtual tmp<Field<Type> > gradientBoundaryCoeffs() const;
264 
265 
266  //- Write
267  virtual void write(Ostream&) const;
268 
269 
270  // Member operators
271 
272  virtual void operator=(const UList<Type>&) {}
273 
274  virtual void operator=(const fvPatchField<Type>&) {}
275  virtual void operator+=(const fvPatchField<Type>&) {}
276  virtual void operator-=(const fvPatchField<Type>&) {}
277  virtual void operator*=(const fvPatchField<scalar>&) {}
278  virtual void operator/=(const fvPatchField<scalar>&) {}
279 
280  virtual void operator+=(const Field<Type>&) {}
281  virtual void operator-=(const Field<Type>&) {}
282 
283  virtual void operator*=(const Field<scalar>&) {}
284  virtual void operator/=(const Field<scalar>&) {}
285 
286  virtual void operator=(const Type&) {}
287  virtual void operator+=(const Type&) {}
288  virtual void operator-=(const Type&) {}
289  virtual void operator*=(const scalar) {}
290  virtual void operator/=(const scalar) {}
291 };
292 
293 
294 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
295 
296 } // End namespace Foam
297 
298 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
299 
300 #ifdef NoRepository
301 # include "mixedFvPatchField.C"
302 #endif
303 
304 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
305 
306 #endif
307 
308 // ************************************************************************* //
Foam::fvPatchField
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:65
Foam::mixedFvPatchField::operator+=
virtual void operator+=(const Type &)
Definition: mixedFvPatchField.H:326
Foam::scalarField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Definition: primitiveFieldsFwd.H:48
Foam::mixedFvPatchField::valueFraction
virtual scalarField & valueFraction()
Definition: mixedFvPatchField.H:244
Foam::mixedFvPatchField::valueFraction
virtual const scalarField & valueFraction() const
Definition: mixedFvPatchField.H:249
Foam::mixedFvPatchField::refValue
virtual Field< Type > & refValue()
Definition: mixedFvPatchField.H:224
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:118
Foam::mixedFvPatchField::operator/=
virtual void operator/=(const scalar)
Definition: mixedFvPatchField.H:329
Foam::mixedFvPatchField::gradientInternalCoeffs
virtual tmp< Field< Type > > gradientInternalCoeffs() const
Return the matrix diagonal coefficients corresponding to the.
Definition: mixedFvPatchField.C:210
Foam::mixedFvPatchField::operator=
virtual void operator=(const fvPatchField< Type > &)
Definition: mixedFvPatchField.H:313
Foam::mixedFvPatchField::operator*=
virtual void operator*=(const Field< scalar > &)
Definition: mixedFvPatchField.H:322
Foam::mixedFvPatchField::operator=
virtual void operator=(const Type &)
Definition: mixedFvPatchField.H:325
Foam::mixedFvPatchField::operator*=
virtual void operator*=(const fvPatchField< scalar > &)
Definition: mixedFvPatchField.H:316
Foam::mixedFvPatchField::refGrad
virtual Field< Type > & refGrad()
Definition: mixedFvPatchField.H:234
Foam::mixedFvPatchField::clone
virtual tmp< fvPatchField< Type > > clone() const
Construct and return a clone.
Definition: mixedFvPatchField.H:181
Foam::mixedFvPatchField::refGrad
virtual const Field< Type > & refGrad() const
Definition: mixedFvPatchField.H:239
Foam::mixedFvPatchField::operator+=
virtual void operator+=(const fvPatchField< Type > &)
Definition: mixedFvPatchField.H:314
Foam::mixedFvPatchField::snGrad
virtual tmp< Field< Type > > snGrad() const
Return gradient at boundary.
Definition: mixedFvPatchField.C:176
Foam::mixedFvPatchField::valueFraction_
scalarField valueFraction_
Fraction (0-1) of value used for boundary condition.
Definition: mixedFvPatchField.H:139
Foam::UPstream::blocking
@ blocking
Definition: UPstream.H:66
Foam::mixedFvPatchField::operator/=
virtual void operator/=(const fvPatchField< scalar > &)
Definition: mixedFvPatchField.H:317
Foam::mixedFvPatchField::autoMap
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
Definition: mixedFvPatchField.C:123
Foam::Field< Type >
Foam::mixedFvPatchField::mixedFvPatchField
mixedFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
Definition: mixedFvPatchField.C:37
Foam::mixedFvPatchField::refValue_
Field< Type > refValue_
Value field.
Definition: mixedFvPatchField.H:133
Foam::mixedFvPatchField::operator*=
virtual void operator*=(const scalar)
Definition: mixedFvPatchField.H:328
Foam::mixedFvPatchField::valueBoundaryCoeffs
virtual tmp< Field< Type > > valueBoundaryCoeffs(const tmp< scalarField > &) const
Return the matrix source coefficients corresponding to the.
Definition: mixedFvPatchField.C:199
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
Foam::mixedFvPatchField::write
virtual void write(Ostream &) const
Write.
Definition: mixedFvPatchField.C:226
Foam::mixedFvPatchField::refGrad_
Field< Type > refGrad_
Normal gradient field.
Definition: mixedFvPatchField.H:136
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::mixedFvPatchField::gradientBoundaryCoeffs
virtual tmp< Field< Type > > gradientBoundaryCoeffs() const
Return the matrix source coefficients corresponding to the.
Definition: mixedFvPatchField.C:217
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::mixedFvPatchField
This boundary condition provides a base class for 'mixed' type boundary conditions,...
Definition: mixedFvPatchField.H:126
Foam::mixedFvPatchField::fixesValue
virtual bool fixesValue() const
Return true if this patch field fixes a value.
Definition: mixedFvPatchField.H:216
Foam::mixedFvPatchField::refValue
virtual const Field< Type > & refValue() const
Definition: mixedFvPatchField.H:229
Foam::mixedFvPatchField::operator+=
virtual void operator+=(const Field< Type > &)
Definition: mixedFvPatchField.H:319
Foam::UPstream::commsTypes
commsTypes
Types of communications.
Definition: UPstream.H:64
Foam::mixedFvPatchField::operator-=
virtual void operator-=(const Field< Type > &)
Definition: mixedFvPatchField.H:320
Foam::mixedFvPatchField::operator=
virtual void operator=(const UList< Type > &)
Definition: mixedFvPatchField.H:311
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::UList< Type >
Foam::mixedFvPatchField::valueInternalCoeffs
virtual tmp< Field< Type > > valueInternalCoeffs(const tmp< scalarField > &) const
Return the matrix diagonal coefficients corresponding to the.
Definition: mixedFvPatchField.C:188
Foam::mixedFvPatchField::operator/=
virtual void operator/=(const Field< scalar > &)
Definition: mixedFvPatchField.H:323
Foam::mixedFvPatchField::evaluate
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::blocking)
Evaluate the patch field.
Definition: mixedFvPatchField.C:153
Foam::fvPatchFieldMapper
Foam::fvPatchFieldMapper.
Definition: fvPatchFieldMapper.H:45
Foam::mixedFvPatchField::operator-=
virtual void operator-=(const fvPatchField< Type > &)
Definition: mixedFvPatchField.H:315
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
mixedFvPatchField.C
Foam::mixedFvPatchField::TypeName
TypeName("mixed")
Runtime type information.
Foam::mixedFvPatchField::rmap
virtual void rmap(const fvPatchField< Type > &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
Definition: mixedFvPatchField.C:136
Foam::mixedFvPatchField::operator-=
virtual void operator-=(const Type &)
Definition: mixedFvPatchField.H:327
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:51
fvPatchField.H