mixedFaPatchField.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) 2016-2017 Wikki Ltd
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 "mixedFaPatchField.H"
29
30// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
31
32template<class Type>
34(
35 const faPatch& p,
37)
38:
39 faPatchField<Type>(p, iF),
40 refValue_(p.size()),
41 refGrad_(p.size()),
42 valueFraction_(p.size())
43{}
44
45
46template<class Type>
48(
49 const mixedFaPatchField<Type>& ptf,
50 const faPatch& p,
52 const faPatchFieldMapper& mapper
53)
54:
55 faPatchField<Type>(ptf, p, iF, mapper),
56 refValue_(ptf.refValue_, mapper),
57 refGrad_(ptf.refGrad_, mapper),
58 valueFraction_(ptf.valueFraction_, mapper)
59{}
60
61
62template<class Type>
64(
65 const faPatch& p,
67 const dictionary& dict
68)
69:
70 faPatchField<Type>(p, iF),
71 refValue_("refValue", dict, p.size()),
72 refGrad_("refGradient", dict, p.size()),
73 valueFraction_("valueFraction", dict, p.size())
74{
75 evaluate();
76}
77
78
79template<class Type>
81(
83)
84:
85 faPatchField<Type>(ptf),
86 refValue_(ptf.refValue_),
87 refGrad_(ptf.refGrad_),
88 valueFraction_(ptf.valueFraction_)
89{}
90
91
92template<class Type>
94(
95 const mixedFaPatchField<Type>& ptf,
97)
98:
99 faPatchField<Type>(ptf, iF),
100 refValue_(ptf.refValue_),
101 refGrad_(ptf.refGrad_),
102 valueFraction_(ptf.valueFraction_)
103{}
104
105
106// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
107
108template<class Type>
110(
111 const faPatchFieldMapper& m
112)
113{
115 refValue_.autoMap(m);
116 refGrad_.autoMap(m);
117 valueFraction_.autoMap(m);
118}
119
120
121template<class Type>
123(
124 const faPatchField<Type>& ptf,
125 const labelList& addr
126)
127{
128 faPatchField<Type>::rmap(ptf, addr);
129
130 const mixedFaPatchField<Type>& mptf =
131 refCast<const mixedFaPatchField<Type>>(ptf);
132
133 refValue_.rmap(mptf.refValue_, addr);
134 refGrad_.rmap(mptf.refGrad_, addr);
135 valueFraction_.rmap(mptf.valueFraction_, addr);
136}
137
138
139template<class Type>
141{
142 if (!this->updated())
143 {
144 this->updateCoeffs();
145 }
146
148 (
149 valueFraction_*refValue_
150 +
151 (1.0 - valueFraction_)*
152 (
153 this->patchInternalField()
154 + refGrad_/this->patch().deltaCoeffs()
155 )
156 );
157
159}
160
161
162template<class Type>
164{
165 return
166 valueFraction_
167 *(refValue_ - this->patchInternalField())
168 *this->patch().deltaCoeffs()
169 + (1.0 - valueFraction_)*refGrad_;
170}
171
172
173template<class Type>
175(
176 const tmp<scalarField>&
177) const
178{
179 return Type(pTraits<Type>::one)*(1.0 - valueFraction_);
180}
181
182
183template<class Type>
185(
186 const tmp<scalarField>&
187) const
188{
189 return
190 valueFraction_*refValue_
191 + (1.0 - valueFraction_)*refGrad_/this->patch().deltaCoeffs();
192}
193
194
195template<class Type>
198{
199 return -Type(pTraits<Type>::one)*valueFraction_*this->patch().deltaCoeffs();
200}
201
202
203template<class Type>
206{
207 return
208 valueFraction_*this->patch().deltaCoeffs()*refValue_
209 + (1.0 - valueFraction_)*refGrad_;
210}
211
212
213template<class Type>
215{
217 refValue_.writeEntry("refValue", os);
218 refGrad_.writeEntry("refGradient", os);
219 valueFraction_.writeEntry("valueFraction", os);
220 this->writeEntry("value", os);
221}
222
223
224// ************************************************************************* //
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Generic templated field type.
Definition: Field.H:82
void autoMap(const FieldMapper &map, const bool applyFlip=true)
Map from self.
Definition: Field.C:403
void evaluate()
Evaluate boundary conditions.
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
A FieldMapper for finite-area patch fields.
faPatchField<Type> abstract base class. This class gives a fat-interface to all derived classes cover...
Definition: faPatchField.H:82
virtual void rmap(const faPatchField< Type > &, const labelList &)
Reverse map the given faPatchField onto this faPatchField.
Definition: faPatchField.C:190
Finite area patch class. Used for 2-D non-Euclidian finite area method.
Definition: faPatch.H:78
virtual bool write()
Write the output fields.
Author Zeljko Tukovic, FMENA Hrvoje Jasak, Wikki Ltd.
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 void rmap(const faPatchField< Type > &, const labelList &)
Reverse map the given faPatchField onto this faPatchField.
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 autoMap(const faPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
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)
dictionary dict