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 and return a clone
172  virtual tmp<fvPatchField<Type>> clone() const
173  {
174  return tmp<fvPatchField<Type>>
175  (
176  new mixedFvPatchField<Type>(*this)
177  );
178  }
179 
180  //- Construct as copy setting internal field reference
182  (
185  );
186 
187  //- Construct and return a clone setting internal field reference
189  (
191  ) const
192  {
193  return tmp<fvPatchField<Type>>
194  (
195  new mixedFvPatchField<Type>(*this, iF)
196  );
197  }
198 
199 
200  // Member Functions
201 
202  //- True: this patch field fixes a value.
203  virtual bool fixesValue() const { return true; }
204 
205  //- False: this patch field is not altered by assignment.
206  virtual bool assignable() const { return false; }
207 
208 
209  // Return defining fields
210 
211  virtual Field<Type>& refValue()
212  {
213  return refValue_;
214  }
215 
216  virtual const Field<Type>& refValue() const
217  {
218  return refValue_;
219  }
220 
221  virtual Field<Type>& refGrad()
222  {
223  return refGrad_;
224  }
225 
226  virtual const Field<Type>& refGrad() const
227  {
228  return refGrad_;
229  }
230 
231  virtual scalarField& valueFraction()
232  {
233  return valueFraction_;
234  }
235 
236  virtual const scalarField& valueFraction() const
237  {
238  return valueFraction_;
239  }
240 
241  virtual Field<Type>& source()
242  {
243  return source_;
244  }
245 
246  virtual const Field<Type>& source() const
247  {
248  return source_;
249  }
250 
251 
252  // Mapping functions
253 
254  //- Map (and resize as needed) from self given a mapping object
255  virtual void autoMap
256  (
257  const fvPatchFieldMapper&
258  );
259 
260  //- Reverse map the given fvPatchField onto this fvPatchField
261  virtual void rmap
262  (
263  const fvPatchField<Type>&,
264  const labelList&
265  );
266 
267 
268  // Evaluation functions
269 
270  //- Return gradient at boundary
271  virtual tmp<Field<Type>> snGrad() const;
272 
273  //- Evaluate the patch field
274  virtual void evaluate
275  (
276  const Pstream::commsTypes commsType =
278  );
279 
280  //- Return the matrix diagonal coefficients corresponding to the
281  // evaluation of the value of this patchField with given weights
283  (
284  const tmp<scalarField>&
285  ) const;
286 
287  //- Return the matrix source coefficients corresponding to the
288  // evaluation of the value of this patchField with given weights
290  (
291  const tmp<scalarField>&
292  ) const;
293 
294  //- Return the matrix diagonal coefficients corresponding to the
295  // evaluation of the gradient of this patchField
296  virtual tmp<Field<Type>> gradientInternalCoeffs() const;
297 
298  //- Return the matrix source coefficients corresponding to the
299  // evaluation of the gradient of this patchField
301 
302 
303  //- Write
304  virtual void write(Ostream&) const;
306 
307  // Member operators
308 
309  virtual void operator=(const UList<Type>&) {}
311  virtual void operator=(const fvPatchField<Type>&) {}
312  virtual void operator+=(const fvPatchField<Type>&) {}
313  virtual void operator-=(const fvPatchField<Type>&) {}
314  virtual void operator*=(const fvPatchField<scalar>&) {}
315  virtual void operator/=(const fvPatchField<scalar>&) {}
316 
317  virtual void operator+=(const Field<Type>&) {}
318  virtual void operator-=(const Field<Type>&) {}
319 
320  virtual void operator*=(const Field<scalar>&) {}
321  virtual void operator/=(const Field<scalar>&) {}
322 
323  virtual void operator=(const Type&) {}
324  virtual void operator+=(const Type&) {}
325  virtual void operator-=(const Type&) {}
326  virtual void operator*=(const scalar) {}
327  virtual void operator/=(const scalar) {}
328 };
329 
330 
331 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
332 
333 } // End namespace Foam
334 
335 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
336 
337 #ifdef NoRepository
338  #include "mixedFvPatchField.C"
339 #endif
340 
341 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
342 
343 #endif
344 
345 // ************************************************************************* //
dictionary dict
"blocking" : (MPI_Bsend, MPI_Recv)
virtual void operator=(const UList< Type > &)
commsTypes
Communications types.
Definition: UPstream.H:72
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
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 > &)
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 evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::blocking)
Evaluate the patch field.
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
Construct and 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...
Definition: areaFieldsFwd.H:42
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
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.