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 
104 public:
105 
106  //- Runtime type information
107  TypeName("mixed");
108 
109 
110  // Constructors
111 
112  //- Construct from patch and internal field
114  (
115  const fvPatch&,
116  const DimensionedField<Type, volMesh>&
117  );
118 
119  //- Construct from patch, internal field and dictionary
121  (
122  const fvPatch&,
124  const dictionary&
125  );
126 
127  //- Construct by mapping the given mixedFvPatchField onto a new patch
129  (
131  const fvPatch&,
133  const fvPatchFieldMapper&
134  );
135 
136  //- Construct as copy
138  (
140  );
141 
142  //- Construct and return a clone
143  virtual tmp<fvPatchField<Type>> clone() const
144  {
145  return tmp<fvPatchField<Type>>
146  (
147  new mixedFvPatchField<Type>(*this)
148  );
149  }
150 
151  //- Construct as copy setting internal field reference
153  (
156  );
157 
158  //- Construct and return a clone setting internal field reference
160  (
162  ) const
163  {
164  return tmp<fvPatchField<Type>>
165  (
166  new mixedFvPatchField<Type>(*this, iF)
167  );
168  }
169 
170 
171  // Member functions
172 
173  // Access
174 
175  //- Return true if this patch field fixes a value.
176  // Needed to check if a level has to be specified while solving
177  // Poissons equations.
178  virtual bool fixesValue() const
179  {
180  return true;
181  }
182 
183  //- Return false: this patch field is not altered by assignment
184  virtual bool assignable() const
185  {
186  return false;
187  }
188 
189 
190  // Return defining fields
191 
192  virtual Field<Type>& refValue()
193  {
194  return refValue_;
195  }
196 
197  virtual const Field<Type>& refValue() const
198  {
199  return refValue_;
200  }
201 
202  virtual Field<Type>& refGrad()
203  {
204  return refGrad_;
205  }
206 
207  virtual const Field<Type>& refGrad() const
208  {
209  return refGrad_;
210  }
211 
212  virtual scalarField& valueFraction()
213  {
214  return valueFraction_;
215  }
216 
217  virtual const scalarField& valueFraction() const
218  {
219  return valueFraction_;
220  }
221 
222 
223  // Mapping functions
224 
225  //- Map (and resize as needed) from self given a mapping object
226  virtual void autoMap
227  (
228  const fvPatchFieldMapper&
229  );
230 
231  //- Reverse map the given fvPatchField onto this fvPatchField
232  virtual void rmap
233  (
234  const fvPatchField<Type>&,
235  const labelList&
236  );
237 
238 
239  // Evaluation functions
240 
241  //- Return gradient at boundary
242  virtual tmp<Field<Type>> snGrad() const;
243 
244  //- Evaluate the patch field
245  virtual void evaluate
246  (
247  const Pstream::commsTypes commsType =
249  );
250 
251  //- Return the matrix diagonal coefficients corresponding to the
252  // evaluation of the value of this patchField with given weights
254  (
255  const tmp<scalarField>&
256  ) const;
257 
258  //- Return the matrix source coefficients corresponding to the
259  // evaluation of the value of this patchField with given weights
261  (
262  const tmp<scalarField>&
263  ) const;
264 
265  //- Return the matrix diagonal coefficients corresponding to the
266  // evaluation of the gradient of this patchField
267  virtual tmp<Field<Type>> gradientInternalCoeffs() const;
268 
269  //- Return the matrix source coefficients corresponding to the
270  // evaluation of the gradient of this patchField
271  virtual tmp<Field<Type>> gradientBoundaryCoeffs() const;
272 
273 
274  //- Write
275  virtual void write(Ostream&) const;
276 
277 
278  // Member operators
279 
280  virtual void operator=(const UList<Type>&) {}
281 
282  virtual void operator=(const fvPatchField<Type>&) {}
283  virtual void operator+=(const fvPatchField<Type>&) {}
284  virtual void operator-=(const fvPatchField<Type>&) {}
285  virtual void operator*=(const fvPatchField<scalar>&) {}
286  virtual void operator/=(const fvPatchField<scalar>&) {}
287 
288  virtual void operator+=(const Field<Type>&) {}
289  virtual void operator-=(const Field<Type>&) {}
290 
291  virtual void operator*=(const Field<scalar>&) {}
292  virtual void operator/=(const Field<scalar>&) {}
293 
294  virtual void operator=(const Type&) {}
295  virtual void operator+=(const Type&) {}
296  virtual void operator-=(const Type&) {}
297  virtual void operator*=(const scalar) {}
298  virtual void operator/=(const scalar) {}
299 };
300 
301 
302 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
303 
304 } // End namespace Foam
305 
306 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
307 
308 #ifdef NoRepository
309  #include "mixedFvPatchField.C"
310 #endif
311 
312 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
313 
314 #endif
315 
316 // ************************************************************************* //
Foam::fvPatchField
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: volSurfaceMapping.H:50
Foam::UPstream::commsTypes::blocking
Foam::mixedFvPatchField::operator+=
virtual void operator+=(const Type &)
Definition: mixedFvPatchField.H:330
Foam::scalarField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Definition: primitiveFieldsFwd.H:52
Foam::mixedFvPatchField::valueFraction
virtual scalarField & valueFraction()
Definition: mixedFvPatchField.H:247
Foam::mixedFvPatchField::valueFraction
virtual const scalarField & valueFraction() const
Definition: mixedFvPatchField.H:252
Foam::mixedFvPatchField::refValue
virtual Field< Type > & refValue()
Definition: mixedFvPatchField.H:227
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:59
Foam::mixedFvPatchField::operator/=
virtual void operator/=(const scalar)
Definition: mixedFvPatchField.H:333
Foam::mixedFvPatchField::assignable
virtual bool assignable() const
Return false: this patch field is not altered by assignment.
Definition: mixedFvPatchField.H:219
Foam::mixedFvPatchField::operator=
virtual void operator=(const fvPatchField< Type > &)
Definition: mixedFvPatchField.H:317
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:326
Foam::mixedFvPatchField::operator=
virtual void operator=(const Type &)
Definition: mixedFvPatchField.H:329
Foam::mixedFvPatchField::operator*=
virtual void operator*=(const fvPatchField< scalar > &)
Definition: mixedFvPatchField.H:320
Foam::mixedFvPatchField::refGrad
virtual Field< Type > & refGrad()
Definition: mixedFvPatchField.H:237
Foam::mixedFvPatchField::clone
virtual tmp< fvPatchField< Type > > clone() const
Construct and return a clone.
Definition: mixedFvPatchField.H:178
Foam::mixedFvPatchField::valueBoundaryCoeffs
virtual tmp< Field< Type > > valueBoundaryCoeffs(const tmp< scalarField > &) const
Return the matrix source coefficients corresponding to the.
Definition: mixedFvPatchField.C:200
Foam::mixedFvPatchField::refGrad
virtual const Field< Type > & refGrad() const
Definition: mixedFvPatchField.H:242
Foam::mixedFvPatchField::operator+=
virtual void operator+=(const fvPatchField< Type > &)
Definition: mixedFvPatchField.H:318
Foam::mixedFvPatchField::operator/=
virtual void operator/=(const fvPatchField< scalar > &)
Definition: mixedFvPatchField.H:321
Foam::mixedFvPatchField::gradientBoundaryCoeffs
virtual tmp< Field< Type > > gradientBoundaryCoeffs() const
Return the matrix source coefficients corresponding to the.
Definition: mixedFvPatchField.C:220
Foam::mixedFvPatchField::autoMap
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
Definition: mixedFvPatchField.C:121
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:332
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:212
Foam::mixedFvPatchField::write
virtual void write(Ostream &) const
Write.
Definition: mixedFvPatchField.C:229
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
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:213
Foam::mixedFvPatchField::refValue
virtual const Field< Type > & refValue() const
Definition: mixedFvPatchField.H:232
Foam::mixedFvPatchField::operator+=
virtual void operator+=(const Field< Type > &)
Definition: mixedFvPatchField.H:323
Foam::UPstream::commsTypes
commsTypes
Types of communications.
Definition: UPstream.H:66
Foam::mixedFvPatchField::evaluate
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::blocking)
Evaluate the patch field.
Definition: mixedFvPatchField.C:151
Foam::mixedFvPatchField::operator-=
virtual void operator-=(const Field< Type > &)
Definition: mixedFvPatchField.H:324
Foam::mixedFvPatchField::operator=
virtual void operator=(const UList< Type > &)
Definition: mixedFvPatchField.H:315
Foam::List< label >
Foam::UList< Type >
Foam::mixedFvPatchField::operator/=
virtual void operator/=(const Field< scalar > &)
Definition: mixedFvPatchField.H:327
Foam::fvPatchFieldMapper
Foam::fvPatchFieldMapper.
Definition: fvPatchFieldMapper.H:47
Foam::mixedFvPatchField::operator-=
virtual void operator-=(const fvPatchField< Type > &)
Definition: mixedFvPatchField.H:319
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:134
Foam::mixedFvPatchField::snGrad
virtual tmp< Field< Type > > snGrad() const
Return gradient at boundary.
Definition: mixedFvPatchField.C:175
Foam::mixedFvPatchField::operator-=
virtual void operator-=(const Type &)
Definition: mixedFvPatchField.H:331
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:54
fvPatchField.H