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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2017 OpenFOAM Foundation
9  Copyright (C) 2019 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::mixedFvPatchField
29 
30 Group
31  grpGenericBoundaryConditions
32 
33 Description
34  This boundary condition provides a base class for 'mixed' type boundary
35  conditions, i.e. conditions that mix fixed value and patch-normal gradient
36  conditions.
37 
38  The respective contributions from each is determined by a weight field:
39 
40  \f[
41  x_p = w x_p + (1-w) \left(x_c + \frac{\nabla_\perp x}{\Delta}\right)
42  \f]
43 
44  where
45  \vartable
46  x_p | patch values
47  x_c | patch internal cell values
48  \Delta| inverse distance from face centre to internal cell centre
49  w | weighting values (0-1)
50  \endvartable
51 
52 
53 Usage
54  \table
55  Property | Description | Required | Default
56  refValue | fixed value | yes |
57  refGradient | patch normal gradient | yes |
58  valueFraction | value weighting (0-1) | yes |
59  \endtable
60 
61 Note
62  This condition is not usually applied directly; instead, use a derived
63  mixed condition such as \c inletOutlet
64 
65 See also
66  Foam::inletOutletFvPatchField
67 
68 SourceFiles
69  mixedFvPatchField.C
70 
71 \*---------------------------------------------------------------------------*/
72 
73 #ifndef mixedFvPatchField_H
74 #define mixedFvPatchField_H
75 
76 #include "fvPatchField.H"
77 
78 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
79 
80 namespace Foam
81 {
82 
83 /*---------------------------------------------------------------------------*\
84  Class mixedFvPatchField Declaration
85 \*---------------------------------------------------------------------------*/
86 
87 template<class Type>
88 class mixedFvPatchField
89 :
90  public fvPatchField<Type>
91 {
92  // Private data
93 
94  //- Value field
95  Field<Type> refValue_;
96 
97  //- Normal gradient field
98  Field<Type> refGrad_;
99 
100  //- Fraction (0-1) of value used for boundary condition
101  scalarField valueFraction_;
102 
103  //- Source field
104  Field<Type> source_;
105 
106 
107 public:
108 
109  //- Runtime type information
110  TypeName("mixed");
111 
112 
113  // Constructors
114 
115  //- Construct from patch and internal field
117  (
118  const fvPatch&,
119  const DimensionedField<Type, volMesh>&
120  );
121 
122  //- Construct from patch, internal field and dictionary
124  (
125  const fvPatch&,
127  const dictionary&
128  );
129 
130  //- Construct by mapping the given mixedFvPatchField onto a new patch
132  (
134  const fvPatch&,
136  const fvPatchFieldMapper&
137  );
138 
139  //- Construct as copy
141  (
143  );
144 
145  //- Construct and return a clone
146  virtual tmp<fvPatchField<Type>> clone() const
147  {
148  return tmp<fvPatchField<Type>>
149  (
150  new mixedFvPatchField<Type>(*this)
151  );
152  }
153 
154  //- Construct as copy setting internal field reference
156  (
159  );
160 
161  //- Construct and return a clone setting internal field reference
163  (
165  ) const
166  {
167  return tmp<fvPatchField<Type>>
168  (
169  new mixedFvPatchField<Type>(*this, iF)
170  );
171  }
172 
173 
174  // Member functions
175 
176  // Access
177 
178  //- Return true if this patch field fixes a value.
179  // Needed to check if a level has to be specified while solving
180  // Poissons equations.
181  virtual bool fixesValue() const
182  {
183  return true;
184  }
185 
186  //- Return false: this patch field is not altered by assignment
187  virtual bool assignable() const
188  {
189  return false;
190  }
191 
192 
193  // Return defining fields
194 
195  virtual Field<Type>& refValue()
196  {
197  return refValue_;
198  }
199 
200  virtual const Field<Type>& refValue() const
201  {
202  return refValue_;
203  }
204 
205  virtual Field<Type>& refGrad()
206  {
207  return refGrad_;
208  }
209 
210  virtual const Field<Type>& refGrad() const
211  {
212  return refGrad_;
213  }
214 
215  virtual scalarField& valueFraction()
216  {
217  return valueFraction_;
218  }
219 
220  virtual const scalarField& valueFraction() const
221  {
222  return valueFraction_;
223  }
224 
225  virtual Field<Type>& source()
226  {
227  return source_;
228  }
229 
230  virtual const Field<Type>& source() const
231  {
232  return source_;
233  }
234 
235 
236  // Mapping functions
237 
238  //- Map (and resize as needed) from self given a mapping object
239  virtual void autoMap
240  (
241  const fvPatchFieldMapper&
242  );
243 
244  //- Reverse map the given fvPatchField onto this fvPatchField
245  virtual void rmap
246  (
247  const fvPatchField<Type>&,
248  const labelList&
249  );
250 
251 
252  // Evaluation functions
253 
254  //- Return gradient at boundary
255  virtual tmp<Field<Type>> snGrad() const;
256 
257  //- Evaluate the patch field
258  virtual void evaluate
259  (
260  const Pstream::commsTypes commsType =
262  );
263 
264  //- Return the matrix diagonal coefficients corresponding to the
265  // evaluation of the value of this patchField with given weights
267  (
268  const tmp<scalarField>&
269  ) const;
270 
271  //- Return the matrix source coefficients corresponding to the
272  // evaluation of the value of this patchField with given weights
274  (
275  const tmp<scalarField>&
276  ) const;
277 
278  //- Return the matrix diagonal coefficients corresponding to the
279  // evaluation of the gradient of this patchField
280  virtual tmp<Field<Type>> gradientInternalCoeffs() const;
281 
282  //- Return the matrix source coefficients corresponding to the
283  // evaluation of the gradient of this patchField
284  virtual tmp<Field<Type>> gradientBoundaryCoeffs() const;
285 
286 
287  //- Write
288  virtual void write(Ostream&) const;
289 
290 
291  // Member operators
292 
293  virtual void operator=(const UList<Type>&) {}
294 
295  virtual void operator=(const fvPatchField<Type>&) {}
296  virtual void operator+=(const fvPatchField<Type>&) {}
297  virtual void operator-=(const fvPatchField<Type>&) {}
298  virtual void operator*=(const fvPatchField<scalar>&) {}
299  virtual void operator/=(const fvPatchField<scalar>&) {}
300 
301  virtual void operator+=(const Field<Type>&) {}
302  virtual void operator-=(const Field<Type>&) {}
303 
304  virtual void operator*=(const Field<scalar>&) {}
305  virtual void operator/=(const Field<scalar>&) {}
306 
307  virtual void operator=(const Type&) {}
308  virtual void operator+=(const Type&) {}
309  virtual void operator-=(const Type&) {}
310  virtual void operator*=(const scalar) {}
311  virtual void operator/=(const scalar) {}
312 };
313 
314 
315 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
316 
317 } // End namespace Foam
318 
319 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
320 
321 #ifdef NoRepository
322  #include "mixedFvPatchField.C"
323 #endif
324 
325 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
326 
327 #endif
328 
329 // ************************************************************************* //
Foam::fvPatchField
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: volSurfaceMapping.H:51
Foam::mixedFvPatchField::operator+=
virtual void operator+=(const Type &)
Definition: mixedFvPatchField.H:343
Foam::scalarField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Definition: primitiveFieldsFwd.H:52
Foam::mixedFvPatchField::valueFraction
virtual scalarField & valueFraction()
Definition: mixedFvPatchField.H:250
Foam::mixedFvPatchField::valueFraction
virtual const scalarField & valueFraction() const
Definition: mixedFvPatchField.H:255
Foam::mixedFvPatchField::refValue
virtual Field< Type > & refValue()
Definition: mixedFvPatchField.H:230
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::mixedFvPatchField::operator/=
virtual void operator/=(const scalar)
Definition: mixedFvPatchField.H:346
Foam::mixedFvPatchField::assignable
virtual bool assignable() const
Return false: this patch field is not altered by assignment.
Definition: mixedFvPatchField.H:222
Foam::mixedFvPatchField::operator=
virtual void operator=(const fvPatchField< Type > &)
Definition: mixedFvPatchField.H:330
Foam::mixedFvPatchField::valueInternalCoeffs
virtual tmp< Field< Type > > valueInternalCoeffs(const tmp< scalarField > &) const
Return the matrix diagonal coefficients corresponding to the.
Definition: mixedFvPatchField.C:195
Foam::mixedFvPatchField::operator*=
virtual void operator*=(const Field< scalar > &)
Definition: mixedFvPatchField.H:339
Foam::mixedFvPatchField::operator=
virtual void operator=(const Type &)
Definition: mixedFvPatchField.H:342
Foam::mixedFvPatchField::operator*=
virtual void operator*=(const fvPatchField< scalar > &)
Definition: mixedFvPatchField.H:333
Foam::mixedFvPatchField::refGrad
virtual Field< Type > & refGrad()
Definition: mixedFvPatchField.H:240
Foam::mixedFvPatchField::clone
virtual tmp< fvPatchField< Type > > clone() const
Construct and return a clone.
Definition: mixedFvPatchField.H:181
Foam::mixedFvPatchField::valueBoundaryCoeffs
virtual tmp< Field< Type > > valueBoundaryCoeffs(const tmp< scalarField > &) const
Return the matrix source coefficients corresponding to the.
Definition: mixedFvPatchField.C:206
Foam::mixedFvPatchField::refGrad
virtual const Field< Type > & refGrad() const
Definition: mixedFvPatchField.H:245
Foam::mixedFvPatchField::operator+=
virtual void operator+=(const fvPatchField< Type > &)
Definition: mixedFvPatchField.H:331
Foam::mixedFvPatchField::operator/=
virtual void operator/=(const fvPatchField< scalar > &)
Definition: mixedFvPatchField.H:334
Foam::mixedFvPatchField::gradientBoundaryCoeffs
virtual tmp< Field< Type > > gradientBoundaryCoeffs() const
Return the matrix source coefficients corresponding to the.
Definition: mixedFvPatchField.C:226
Foam::mixedFvPatchField::autoMap
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
Definition: mixedFvPatchField.C:126
Foam::Field
Generic templated field type.
Definition: Field.H:63
Foam::mixedFvPatchField::mixedFvPatchField
mixedFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
Definition: mixedFvPatchField.C:34
Foam::mixedFvPatchField::operator*=
virtual void operator*=(const scalar)
Definition: mixedFvPatchField.H:345
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:65
Foam::mixedFvPatchField::gradientInternalCoeffs
virtual tmp< Field< Type > > gradientInternalCoeffs() const
Return the matrix diagonal coefficients corresponding to the.
Definition: mixedFvPatchField.C:218
Foam::mixedFvPatchField::write
virtual void write(Ostream &) const
Write.
Definition: mixedFvPatchField.C:235
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::mixedFvPatchField
This boundary condition provides a base class for 'mixed' type boundary conditions,...
Definition: mixedFvPatchField.H:123
Foam::mixedFvPatchField::fixesValue
virtual bool fixesValue() const
Return true if this patch field fixes a value.
Definition: mixedFvPatchField.H:216
Foam::mixedFvPatchField::source
virtual const Field< Type > & source() const
Definition: mixedFvPatchField.H:265
Foam::mixedFvPatchField::refValue
virtual const Field< Type > & refValue() const
Definition: mixedFvPatchField.H:235
Foam::UPstream::commsTypes
commsTypes
Types of communications.
Definition: UPstream.H:69
Foam::mixedFvPatchField::operator+=
virtual void operator+=(const Field< Type > &)
Definition: mixedFvPatchField.H:336
Foam::mixedFvPatchField::evaluate
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::blocking)
Evaluate the patch field.
Definition: mixedFvPatchField.C:158
Foam::mixedFvPatchField::operator-=
virtual void operator-=(const Field< Type > &)
Definition: mixedFvPatchField.H:337
Foam::mixedFvPatchField::operator=
virtual void operator=(const UList< Type > &)
Definition: mixedFvPatchField.H:328
Foam::List< label >
Foam::UList< Type >
Foam::mixedFvPatchField::operator/=
virtual void operator/=(const Field< scalar > &)
Definition: mixedFvPatchField.H:340
Foam::fvPatchFieldMapper
Foam::fvPatchFieldMapper.
Definition: fvPatchFieldMapper.H:47
Foam::mixedFvPatchField::source
virtual Field< Type > & source()
Definition: mixedFvPatchField.H:260
Foam::mixedFvPatchField::operator-=
virtual void operator-=(const fvPatchField< Type > &)
Definition: mixedFvPatchField.H:332
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
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:140
Foam::mixedFvPatchField::snGrad
virtual tmp< Field< Type > > snGrad() const
Return gradient at boundary.
Definition: mixedFvPatchField.C:182
Foam::mixedFvPatchField::operator-=
virtual void operator-=(const Type &)
Definition: mixedFvPatchField.H:344
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:54
Foam::UPstream::commsTypes::blocking
fvPatchField.H