mixedFvPatchField.C
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-2016 OpenFOAM Foundation
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26\*---------------------------------------------------------------------------*/
27
28#include "mixedFvPatchField.H"
29
30// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
31
32template<class Type>
34(
35 const fvPatch& p,
37)
38:
39 fvPatchField<Type>(p, iF),
40 refValue_(p.size()),
41 refGrad_(p.size()),
42 valueFraction_(p.size()),
43 source_(p.size(), Zero)
44{}
45
46
47template<class Type>
49(
50 const fvPatch& p,
52 const dictionary& dict
53)
54:
55 fvPatchField<Type>(p, iF, dict, false),
56 refValue_("refValue", dict, p.size()),
57 refGrad_("refGradient", dict, p.size()),
58 valueFraction_("valueFraction", dict, p.size()),
59 source_(p.size(), Zero)
60{
61 // Could also check/clip fraction to 0-1 range
62 evaluate();
63}
64
65
66template<class Type>
68(
69 const mixedFvPatchField<Type>& ptf,
70 const fvPatch& p,
72 const fvPatchFieldMapper& mapper
73)
74:
75 fvPatchField<Type>(ptf, p, iF, mapper),
76 refValue_(ptf.refValue_, mapper),
77 refGrad_(ptf.refGrad_, mapper),
78 valueFraction_(ptf.valueFraction_, mapper),
79 source_(ptf.source_, mapper)
80{
81 if (notNull(iF) && mapper.hasUnmapped())
82 {
84 << "On field " << iF.name() << " patch " << p.name()
85 << " patchField " << this->type()
86 << " : mapper does not map all values." << nl
87 << " To avoid this warning fully specify the mapping in derived"
88 << " patch fields." << endl;
89 }
90}
91
92
93template<class Type>
95(
97)
98:
99 fvPatchField<Type>(ptf),
100 refValue_(ptf.refValue_),
101 refGrad_(ptf.refGrad_),
102 valueFraction_(ptf.valueFraction_),
103 source_(ptf.source_)
104{}
105
106
107template<class Type>
109(
110 const mixedFvPatchField<Type>& ptf,
112)
113:
114 fvPatchField<Type>(ptf, iF),
115 refValue_(ptf.refValue_),
116 refGrad_(ptf.refGrad_),
117 valueFraction_(ptf.valueFraction_),
118 source_(ptf.source_)
119{}
120
121
122// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
123
124template<class Type>
126(
127 const fvPatchFieldMapper& m
128)
129{
131 refValue_.autoMap(m);
132 refGrad_.autoMap(m);
133 valueFraction_.autoMap(m);
134 source_.autoMap(m);
135}
136
137
138template<class Type>
140(
141 const fvPatchField<Type>& ptf,
142 const labelList& addr
143)
144{
145 fvPatchField<Type>::rmap(ptf, addr);
146
147 const mixedFvPatchField<Type>& mptf =
148 refCast<const mixedFvPatchField<Type>>(ptf);
149
150 refValue_.rmap(mptf.refValue_, addr);
151 refGrad_.rmap(mptf.refGrad_, addr);
152 valueFraction_.rmap(mptf.valueFraction_, addr);
153 source_.rmap(mptf.source_, addr);
154}
155
156
157template<class Type>
159{
160
161 if (!this->updated())
162 {
163 this->updateCoeffs();
164 }
165
167 (
168 valueFraction_*refValue_
169 + (1.0 - valueFraction_)
170 *(
171 this->patchInternalField()
172 + refGrad_/this->patch().deltaCoeffs()
173 )
174 );
177}
178
179
180template<class Type>
183{
184 return
185 valueFraction_
186 *(refValue_ - this->patchInternalField())
187 *this->patch().deltaCoeffs()
188 + (1.0 - valueFraction_)*refGrad_;
189}
191
192template<class Type>
195(
196 const tmp<scalarField>&
197) const
198{
199 return Type(pTraits<Type>::one)*(1.0 - valueFraction_);
200}
201
202
203template<class Type>
206(
207 const tmp<scalarField>&
208) const
209{
210 return
211 valueFraction_*refValue_
212 + (1.0 - valueFraction_)*refGrad_/this->patch().deltaCoeffs();
213}
214
215
216template<class Type>
219{
220 return -Type(pTraits<Type>::one)*valueFraction_*this->patch().deltaCoeffs();
221}
222
223
224template<class Type>
227{
228 return
229 valueFraction_*this->patch().deltaCoeffs()*refValue_
230 + (1.0 - valueFraction_)*refGrad_;
231}
232
233
234template<class Type>
236{
238 refValue_.writeEntry("refValue", os);
239 refGrad_.writeEntry("refGradient", os);
240 valueFraction_.writeEntry("valueFraction", os);
241 source_.writeEntry("source", os);
242 this->writeEntry("value", os);
243}
244
245
246// ************************************************************************* //
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
virtual bool hasUnmapped() const =0
Any unmapped values?
Generic templated field type.
Definition: Field.H:82
void evaluate()
Evaluate boundary conditions.
const word & name() const noexcept
Return the object name.
Definition: IOobjectI.H:65
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
commsTypes
Types of communications.
Definition: UPstream.H:67
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
virtual bool write()
Write the output fields.
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...
Definition: fvPatchField.H:82
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
Definition: fvPatchField.C:252
virtual void rmap(const fvPatchField< Type > &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
Definition: fvPatchField.C:315
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 autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::blocking)
Evaluate the patch field.
virtual tmp< Field< Type > > gradientInternalCoeffs() const
Return the matrix diagonal coefficients corresponding to the.
virtual tmp< Field< Type > > snGrad() const
Return gradient at boundary.
virtual tmp< Field< Type > > valueInternalCoeffs(const tmp< scalarField > &) const
Return the matrix diagonal coefficients corresponding to the.
virtual tmp< Field< Type > > gradientBoundaryCoeffs() const
Return the matrix source coefficients corresponding to the.
virtual tmp< Field< Type > > valueBoundaryCoeffs(const tmp< scalarField > &) const
Return the matrix source coefficients corresponding to the.
virtual void rmap(const fvPatchField< Type > &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
A class representing the concept of 1 (one) that can be used to avoid manipulating objects known to b...
Definition: one.H:62
A class for managing temporary objects.
Definition: tmp.H:65
volScalarField & p
OBJstream os(runTime.globalPath()/outputName)
#define WarningInFunction
Report a warning using Foam::Warning.
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: MSwindows.C:598
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
bool notNull(const T *ptr)
True if ptr is not a pointer (of type T) to the nullObject.
Definition: nullObject.H:207
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53
dictionary dict