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-2019 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  //- Copy constructor
134  (
136  );
137 
138  //- Construct and return a clone
139  virtual tmp<fvPatchField<Type>> clone() const
140  {
141  return tmp<fvPatchField<Type>>
142  (
143  new mixedFvPatchField<Type>(*this)
144  );
145  }
146 
147  //- Copy constructor setting internal field reference
149  (
152  );
153 
154  //- Construct and return a clone setting internal field reference
156  (
158  ) const
159  {
160  return tmp<fvPatchField<Type>>
161  (
162  new mixedFvPatchField<Type>(*this, iF)
163  );
164  }
165 
166 
167  // Member Functions
168 
169  // Access
170 
171  //- Return true if this patch field fixes a value.
172  // Needed to check if a level has to be specified while solving
173  // Poissons equations.
174  virtual bool fixesValue() const
175  {
176  return true;
177  }
179  //- Return false: this patch field is not altered by assignment
180  virtual bool assignable() const
181  {
182  return false;
183  }
184 
185 
186  // Return defining fields
187 
188  virtual Field<Type>& refValue()
189  {
190  return refValue_;
191  }
192 
193  virtual const Field<Type>& refValue() const
194  {
195  return refValue_;
196  }
197 
198  virtual Field<Type>& refGrad()
199  {
200  return refGrad_;
201  }
202 
203  virtual const Field<Type>& refGrad() const
204  {
205  return refGrad_;
206  }
207 
208  virtual scalarField& valueFraction()
209  {
210  return valueFraction_;
211  }
212 
213  virtual const scalarField& valueFraction() const
214  {
215  return valueFraction_;
216  }
217 
218 
219  // Mapping functions
220 
221  //- Map (and resize as needed) from self given a mapping object
222  // Used to update fields following mesh topology change
223  virtual void autoMap(const fvPatchFieldMapper&);
224 
225  //- Reverse map the given fvPatchField onto this fvPatchField
226  // Used to reconstruct fields
227  virtual void rmap(const fvPatchField<Type>&, const labelList&);
228 
229 
230  // Evaluation functions
231 
232  //- Return gradient at boundary
233  virtual tmp<Field<Type>> snGrad() const;
234 
235  //- Evaluate the patch field
236  virtual void evaluate
237  (
238  const Pstream::commsTypes commsType =
240  );
241 
242  //- Return the matrix diagonal coefficients corresponding to the
243  // evaluation of the value of this patchField with given weights
245  (
246  const tmp<scalarField>&
247  ) const;
248 
249  //- Return the matrix source coefficients corresponding to the
250  // evaluation of the value of this patchField with given weights
252  (
253  const tmp<scalarField>&
254  ) const;
255 
256  //- Return the matrix diagonal coefficients corresponding to the
257  // evaluation of the gradient of this patchField
258  virtual tmp<Field<Type>> gradientInternalCoeffs() const;
259 
260  //- Return the matrix source coefficients corresponding to the
261  // evaluation of the gradient of this patchField
262  virtual tmp<Field<Type>> gradientBoundaryCoeffs() const;
263 
264 
265  //- Write
266  virtual void write(Ostream&) const;
267 
268 
269  // Member Operators
270 
271  virtual void operator=(const UList<Type>&) {}
272 
273  virtual void operator=(const fvPatchField<Type>&) {}
274  virtual void operator+=(const fvPatchField<Type>&) {}
275  virtual void operator-=(const fvPatchField<Type>&) {}
276  virtual void operator*=(const fvPatchField<scalar>&) {}
277  virtual void operator/=(const fvPatchField<scalar>&) {}
278 
279  virtual void operator+=(const Field<Type>&) {}
280  virtual void operator-=(const Field<Type>&) {}
281 
282  virtual void operator*=(const Field<scalar>&) {}
283  virtual void operator/=(const Field<scalar>&) {}
284 
285  virtual void operator=(const Type&) {}
286  virtual void operator+=(const Type&) {}
287  virtual void operator-=(const Type&) {}
288  virtual void operator*=(const scalar) {}
289  virtual void operator/=(const scalar) {}
290 };
291 
292 
293 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
294 
295 } // End namespace Foam
296 
297 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
298 
299 #ifdef NoRepository
300  #include "mixedFvPatchField.C"
301 #endif
302 
303 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
304 
305 #endif
306 
307 // ************************************************************************* //
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:61
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.
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...
virtual void write(Ostream &) const
Write.
A class for managing temporary objects.
Definition: PtrList.H:53
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.