1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
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
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "expDirectionMixedFvPatchField.H"
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
37 expDirectionMixedFvPatchField<Type>::expDirectionMixedFvPatchField
40 const DimensionedField<Type, volMesh>& iF
43 fvPatchField<Type>(p, iF),
46 valueFraction_(p.size())
51 expDirectionMixedFvPatchField<Type>::expDirectionMixedFvPatchField
53 const expDirectionMixedFvPatchField<Type>& ptf,
55 const DimensionedField<Type, volMesh>& iF,
56 const fvPatchFieldMapper& mapper
59 fvPatchField<Type>(ptf, p, iF, mapper),
60 refValue_(ptf.refValue_, mapper),
61 refGrad_(ptf.refGrad_, mapper),
62 valueFraction_(ptf.valueFraction_, mapper)
67 expDirectionMixedFvPatchField<Type>::expDirectionMixedFvPatchField
70 const DimensionedField<Type, volMesh>& iF,
71 const dictionary& dict
74 fvPatchField<Type>(p, iF, dict),
75 refValue_("refValue", dict, p.size()),
76 refGrad_("refGradient", dict, p.size()),
77 valueFraction_("valueFraction", dict, p.size())
84 expDirectionMixedFvPatchField<Type>::expDirectionMixedFvPatchField
86 const expDirectionMixedFvPatchField<Type>& ptf
89 fvPatchField<Type>(ptf),
90 refValue_(ptf.refValue_),
91 refGrad_(ptf.refGrad_),
92 valueFraction_(ptf.valueFraction_)
97 expDirectionMixedFvPatchField<Type>::expDirectionMixedFvPatchField
99 const expDirectionMixedFvPatchField<Type>& ptf,
100 const DimensionedField<Type, volMesh>& iF
103 fvPatchField<Type>(ptf, iF),
104 refValue_(ptf.refValue_),
105 refGrad_(ptf.refGrad_),
106 valueFraction_(ptf.valueFraction_)
110 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
113 void expDirectionMixedFvPatchField<Type>::autoMap
115 const fvPatchFieldMapper& m
118 fvPatchField<Type>::autoMap(m);
119 refValue_.autoMap(m);
121 valueFraction_.autoMap(m);
125 // Reverse-map the given fvPatchField onto this fvPatchField
127 void expDirectionMixedFvPatchField<Type>::rmap
129 const fvPatchField<Type>& ptf,
130 const labelList& addr
133 fvPatchField<Type>::rmap(ptf, addr);
135 const expDirectionMixedFvPatchField<Type>& edmptf =
136 refCast<const expDirectionMixedFvPatchField<Type> >(ptf);
138 refValue_.rmap(edmptf.refValue_, addr);
139 refGrad_.rmap(edmptf.refGrad_, addr);
140 valueFraction_.rmap(edmptf.valueFraction_, addr);
145 tmp<Field<Type> > expDirectionMixedFvPatchField<Type>::snGrad() const
147 const vectorField& nHat = patch().faceNormals();
149 Field<Type> gradValue =
150 patchInternalField() + refGrad_/patch().deltaCoeffs();
152 Field<Type> mixedValue =
153 nHat*(nHat & refValue_)
154 + gradValue - nHat*(nHat & gradValue);
158 (mixedValue - patchInternalField())*patch().deltaCoeffs()
159 + (1.0 - valueFraction_)*refGrad_;
164 void expDirectionMixedFvPatchField<Type>::evaluate(const Pstream::commsTypes)
171 const vectorField& nHat = patch().faceNormals();
173 Field<Type> gradValue =
174 patchInternalField() + refGrad_/patch().deltaCoeffs();
176 Field<Type> mixedValue =
177 nHat*(nHat & refValue_)
178 + gradValue - nHat*(nHat & gradValue);
180 Field<Type>::operator=
182 valueFraction_*mixedValue + (1.0 - valueFraction_)*gradValue
185 fvPatchField<Type>::evaluate();
190 tmp<Field<Type> > expDirectionMixedFvPatchField<Type>::valueInternalCoeffs
192 const tmp<scalarField>&
195 return Type(pTraits<Type>::one)*(1.0 - valueFraction_);
200 tmp<Field<Type> > expDirectionMixedFvPatchField<Type>::valueBoundaryCoeffs
202 const tmp<scalarField>&
205 const vectorField& nHat = patch().faceNormals();
207 Field<Type> gradValue =
208 patchInternalField() + refGrad_/patch().deltaCoeffs();
210 Field<Type> mixedValue =
211 nHat*(nHat & refValue_)
212 + gradValue - nHat*(nHat & gradValue);
215 valueFraction_*mixedValue
216 + (1.0 - valueFraction_)*refGrad_/patch().deltaCoeffs();
221 tmp<Field<Type> > expDirectionMixedFvPatchField<Type>::
222 gradientInternalCoeffs() const
224 return -Type(pTraits<Type>::one)*valueFraction_*patch().deltaCoeffs();
229 tmp<Field<Type> > expDirectionMixedFvPatchField<Type>::
230 gradientBoundaryCoeffs() const
232 const vectorField& nHat = patch().faceNormals();
234 Field<Type> gradValue =
235 patchInternalField() + refGrad_/patch().deltaCoeffs();
237 Field<Type> mixedValue =
238 nHat*(nHat & refValue_)
239 + gradValue - nHat*(nHat & gradValue);
242 valueFraction_*patch().deltaCoeffs()*mixedValue
243 + (1.0 - valueFraction_)*refGrad_;
248 void expDirectionMixedFvPatchField<Type>::write(Ostream& os) const
250 fvPatchField<Type>::write(os);
251 refValue_.writeEntry("refValue", os);
252 refGrad_.writeEntry("refGradient", os);
253 valueFraction_.writeEntry("valueFraction", os);
254 writeEntry("value", os);
258 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
260 } // End namespace Foam
262 // ************************************************************************* //