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 fieldMapper&,
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(const fvPatchField<Type>&, const fieldMapper&);
210 
211  //- Reset the fvPatchField to the given fvPatchField
212  // Used for mesh to mesh mapping
213  virtual void reset(const fvPatchField<Type>&);
214 
215 
216  // Evaluation functions
217 
218  //- Return gradient at boundary
219  virtual tmp<Field<Type>> snGrad() const;
220 
221  //- Evaluate the patch field
222  virtual void evaluate
223  (
224  const Pstream::commsTypes commsType =
226  );
227 
228  //- Return the matrix diagonal coefficients corresponding to the
229  // evaluation of the value of this patchField with given weights
231  (
232  const tmp<scalarField>&
233  ) const;
234 
235  //- Return the matrix source coefficients corresponding to the
236  // evaluation of the value of this patchField with given weights
238  (
239  const tmp<scalarField>&
240  ) const;
241 
242  //- Return the matrix diagonal coefficients corresponding to the
243  // evaluation of the gradient of this patchField
244  virtual tmp<Field<Type>> gradientInternalCoeffs() const;
245 
246  //- Return the matrix source coefficients corresponding to the
247  // evaluation of the gradient of this patchField
248  virtual tmp<Field<Type>> gradientBoundaryCoeffs() const;
249 
250 
251  //- Write
252  virtual void write(Ostream&) const;
253 
254 
255  // Member Operators
256 
257  virtual void operator=(const UList<Type>&) {}
258 
259  virtual void operator=(const fvPatchField<Type>&) {}
260  virtual void operator+=(const fvPatchField<Type>&) {}
261  virtual void operator-=(const fvPatchField<Type>&) {}
262  virtual void operator*=(const fvPatchField<scalar>&) {}
263  virtual void operator/=(const fvPatchField<scalar>&) {}
264 
265  virtual void operator+=(const Field<Type>&) {}
266  virtual void operator-=(const Field<Type>&) {}
267 
268  virtual void operator*=(const Field<scalar>&) {}
269  virtual void operator/=(const Field<scalar>&) {}
270 
271  virtual void operator=(const Type&) {}
272  virtual void operator+=(const Type&) {}
273  virtual void operator-=(const Type&) {}
274  virtual void operator*=(const scalar) {}
275  virtual void operator/=(const scalar) {}
276 };
277 
278 
279 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
280 
281 } // End namespace Foam
282 
283 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
284 
285 #ifdef NoRepository
286  #include "mixedFvPatchField.C"
287 #endif
288 
289 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
290 
291 #endif
292 
293 // ************************************************************************* //
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:83
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:162
Abstract base class for field mapping.
Definition: fieldMapper.H:48
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:88
tmp< fvPatchField< Type > > clone() const
Disallow clone without setting internal field reference.
Definition: fvPatchField.H:204
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 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 void map(const fvPatchField< Type > &, const fieldMapper &)
Map the given fvPatchField onto this fvPatchField.
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.