1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2004-2010 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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "directionMixedFvPatchField.H"
27 #include "symmTransformField.H"
29 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32 Foam::directionMixedFvPatchField<Type>::directionMixedFvPatchField
35 const DimensionedField<Type, volMesh>& iF
38 transformFvPatchField<Type>(p, iF),
41 valueFraction_(p.size())
46 Foam::directionMixedFvPatchField<Type>::directionMixedFvPatchField
48 const directionMixedFvPatchField<Type>& ptf,
50 const DimensionedField<Type, volMesh>& iF,
51 const fvPatchFieldMapper& mapper
54 transformFvPatchField<Type>(ptf, p, iF, mapper),
55 refValue_(ptf.refValue_, mapper),
56 refGrad_(ptf.refGrad_, mapper),
57 valueFraction_(ptf.valueFraction_, mapper)
62 Foam::directionMixedFvPatchField<Type>::directionMixedFvPatchField
65 const DimensionedField<Type, volMesh>& iF,
66 const dictionary& dict
69 transformFvPatchField<Type>(p, iF, dict),
70 refValue_("refValue", dict, p.size()),
71 refGrad_("refGradient", dict, p.size()),
72 valueFraction_("valueFraction", dict, p.size())
79 Foam::directionMixedFvPatchField<Type>::directionMixedFvPatchField
81 const directionMixedFvPatchField<Type>& ptf,
82 const DimensionedField<Type, volMesh>& iF
85 transformFvPatchField<Type>(ptf, iF),
86 refValue_(ptf.refValue_),
87 refGrad_(ptf.refGrad_),
88 valueFraction_(ptf.valueFraction_)
92 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
95 void Foam::directionMixedFvPatchField<Type>::autoMap
97 const fvPatchFieldMapper& m
100 transformFvPatchField<Type>::autoMap(m);
101 refValue_.autoMap(m);
103 valueFraction_.autoMap(m);
108 void Foam::directionMixedFvPatchField<Type>::rmap
110 const fvPatchField<Type>& ptf,
111 const labelList& addr
114 transformFvPatchField<Type>::rmap(ptf, addr);
116 const directionMixedFvPatchField<Type>& dmptf =
117 refCast<const directionMixedFvPatchField<Type> >(ptf);
119 refValue_.rmap(dmptf.refValue_, addr);
120 refGrad_.rmap(dmptf.refGrad_, addr);
121 valueFraction_.rmap(dmptf.valueFraction_, addr);
126 Foam::tmp<Foam::Field<Type> >
127 Foam::directionMixedFvPatchField<Type>::snGrad() const
129 const Field<Type> pif(this->patchInternalField());
131 tmp<Field<Type> > normalValue = transform(valueFraction_, refValue_);
133 tmp<Field<Type> > gradValue = pif + refGrad_/this->patch().deltaCoeffs();
135 tmp<Field<Type> > transformGradValue =
136 transform(I - valueFraction_, gradValue);
139 (normalValue + transformGradValue - pif)*
140 this->patch().deltaCoeffs();
145 void Foam::directionMixedFvPatchField<Type>::evaluate(const Pstream::commsTypes)
147 if (!this->updated())
149 this->updateCoeffs();
152 tmp<Field<Type> > normalValue = transform(valueFraction_, refValue_);
154 tmp<Field<Type> > gradValue =
155 this->patchInternalField() + refGrad_/this->patch().deltaCoeffs();
157 tmp<Field<Type> > transformGradValue =
158 transform(I - valueFraction_, gradValue);
160 Field<Type>::operator=(normalValue + transformGradValue);
162 transformFvPatchField<Type>::evaluate();
167 Foam::tmp<Foam::Field<Type> >
168 Foam::directionMixedFvPatchField<Type>::snGradTransformDiag() const
170 vectorField diag(valueFraction_.size());
175 sqrt(mag(valueFraction_.component(symmTensor::XX)))
180 sqrt(mag(valueFraction_.component(symmTensor::YY)))
185 sqrt(mag(valueFraction_.component(symmTensor::ZZ)))
188 return transformFieldMask<Type>(pow<vector, pTraits<Type>::rank>(diag));
193 void Foam::directionMixedFvPatchField<Type>::write(Ostream& os) const
195 transformFvPatchField<Type>::write(os);
196 refValue_.writeEntry("refValue", os);
197 refGrad_.writeEntry("refGradient", os);
198 valueFraction_.writeEntry("valueFraction", os);
199 this->writeEntry("value", os);
203 // ************************************************************************* //