Loading...
Searching...
No Matches
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-------------------------------------------------------------------------------
11License
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
27Class
28 Foam::mixedFvPatchField
29
30Group
31 grpGenericBoundaryConditions
32
33Description
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
53Usage
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
61Note
62 This condition is not usually applied directly; instead, use a derived
63 mixed condition such as \c inletOutlet
64
65See also
66 Foam::inletOutletFvPatchField
67
68SourceFiles
69 mixedFvPatchField.C
70
71\*---------------------------------------------------------------------------*/
72
73#ifndef Foam_mixedFvPatchField_H
74#define Foam_mixedFvPatchField_H
75
76#include "fvPatchField.H"
77
78// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
79
80namespace Foam
81{
82
83/*---------------------------------------------------------------------------*\
84 Class mixedFvPatchField Declaration
85\*---------------------------------------------------------------------------*/
86
87template<class Type>
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
106protected:
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
115 (
116 const dictionary& dict,
118 );
120
121public:
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 as copy setting internal field reference
173 (
176 );
177
178 //- Return a clone
179 virtual tmp<fvPatchField<Type>> clone() const
180 {
181 return fvPatchField<Type>::Clone(*this);
182 }
183
184 //- Clone with an internal field reference
188 ) const
189 {
190 return fvPatchField<Type>::Clone(*this, iF);
191 }
192
193
194 // Member Functions
195
196 //- True: this patch field fixes a value.
197 virtual bool fixesValue() const { return true; }
198
199 //- False: this patch field is not altered by assignment.
200 virtual bool assignable() const { return false; }
201
202
203 // Return defining fields
204
205 virtual Field<Type>& refValue()
206 {
207 return refValue_;
208 }
210 virtual const Field<Type>& refValue() const
211 {
212 return refValue_;
213 }
214
215 virtual Field<Type>& refGrad()
216 {
217 return refGrad_;
218 }
219
220 virtual const Field<Type>& refGrad() const
221 {
222 return refGrad_;
223 }
224
225 virtual scalarField& valueFraction()
226 {
227 return valueFraction_;
229
230 virtual const scalarField& valueFraction() const
231 {
232 return valueFraction_;
233 }
234
235 virtual Field<Type>& source()
236 {
237 return source_;
238 }
239
240 virtual const Field<Type>& source() const
241 {
242 return source_;
243 }
244
246 // Mapping functions
247
248 //- Map (and resize as needed) from self given a mapping object
249 virtual void autoMap
250 (
251 const fvPatchFieldMapper&
252 );
253
254 //- Reverse map the given fvPatchField onto this fvPatchField
255 virtual void rmap
256 (
257 const fvPatchField<Type>&,
258 const labelList&
259 );
260
261
262 // Evaluation functions
263
264 //- Return gradient at boundary
265 virtual tmp<Field<Type>> snGrad() const;
266
267 //- Evaluate the patch field
268 virtual void evaluate
270 const Pstream::commsTypes commsType =
272 );
273
274 //- Return the matrix diagonal coefficients corresponding to the
275 // evaluation of the value of this patchField with given weights
277 (
278 const tmp<scalarField>&
279 ) const;
280
281 //- Return the matrix source coefficients corresponding to the
282 // evaluation of the value of this patchField with given weights
285 const tmp<scalarField>&
286 ) const;
287
288 //- Return the matrix diagonal coefficients corresponding to the
289 // evaluation of the gradient of this patchField
291
292 //- Return the matrix source coefficients corresponding to the
293 // evaluation of the gradient of this patchField
295
296
297 //- Write
298 virtual void write(Ostream&) const;
300
301 // Member operators
302
303 virtual void operator=(const UList<Type>&) {}
305 virtual void operator=(const fvPatchField<Type>&) {}
306 virtual void operator+=(const fvPatchField<Type>&) {}
307 virtual void operator-=(const fvPatchField<Type>&) {}
308 virtual void operator*=(const fvPatchField<scalar>&) {}
309 virtual void operator/=(const fvPatchField<scalar>&) {}
310
311 virtual void operator+=(const Field<Type>&) {}
312 virtual void operator-=(const Field<Type>&) {}
313
314 virtual void operator*=(const Field<scalar>&) {}
315 virtual void operator/=(const Field<scalar>&) {}
316
317 virtual void operator=(const Type&) {}
318 virtual void operator+=(const Type&) {}
319 virtual void operator-=(const Type&) {}
320 virtual void operator*=(const scalar) {}
321 virtual void operator/=(const scalar) {}
322};
324
325// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
326
327} // End namespace Foam
328
329// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
330
331#ifdef NoRepository
332 #include "mixedFvPatchField.C"
333#endif
334
335// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
336
337#endif
338
339// ************************************************************************* //
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
Definition Field.H:172
constexpr Field() noexcept
Default construct.
Definition FieldI.H:24
readOption
Enumeration defining read preferences.
@ MUST_READ
Reading required.
@ LAZY_READ
Reading is optional [identical to READ_IF_PRESENT].
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition UList.H:89
commsTypes
Communications types.
Definition UPstream.H:81
@ buffered
"buffered" : (MPI_Bsend, MPI_Recv)
Definition UPstream.H:82
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
A FieldMapper for finite-volume patch fields.
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
static tmp< fvPatchField< Type > > Clone(const DerivedPatchField &pf, Args &&... args)
Clone a patch field, optionally with internal field reference etc.
fvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition fvPatch.H:71
This boundary condition provides a base class for 'mixed' type boundary conditions,...
virtual void operator/=(const Field< scalar > &)
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
virtual bool fixesValue() const
True: this patch field fixes a value.
mixedFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
virtual void write(Ostream &) const
Write.
virtual const Field< Type > & refGrad() const
virtual tmp< Field< Type > > gradientInternalCoeffs() const
Return the matrix diagonal coefficients corresponding to the.
virtual void operator+=(const Field< Type > &)
virtual void operator=(const Type &)
virtual void operator*=(const Field< scalar > &)
mixedFvPatchField(const mixedFvPatchField< Type > &, const DimensionedField< Type, volMesh > &)
Construct as copy setting internal field reference.
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< Type > &)
mixedFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &, const Foam::zero)
Construct from patch and internal field, initialise as zero-gradient.
virtual void operator*=(const fvPatchField< scalar > &)
virtual void operator/=(const scalar)
virtual Field< Type > & refGrad()
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 const Field< Type > & source() const
virtual tmp< Field< Type > > valueBoundaryCoeffs(const tmp< scalarField > &) const
Return the matrix source coefficients corresponding to the.
virtual void operator-=(const Type &)
mixedFvPatchField(const mixedFvPatchField< Type > &)
Construct as copy.
virtual const scalarField & valueFraction() const
virtual void rmap(const fvPatchField< Type > &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
bool readMixedEntries(const dictionary &dict, IOobjectOption::readOption readOpt=IOobjectOption::LAZY_READ)
Read the 'refValue', 'refGradient' and 'valueFraction' entries into their respective places.
mixedFvPatchField(const mixedFvPatchField< Type > &, const fvPatch &, const DimensionedField< Type, volMesh > &, const fvPatchFieldMapper &)
Construct by mapping the given mixedFvPatchField onto a new patch.
mixedFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &, const dictionary &, IOobjectOption::readOption requireMixed=IOobjectOption::MUST_READ)
Construct from patch, internal field and dictionary.
virtual const Field< Type > & refValue() const
virtual tmp< fvPatchField< Type > > clone() const
Return a clone.
virtual bool assignable() const
False: this patch field is not altered by assignment.
virtual Field< Type > & refValue()
TypeName("mixed")
Runtime type information.
virtual void operator*=(const scalar)
virtual Field< Type > & source()
virtual void operator-=(const Field< Type > &)
virtual void operator+=(const Type &)
virtual scalarField & valueFraction()
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::buffered)
Evaluate the patch field.
virtual tmp< fvPatchField< Type > > clone(const DimensionedField< Type, volMesh > &iF) const
Clone with an internal field reference.
A class for managing temporary objects.
Definition tmp.H:75
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition zero.H:58
Namespace for OpenFOAM.
List< label > labelList
A List of labels.
Definition List.H:62
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
runTime write()
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition typeInfo.H:68