All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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-2020 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
43  \Delta| inverse distance from face centre to internal cell centre
44  w | weighting (0-1)
45  \endvartable
46 
47 
48 Usage
49  \table
50  Property | Description | Required | Default value
51  valueFraction | weight field | yes |
52  refValue | fixed value | yes |
53  refGrad | patch normal gradient | yes |
54  \endtable
55 
56 Note
57  This condition is not usually applied directly; instead, use a derived
58  mixed condition such as \c inletOutlet
59 
60 See also
61  Foam::inletOutletFvPatchField
62 
63 SourceFiles
64  mixedFvPatchField.C
65 
66 \*---------------------------------------------------------------------------*/
67 
68 #ifndef mixedFvPatchField_H
69 #define mixedFvPatchField_H
70 
71 #include "fvPatchField.H"
72 
73 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
74 
75 namespace Foam
76 {
77 
78 /*---------------------------------------------------------------------------*\
79  Class mixedFvPatchField Declaration
80 \*---------------------------------------------------------------------------*/
81 
82 template<class Type>
83 class mixedFvPatchField
84 :
85  public fvPatchField<Type>
86 {
87  // Private Data
88 
89  //- Value field
90  Field<Type> refValue_;
91 
92  //- Normal gradient field
93  Field<Type> refGrad_;
94 
95  //- Fraction (0-1) of value used for boundary condition
96  scalarField valueFraction_;
97 
98 
99 public:
100 
101  //- Runtime type information
102  TypeName("mixed");
103 
104 
105  // Constructors
106 
107  //- Construct from patch and internal field
109  (
110  const fvPatch&,
111  const DimensionedField<Type, volMesh>&
112  );
113 
114  //- Construct from patch, internal field and dictionary
116  (
117  const fvPatch&,
118  const DimensionedField<Type, volMesh>&,
119  const dictionary&
120  );
121 
122  //- Construct by mapping the given mixedFvPatchField onto a new patch
124  (
126  const fvPatch&,
128  const fvPatchFieldMapper&,
129  const bool mappingRequired=true
130  );
131 
132  //- Disallow copy without setting internal field reference
134 
135  //- Copy constructor setting internal field reference
137  (
140  );
141 
142  //- Construct and return a clone setting internal field reference
144  (
146  ) const
147  {
148  return tmp<fvPatchField<Type>>
149  (
150  new mixedFvPatchField<Type>(*this, iF)
151  );
152  }
153 
154 
155  // Member Functions
156 
157  // Access
158 
159  //- Return true if this patch field fixes a value.
160  // Needed to check if a level has to be specified while solving
161  // Poissons equations.
162  virtual bool fixesValue() const
163  {
164  return true;
165  }
166 
167  //- Return false: this patch field is not altered by assignment
168  virtual bool assignable() const
169  {
170  return false;
171  }
172 
173 
174  // Return defining fields
175 
176  virtual Field<Type>& refValue()
177  {
178  return refValue_;
179  }
180 
181  virtual const Field<Type>& refValue() const
182  {
183  return refValue_;
184  }
185 
186  virtual Field<Type>& refGrad()
187  {
188  return refGrad_;
189  }
190 
191  virtual const Field<Type>& refGrad() const
192  {
193  return refGrad_;
194  }
195 
196  virtual scalarField& valueFraction()
197  {
198  return valueFraction_;
199  }
200 
201  virtual const scalarField& valueFraction() const
202  {
203  return valueFraction_;
204  }
205 
206 
207  // Mapping functions
208 
209  //- Map (and resize as needed) from self given a mapping object
210  // Used to update fields following mesh topology change
211  virtual void autoMap(const fvPatchFieldMapper&);
212 
213  //- Reverse map the given fvPatchField onto this fvPatchField
214  // Used to reconstruct fields
215  virtual void rmap(const fvPatchField<Type>&, const labelList&);
216 
217 
218  // Evaluation functions
219 
220  //- Return gradient at boundary
221  virtual tmp<Field<Type>> snGrad() const;
222 
223  //- Evaluate the patch field
224  virtual void evaluate
225  (
226  const Pstream::commsTypes commsType =
228  );
229 
230  //- Return the matrix diagonal coefficients corresponding to the
231  // evaluation of the value of this patchField with given weights
233  (
234  const tmp<scalarField>&
235  ) const;
236 
237  //- Return the matrix source coefficients corresponding to the
238  // evaluation of the value of this patchField with given weights
240  (
241  const tmp<scalarField>&
242  ) const;
243 
244  //- Return the matrix diagonal coefficients corresponding to the
245  // evaluation of the gradient of this patchField
246  virtual tmp<Field<Type>> gradientInternalCoeffs() const;
247 
248  //- Return the matrix source coefficients corresponding to the
249  // evaluation of the gradient of this patchField
250  virtual tmp<Field<Type>> gradientBoundaryCoeffs() const;
251 
252 
253  //- Write
254  virtual void write(Ostream&) const;
255 
256 
257  // Member Operators
258 
259  virtual void operator=(const UList<Type>&) {}
260 
261  virtual void operator=(const fvPatchField<Type>&) {}
262  virtual void operator+=(const fvPatchField<Type>&) {}
263  virtual void operator-=(const fvPatchField<Type>&) {}
264  virtual void operator*=(const fvPatchField<scalar>&) {}
265  virtual void operator/=(const fvPatchField<scalar>&) {}
266 
267  virtual void operator+=(const Field<Type>&) {}
268  virtual void operator-=(const Field<Type>&) {}
269 
270  virtual void operator*=(const Field<scalar>&) {}
271  virtual void operator/=(const Field<scalar>&) {}
272 
273  virtual void operator=(const Type&) {}
274  virtual void operator+=(const Type&) {}
275  virtual void operator-=(const Type&) {}
276  virtual void operator*=(const scalar) {}
277  virtual void operator/=(const scalar) {}
278 };
279 
280 
281 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
282 
283 } // End namespace Foam
284 
285 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
286 
287 #ifdef NoRepository
288  #include "mixedFvPatchField.C"
289 #endif
290 
291 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
292 
293 #endif
294 
295 // ************************************************************************* //
virtual void operator=(const UList< Type > &)
commsTypes
Types of communications.
Definition: UPstream.H:64
virtual bool fixesValue() const
Return true if this patch field fixes a value.
virtual void operator-=(const fvPatchField< Type > &)
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:62
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...
Definition: fvPatchField.H:66
virtual tmp< Field< Type > > gradientInternalCoeffs() const
Return the matrix diagonal coefficients corresponding to the.
virtual Field< Type > & refValue()
virtual void operator+=(const fvPatchField< Type > &)
Pre-declare SubField and related Field type.
Definition: Field.H:56
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.
Foam::fvPatchFieldMapper.
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:54
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
Return false: this patch field is not altered by assignment.
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...
virtual void write(Ostream &) const
Write.
A class for managing temporary objects.
Definition: PtrList.H:53
virtual void operator/=(const fvPatchField< scalar > &)
tmp< fvPatchField< Type > > clone() const
Disallow clone without setting internal field reference.
Definition: fvPatchField.H:199
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.