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-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::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 Usage
52  \table
53  Property | Description | Required | Default value
54  valueFraction | weight field | yes |
55  refValue | fixed value | yes |
56  refGrad | patch normal gradient | yes |
57  \endtable
58 
59 Note
60  This condition is not usually applied directly; instead, use a derived
61  mixed condition such as \c inletOutlet
62 
63 See also
64  Foam::inletOutletFvPatchField
65 
66 SourceFiles
67  mixedFvPatchField.C
68 
69 \*---------------------------------------------------------------------------*/
70 
71 #ifndef mixedFvPatchField_H
72 #define mixedFvPatchField_H
73 
74 #include "fvPatchField.H"
75 
76 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
77 
78 namespace Foam
79 {
80 
81 /*---------------------------------------------------------------------------*\
82  Class mixedFvPatchField Declaration
83 \*---------------------------------------------------------------------------*/
84 
85 template<class Type>
86 class mixedFvPatchField
87 :
88  public fvPatchField<Type>
89 {
90  // Private data
91 
92  //- Value field
93  Field<Type> refValue_;
94 
95  //- Normal gradient field
96  Field<Type> refGrad_;
97 
98  //- Fraction (0-1) of value used for boundary condition
99  scalarField valueFraction_;
100 
101 
102 public:
103 
104  //- Runtime type information
105  TypeName("mixed");
106 
107 
108  // Constructors
109 
110  //- Construct from patch and internal field
112  (
113  const fvPatch&,
114  const DimensionedField<Type, volMesh>&
115  );
116 
117  //- Construct from patch, internal field and dictionary
119  (
120  const fvPatch&,
121  const DimensionedField<Type, volMesh>&,
122  const dictionary&
123  );
124 
125  //- Construct by mapping the given mixedFvPatchField onto a new patch
127  (
129  const fvPatch&,
131  const fvPatchFieldMapper&
132  );
133 
134  //- Construct as copy
136  (
138  );
139 
140  //- Construct and return a clone
141  virtual tmp<fvPatchField<Type>> clone() const
142  {
143  return tmp<fvPatchField<Type>>
144  (
145  new mixedFvPatchField<Type>(*this)
146  );
147  }
148 
149  //- Construct as copy setting internal field reference
151  (
154  );
155 
156  //- Construct and return a clone setting internal field reference
158  (
160  ) const
161  {
162  return tmp<fvPatchField<Type>>
163  (
164  new mixedFvPatchField<Type>(*this, iF)
165  );
166  }
167 
168 
169  // Member functions
170 
171  // Access
172 
173  //- Return true if this patch field fixes a value.
174  // Needed to check if a level has to be specified while solving
175  // Poissons equations.
176  virtual bool fixesValue() const
177  {
178  return true;
179  }
181  //- Return false: this patch field is not altered by assignment
182  virtual bool assignable() const
183  {
184  return false;
185  }
186 
187 
188  // Return defining fields
189 
190  virtual Field<Type>& refValue()
191  {
192  return refValue_;
193  }
194 
195  virtual const Field<Type>& refValue() const
196  {
197  return refValue_;
198  }
199 
200  virtual Field<Type>& refGrad()
201  {
202  return refGrad_;
203  }
204 
205  virtual const Field<Type>& refGrad() const
206  {
207  return refGrad_;
208  }
209 
210  virtual scalarField& valueFraction()
211  {
212  return valueFraction_;
213  }
214 
215  virtual const scalarField& valueFraction() const
216  {
217  return valueFraction_;
218  }
219 
220 
221  // Mapping functions
222 
223  //- Map (and resize as needed) from self given a mapping object
224  virtual void autoMap
225  (
226  const fvPatchFieldMapper&
227  );
228 
229  //- Reverse map the given fvPatchField onto this fvPatchField
230  virtual void rmap
231  (
232  const fvPatchField<Type>&,
233  const labelList&
234  );
235 
236 
237  // Evaluation functions
238 
239  //- Return gradient at boundary
240  virtual tmp<Field<Type>> snGrad() const;
241 
242  //- Evaluate the patch field
243  virtual void evaluate
244  (
245  const Pstream::commsTypes commsType=Pstream::blocking
246  );
247 
248  //- Return the matrix diagonal coefficients corresponding to the
249  // evaluation of the value of this patchField with given weights
251  (
252  const tmp<scalarField>&
253  ) const;
255  //- Return the matrix source coefficients corresponding to the
256  // evaluation of the value of this patchField with given weights
258  (
259  const tmp<scalarField>&
260  ) const;
261 
262  //- Return the matrix diagonal coefficients corresponding to the
263  // evaluation of the gradient of this patchField
264  virtual tmp<Field<Type>> gradientInternalCoeffs() const;
265 
266  //- Return the matrix source coefficients corresponding to the
267  // evaluation of the gradient of this patchField
268  virtual tmp<Field<Type>> gradientBoundaryCoeffs() const;
269 
270 
271  //- Write
272  virtual void write(Ostream&) const;
273 
274 
275  // Member operators
276 
277  virtual void operator=(const UList<Type>&) {}
278 
279  virtual void operator=(const fvPatchField<Type>&) {}
280  virtual void operator+=(const fvPatchField<Type>&) {}
281  virtual void operator-=(const fvPatchField<Type>&) {}
282  virtual void operator*=(const fvPatchField<scalar>&) {}
283  virtual void operator/=(const fvPatchField<scalar>&) {}
284 
285  virtual void operator+=(const Field<Type>&) {}
286  virtual void operator-=(const Field<Type>&) {}
287 
288  virtual void operator*=(const Field<scalar>&) {}
289  virtual void operator/=(const Field<scalar>&) {}
290 
291  virtual void operator=(const Type&) {}
292  virtual void operator+=(const Type&) {}
293  virtual void operator-=(const Type&) {}
294  virtual void operator*=(const scalar) {}
295  virtual void operator/=(const scalar) {}
296 };
297 
298 
299 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
300 
301 } // End namespace Foam
302 
303 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
304 
305 #ifdef NoRepository
306  #include "mixedFvPatchField.C"
307 #endif
308 
309 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
310 
311 #endif
312 
313 // ************************************************************************* //
virtual void operator=(const UList< Type > &)
commsTypes
Types of communications.
Definition: UPstream.H:64
virtual tmp< Field< Type > > snGrad() const
Return gradient at boundary.
virtual void operator-=(const fvPatchField< Type > &)
virtual tmp< fvPatchField< Type > > clone() const
Construct and return a clone.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
virtual tmp< Field< Type > > gradientInternalCoeffs() const
Return the matrix diagonal coefficients corresponding to the.
This boundary condition provides a base class for &#39;mixed&#39; type boundary conditions, i.e. conditions that mix fixed value and patch-normal gradient conditions.
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:65
virtual bool fixesValue() const
Return true if this patch field fixes a value.
virtual Field< Type > & refValue()
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::blocking)
Evaluate the patch field.
virtual void operator+=(const fvPatchField< Type > &)
Pre-declare SubField and related Field type.
Definition: Field.H:57
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
virtual scalarField & valueFraction()
Foam::fvPatchFieldMapper.
virtual tmp< Field< Type > > valueInternalCoeffs(const tmp< scalarField > &) const
Return the matrix diagonal coefficients corresponding to the.
virtual bool assignable() const
Return false: this patch field is not altered by assignment.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
virtual void rmap(const fvPatchField< Type > &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
virtual tmp< Field< Type > > gradientBoundaryCoeffs() const
Return the matrix source coefficients corresponding to the.
virtual void operator*=(const fvPatchField< scalar > &)
virtual void write(Ostream &) const
Write.
mixedFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
virtual tmp< Field< Type > > valueBoundaryCoeffs(const tmp< scalarField > &) const
Return the matrix source coefficients corresponding to the.
A class for managing temporary objects.
Definition: PtrList.H:54
virtual void operator/=(const fvPatchField< scalar > &)
virtual Field< Type > & refGrad()
Namespace for OpenFOAM.
TypeName("mixed")
Runtime type information.
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.