mixedFvPatchField.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2023 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 Description
28  This boundary condition provides a base class for 'mixed' type boundary
29  conditions, i.e. conditions that mix fixed value and patch-normal gradient
30  conditions.
31 
32  The respective contributions from each is determined by a weight field:
33 
34  \f[
35  x_p = w x_p + (1-w) \left(x_c + \frac{\nabla_\perp x}{\Delta}\right)
36  \f]
37 
38  where
39  \vartable
40  x_p | patch values
41  x_c | patch internal cell values
42  w | weight field (0-1)
43  \Delta | inverse distance from face centre to internal cell centre
44  \endvartable
45 
46 Usage
47  \table
48  Property | Description | Required | Default value
49  refValue | reference value | yes |
50  refGradient | reference normal gradient | yes |
51  valueFraction | weight field | yes |
52  \endtable
53 
54  Note:
55  This condition is not usually applied directly; instead, use a derived
56  mixed condition such as \c inletOutlet
57 
58 See also
59  Foam::inletOutletFvPatchField
60 
61 SourceFiles
62  mixedFvPatchField.C
63 
64 \*---------------------------------------------------------------------------*/
65 
66 #ifndef mixedFvPatchField_H
67 #define mixedFvPatchField_H
68 
69 #include "fvPatchField.H"
70 
71 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
72 
73 namespace Foam
74 {
75 
76 /*---------------------------------------------------------------------------*\
77  Class mixedFvPatchField Declaration
78 \*---------------------------------------------------------------------------*/
79 
80 template<class Type>
81 class mixedFvPatchField
82 :
83  public fvPatchField<Type>
84 {
85  // Private Data
86 
87  //- Value field
88  Field<Type> refValue_;
89 
90  //- Normal gradient field
91  Field<Type> refGrad_;
92 
93  //- Fraction (0-1) of value used for boundary condition
94  scalarField valueFraction_;
95 
96 
97 public:
98 
99  //- Runtime type information
100  TypeName("mixed");
101 
102 
103  // Constructors
104 
105  //- Construct from patch and internal field
107  (
108  const fvPatch&,
109  const DimensionedField<Type, volMesh>&
110  );
111 
112  //- Construct from patch, internal field and dictionary
114  (
115  const fvPatch&,
117  const dictionary&,
118  const bool valuesRequired=true
119  );
120 
121  //- Construct by mapping the given mixedFvPatchField onto a new patch
123  (
125  const fvPatch&,
127  const fvPatchFieldMapper&,
128  const bool mappingRequired=true
129  );
130 
131  //- Disallow copy without setting internal field reference
133 
134  //- Copy constructor setting internal field reference
136  (
139  );
140 
141  //- Construct and return a clone setting internal field reference
143  (
145  ) const
146  {
147  return tmp<fvPatchField<Type>>
148  (
149  new mixedFvPatchField<Type>(*this, iF)
150  );
151  }
152 
153 
154  // Member Functions
155 
156  // Access
157 
158  //- Return true if this patch field fixes a value.
159  // Needed to check if a level has to be specified while solving
160  // Poissons equations.
161  virtual bool fixesValue() const
162  {
163  return true;
164  }
165 
166  //- Return false: this patch field is not altered by assignment
167  virtual bool assignable() const
168  {
169  return false;
170  }
171 
172 
173  // Return defining fields
174 
175  virtual Field<Type>& refValue()
176  {
177  return refValue_;
178  }
179 
180  virtual const Field<Type>& refValue() const
181  {
182  return refValue_;
183  }
184 
185  virtual Field<Type>& refGrad()
186  {
187  return refGrad_;
188  }
189 
190  virtual const Field<Type>& refGrad() const
191  {
192  return refGrad_;
193  }
194 
195  virtual scalarField& valueFraction()
196  {
197  return valueFraction_;
198  }
199 
200  virtual const scalarField& valueFraction() const
201  {
202  return valueFraction_;
203  }
204 
205 
206  // Mapping functions
207 
208  //- Map the given fvPatchField onto this fvPatchField
209  virtual void map
210  (
211  const fvPatchField<Type>&,
212  const fvPatchFieldMapper&
213  );
214 
215  //- Reset the fvPatchField to the given fvPatchField
216  // Used for mesh to mesh mapping
217  virtual void reset(const fvPatchField<Type>&);
218 
219 
220  // Evaluation functions
221 
222  //- Return gradient at boundary
223  virtual tmp<Field<Type>> snGrad() const;
224 
225  //- Evaluate the patch field
226  virtual void evaluate
227  (
228  const Pstream::commsTypes commsType =
230  );
231 
232  //- Return the matrix diagonal coefficients corresponding to the
233  // evaluation of the value of this patchField with given weights
235  (
236  const tmp<scalarField>&
237  ) const;
238 
239  //- Return the matrix source coefficients corresponding to the
240  // evaluation of the value of this patchField with given weights
242  (
243  const tmp<scalarField>&
244  ) const;
245 
246  //- Return the matrix diagonal coefficients corresponding to the
247  // evaluation of the gradient of this patchField
248  virtual tmp<Field<Type>> gradientInternalCoeffs() const;
249 
250  //- Return the matrix source coefficients corresponding to the
251  // evaluation of the gradient of this patchField
252  virtual tmp<Field<Type>> gradientBoundaryCoeffs() const;
253 
254 
255  //- Write
256  virtual void write(Ostream&) const;
257 
258 
259  // Member Operators
260 
261  virtual void operator=(const UList<Type>&) {}
262 
263  virtual void operator=(const fvPatchField<Type>&) {}
264  virtual void operator+=(const fvPatchField<Type>&) {}
265  virtual void operator-=(const fvPatchField<Type>&) {}
266  virtual void operator*=(const fvPatchField<scalar>&) {}
267  virtual void operator/=(const fvPatchField<scalar>&) {}
268 
269  virtual void operator+=(const Field<Type>&) {}
270  virtual void operator-=(const Field<Type>&) {}
271 
272  virtual void operator*=(const Field<scalar>&) {}
273  virtual void operator/=(const Field<scalar>&) {}
274 
275  virtual void operator=(const Type&) {}
276  virtual void operator+=(const Type&) {}
277  virtual void operator-=(const Type&) {}
278  virtual void operator*=(const scalar) {}
279  virtual void operator/=(const scalar) {}
280 };
281 
282 
283 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
284 
285 } // End namespace Foam
286 
287 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
288 
289 #ifdef NoRepository
290  #include "mixedFvPatchField.C"
291 #endif
292 
293 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
294 
295 #endif
296 
297 // ************************************************************************* //
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Pre-declare SubField and related Field type.
Definition: Field.H:82
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
commsTypes
Types of communications.
Definition: UPstream.H:65
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:160
Foam::fvPatchFieldMapper.
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:87
tmp< fvPatchField< Type > > clone() const
Disallow clone without setting internal field reference.
Definition: fvPatchField.H:203
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:64
This boundary condition provides a base class for 'mixed' type boundary conditions,...
virtual bool fixesValue() const
Return true if this patch field fixes a value.
mixedFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::blocking)
Evaluate the patch field.
virtual void write(Ostream &) const
Write.
virtual tmp< Field< Type > > gradientInternalCoeffs() const
Return the matrix diagonal coefficients corresponding to the.
virtual Field< Type > & refValue()
virtual void operator+=(const fvPatchField< Type > &)
virtual tmp< Field< Type > > snGrad() const
Return gradient at boundary.
virtual void operator/=(const fvPatchField< scalar > &)
virtual tmp< Field< Type > > valueInternalCoeffs(const tmp< scalarField > &) const
Return the matrix diagonal coefficients corresponding to the.
virtual void operator*=(const fvPatchField< scalar > &)
virtual void operator-=(const fvPatchField< Type > &)
virtual void operator=(const UList< Type > &)
virtual tmp< Field< Type > > gradientBoundaryCoeffs() const
Return the matrix source coefficients corresponding to the.
virtual void reset(const fvPatchField< Type > &)
Reset the fvPatchField to the given fvPatchField.
virtual void map(const fvPatchField< Type > &, const fvPatchFieldMapper &)
Map the given fvPatchField onto this fvPatchField.
virtual tmp< Field< Type > > valueBoundaryCoeffs(const tmp< scalarField > &) const
Return the matrix source coefficients corresponding to the.
virtual bool assignable() const
Return false: this patch field is not altered by assignment.
TypeName("mixed")
Runtime type information.
virtual scalarField & valueFraction()
virtual Field< Type > & refGrad()
A class for managing temporary objects.
Definition: tmp.H:55
Namespace for OpenFOAM.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.