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-2023 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 Foam_mixedFvPatchField_H
74 #define Foam_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 protected:
107 
108  //- Read the 'refValue', 'refGradient' and 'valueFraction' entries
109  //- into their respective places.
110  // The reading can be optional (default), mandatory etc.
111  // If 'refValue' is to be read, refGradient and valueFraction must
112  // also exist.
113  // \returns True on success
114  bool readMixedEntries
115  (
116  const dictionary& dict,
118  );
120 
121 public:
122 
123  //- Runtime type information
124  TypeName("mixed");
125 
126 
127  // Constructors
128 
129  //- Construct from patch and internal field
131  (
132  const fvPatch&,
134  );
135 
136  //- Construct from patch and internal field,
137  //- initialise as zero-gradient
139  (
140  const fvPatch&,
142  const Foam::zero
143  );
144 
145  //- Construct from patch, internal field and dictionary
147  (
148  const fvPatch&,
150  const dictionary&,
154  );
155 
156  //- Construct by mapping the given mixedFvPatchField onto a new patch
158  (
160  const fvPatch&,
162  const fvPatchFieldMapper&
163  );
164 
165  //- Construct as copy
167  (
169  );
170 
171  //- Construct as copy setting internal field reference
173  (
176  );
177 
178  //- Return a clone
179  virtual tmp<fvPatchField<Type>> clone() const
180  {
181  return fvPatchField<Type>::Clone(*this);
182  }
183 
184  //- Clone with an internal field reference
186  (
188  ) const
189  {
190  return fvPatchField<Type>::Clone(*this, iF);
191  }
192 
193 
194  // Member Functions
195 
196  //- True: this patch field fixes a value.
197  virtual bool fixesValue() const { return true; }
198 
199  //- False: this patch field is not altered by assignment.
200  virtual bool assignable() const { return false; }
201 
202 
203  // Return defining fields
204 
205  virtual Field<Type>& refValue()
206  {
207  return refValue_;
208  }
209 
210  virtual const Field<Type>& refValue() const
211  {
212  return refValue_;
213  }
214 
215  virtual Field<Type>& refGrad()
216  {
217  return refGrad_;
218  }
219 
220  virtual const Field<Type>& refGrad() const
221  {
222  return refGrad_;
223  }
224 
225  virtual scalarField& valueFraction()
226  {
227  return valueFraction_;
228  }
229 
230  virtual const scalarField& valueFraction() const
231  {
232  return valueFraction_;
233  }
234 
235  virtual Field<Type>& source()
236  {
237  return source_;
238  }
239 
240  virtual const Field<Type>& source() const
241  {
242  return source_;
243  }
244 
245 
246  // Mapping functions
247 
248  //- Map (and resize as needed) from self given a mapping object
249  virtual void autoMap
250  (
251  const fvPatchFieldMapper&
252  );
253 
254  //- Reverse map the given fvPatchField onto this fvPatchField
255  virtual void rmap
256  (
257  const fvPatchField<Type>&,
258  const labelList&
259  );
260 
261 
262  // Evaluation functions
263 
264  //- Return gradient at boundary
265  virtual tmp<Field<Type>> snGrad() const;
266 
267  //- Evaluate the patch field
268  virtual void evaluate
269  (
270  const Pstream::commsTypes commsType =
272  );
273 
274  //- Return the matrix diagonal coefficients corresponding to the
275  // evaluation of the value of this patchField with given weights
277  (
278  const tmp<scalarField>&
279  ) const;
280 
281  //- Return the matrix source coefficients corresponding to the
282  // evaluation of the value of this patchField with given weights
284  (
285  const tmp<scalarField>&
286  ) const;
287 
288  //- Return the matrix diagonal coefficients corresponding to the
289  // evaluation of the gradient of this patchField
290  virtual tmp<Field<Type>> gradientInternalCoeffs() const;
291 
292  //- Return the matrix source coefficients corresponding to the
293  // evaluation of the gradient of this patchField
295 
296 
297  //- Write
298  virtual void write(Ostream&) const;
300 
301  // Member operators
302 
303  virtual void operator=(const UList<Type>&) {}
305  virtual void operator=(const fvPatchField<Type>&) {}
306  virtual void operator+=(const fvPatchField<Type>&) {}
307  virtual void operator-=(const fvPatchField<Type>&) {}
308  virtual void operator*=(const fvPatchField<scalar>&) {}
309  virtual void operator/=(const fvPatchField<scalar>&) {}
310 
311  virtual void operator+=(const Field<Type>&) {}
312  virtual void operator-=(const Field<Type>&) {}
313 
314  virtual void operator*=(const Field<scalar>&) {}
315  virtual void operator/=(const Field<scalar>&) {}
316 
317  virtual void operator=(const Type&) {}
318  virtual void operator+=(const Type&) {}
319  virtual void operator-=(const Type&) {}
320  virtual void operator*=(const scalar) {}
321  virtual void operator/=(const scalar) {}
322 };
323 
324 
325 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
326 
327 } // End namespace Foam
328 
329 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
330 
331 #ifdef NoRepository
332  #include "mixedFvPatchField.C"
333 #endif
334 
335 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
336 
337 #endif
338 
339 // ************************************************************************* //
dictionary dict
virtual void operator=(const UList< Type > &)
commsTypes
Communications types.
Definition: UPstream.H:77
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::buffered)
Evaluate the patch field.
virtual bool fixesValue() const
True: this patch field fixes a value.
virtual void operator-=(const fvPatchField< Type > &)
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:70
virtual tmp< Field< Type > > snGrad() const
Return gradient at boundary.
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...
virtual tmp< Field< Type > > gradientInternalCoeffs() const
Return the matrix diagonal coefficients corresponding to the.
virtual Field< Type > & source()
virtual Field< Type > & refValue()
bool readMixedEntries(const dictionary &dict, IOobjectOption::readOption readOpt=IOobjectOption::LAZY_READ)
Read the &#39;refValue&#39;, &#39;refGradient&#39; and &#39;valueFraction&#39; entries into their respective places...
virtual void operator+=(const fvPatchField< Type > &)
static tmp< fvPatchField< Type > > Clone(const DerivedPatchField &pf, Args &&... args)
Clone a patch field, optionally with internal field reference etc.
Definition: fvPatchField.H:597
Generic templated field type.
Definition: Field.H:62
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
virtual scalarField & valueFraction()
virtual tmp< Field< Type > > gradientBoundaryCoeffs() const
Return the matrix source coefficients corresponding to the.
A FieldMapper for finite-volume patch fields.
virtual tmp< Field< Type > > valueInternalCoeffs(const tmp< scalarField > &) const
Return the matrix diagonal coefficients corresponding to the.
virtual tmp< Field< Type > > valueBoundaryCoeffs(const tmp< scalarField > &) const
Return the matrix source coefficients corresponding to the.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
virtual void rmap(const fvPatchField< Type > &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
virtual void operator*=(const fvPatchField< scalar > &)
virtual bool assignable() const
False: this patch field is not altered by assignment.
virtual tmp< fvPatchField< Type > > clone() const
Return a clone.
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...
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:57
Reading is optional [identical to READ_IF_PRESENT].
virtual void write(Ostream &) const
Write.
A class for managing temporary objects.
Definition: HashPtrTable.H:50
"buffered" : (MPI_Bsend, MPI_Recv)
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.
readOption
Enumeration defining read preferences.