1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenOAM: 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 "directionMixedFvPatchField.H"
28 #include "symmTransformField.H"
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
38 directionMixedFvPatchField<Type>::directionMixedFvPatchField
41 const DimensionedField<Type, volMesh>& iF
44 transformFvPatchField<Type>(p, iF),
47 valueFraction_(p.size())
52 directionMixedFvPatchField<Type>::directionMixedFvPatchField
54 const directionMixedFvPatchField<Type>& ptf,
56 const DimensionedField<Type, volMesh>& iF,
57 const fvPatchFieldMapper& mapper
60 transformFvPatchField<Type>(ptf, p, iF, mapper),
61 refValue_(ptf.refValue_, mapper),
62 refGrad_(ptf.refGrad_, mapper),
63 valueFraction_(ptf.valueFraction_, mapper)
68 directionMixedFvPatchField<Type>::directionMixedFvPatchField
71 const DimensionedField<Type, volMesh>& iF,
72 const dictionary& dict
75 transformFvPatchField<Type>(p, iF, dict),
76 refValue_("refValue", dict, p.size()),
77 refGrad_("refGradient", dict, p.size()),
78 valueFraction_("valueFraction", dict, p.size())
85 directionMixedFvPatchField<Type>::directionMixedFvPatchField
87 const directionMixedFvPatchField<Type>& ptf,
88 const DimensionedField<Type, volMesh>& iF
91 transformFvPatchField<Type>(ptf, iF),
92 refValue_(ptf.refValue_),
93 refGrad_(ptf.refGrad_),
94 valueFraction_(ptf.valueFraction_)
98 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
101 void directionMixedFvPatchField<Type>::autoMap
103 const fvPatchFieldMapper& m
106 transformFvPatchField<Type>::autoMap(m);
107 refValue_.autoMap(m);
109 valueFraction_.autoMap(m);
114 void directionMixedFvPatchField<Type>::rmap
116 const fvPatchField<Type>& ptf,
117 const labelList& addr
120 transformFvPatchField<Type>::rmap(ptf, addr);
122 const directionMixedFvPatchField<Type>& dmptf =
123 refCast<const directionMixedFvPatchField<Type> >(ptf);
125 refValue_.rmap(dmptf.refValue_, addr);
126 refGrad_.rmap(dmptf.refGrad_, addr);
127 valueFraction_.rmap(dmptf.valueFraction_, addr);
132 tmp<Field<Type> > directionMixedFvPatchField<Type>::snGrad() const
134 Field<Type> pif = this->patchInternalField();
136 Field<Type> normalValue = transform(valueFraction_, refValue_);
138 Field<Type> gradValue = pif + refGrad_/this->patch().deltaCoeffs();
140 Field<Type> transformGradValue =
141 transform(I - valueFraction_, gradValue);
144 (normalValue + transformGradValue - pif)*
145 this->patch().deltaCoeffs();
150 void directionMixedFvPatchField<Type>::evaluate(const Pstream::commsTypes)
152 if (!this->updated())
154 this->updateCoeffs();
157 Field<Type> normalValue = transform(valueFraction_, refValue_);
159 Field<Type> gradValue =
160 this->patchInternalField() + refGrad_/this->patch().deltaCoeffs();
162 Field<Type> transformGradValue =
163 transform(I - valueFraction_, gradValue);
165 Field<Type>::operator=(normalValue + transformGradValue);
167 transformFvPatchField<Type>::evaluate();
172 tmp<Field<Type> > directionMixedFvPatchField<Type>::snGradTransformDiag() const
174 vectorField diag(valueFraction_.size());
179 sqrt(mag(valueFraction_.component(symmTensor::XX)))
184 sqrt(mag(valueFraction_.component(symmTensor::YY)))
189 sqrt(mag(valueFraction_.component(symmTensor::ZZ)))
192 return transformFieldMask<Type>(pow<vector, pTraits<Type>::rank>(diag));
197 void directionMixedFvPatchField<Type>::write(Ostream& os) const
199 transformFvPatchField<Type>::write(os);
200 refValue_.writeEntry("refValue", os);
201 refGrad_.writeEntry("refGradient", os);
202 valueFraction_.writeEntry("valueFraction", os);
203 this->writeEntry("value", os);
207 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
209 } // End namespace Foam
211 // ************************************************************************* //