Initial commit for version 2.0.x patch release
[OpenFOAM-2.0.x.git] / src / finiteVolume / fields / fvPatchFields / basic / directionMixed / directionMixedFvPatchField.C
blob7335cb77d9dbc83bef2191a6960d582e0c3481c1
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2004-2010 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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  * * * * * * * * * * * * * * //
31 template<class Type>
32 Foam::directionMixedFvPatchField<Type>::directionMixedFvPatchField
34     const fvPatch& p,
35     const DimensionedField<Type, volMesh>& iF
38     transformFvPatchField<Type>(p, iF),
39     refValue_(p.size()),
40     refGrad_(p.size()),
41     valueFraction_(p.size())
45 template<class Type>
46 Foam::directionMixedFvPatchField<Type>::directionMixedFvPatchField
48     const directionMixedFvPatchField<Type>& ptf,
49     const fvPatch& p,
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)
61 template<class Type>
62 Foam::directionMixedFvPatchField<Type>::directionMixedFvPatchField
64     const fvPatch& p,
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())
74     evaluate();
78 template<class Type>
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  * * * * * * * * * * * * * //
94 template<class Type>
95 void Foam::directionMixedFvPatchField<Type>::autoMap
97     const fvPatchFieldMapper& m
100     transformFvPatchField<Type>::autoMap(m);
101     refValue_.autoMap(m);
102     refGrad_.autoMap(m);
103     valueFraction_.autoMap(m);
107 template<class Type>
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);
125 template<class Type>
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);
138     return
139         (normalValue + transformGradValue - pif)*
140         this->patch().deltaCoeffs();
144 template<class Type>
145 void Foam::directionMixedFvPatchField<Type>::evaluate(const Pstream::commsTypes)
147     if (!this->updated())
148     {
149         this->updateCoeffs();
150     }
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();
166 template<class Type>
167 Foam::tmp<Foam::Field<Type> >
168 Foam::directionMixedFvPatchField<Type>::snGradTransformDiag() const
170     vectorField diag(valueFraction_.size());
172     diag.replace
173     (
174         vector::X,
175         sqrt(mag(valueFraction_.component(symmTensor::XX)))
176     );
177     diag.replace
178     (
179         vector::Y,
180         sqrt(mag(valueFraction_.component(symmTensor::YY)))
181     );
182     diag.replace
183     (
184         vector::Z,
185         sqrt(mag(valueFraction_.component(symmTensor::ZZ)))
186     );
188     return transformFieldMask<Type>(pow<vector, pTraits<Type>::rank>(diag));
192 template<class Type>
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 // ************************************************************************* //