initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / finiteVolume / fields / fvPatchFields / basic / directionMixed / directionMixedFvPatchField.C
blob3be5be1306f9702113d8c8d917ebd5c3727fe24d
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 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 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
19     for more details.
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 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 namespace Foam
35 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
37 template<class Type>
38 directionMixedFvPatchField<Type>::directionMixedFvPatchField
40     const fvPatch& p,
41     const DimensionedField<Type, volMesh>& iF
44     transformFvPatchField<Type>(p, iF),
45     refValue_(p.size()),
46     refGrad_(p.size()),
47     valueFraction_(p.size())
51 template<class Type>
52 directionMixedFvPatchField<Type>::directionMixedFvPatchField
54     const directionMixedFvPatchField<Type>& ptf,
55     const fvPatch& p,
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)
67 template<class Type>
68 directionMixedFvPatchField<Type>::directionMixedFvPatchField
70     const fvPatch& p,
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())
80     evaluate();
84 template<class Type>
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  * * * * * * * * * * * * * //
100 template<class Type>
101 void directionMixedFvPatchField<Type>::autoMap
103     const fvPatchFieldMapper& m
106     transformFvPatchField<Type>::autoMap(m);
107     refValue_.autoMap(m);
108     refGrad_.autoMap(m);
109     valueFraction_.autoMap(m);
113 template<class Type>
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);
131 template<class Type>
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);
143     return
144         (normalValue + transformGradValue - pif)*
145         this->patch().deltaCoeffs();
149 template<class Type>
150 void directionMixedFvPatchField<Type>::evaluate(const Pstream::commsTypes)
152     if (!this->updated())
153     {
154         this->updateCoeffs();
155     }
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();
171 template<class Type>
172 tmp<Field<Type> > directionMixedFvPatchField<Type>::snGradTransformDiag() const
174     vectorField diag(valueFraction_.size());
176     diag.replace
177     (
178         vector::X,
179         sqrt(mag(valueFraction_.component(symmTensor::XX)))
180     );
181     diag.replace
182     (
183         vector::Y,
184         sqrt(mag(valueFraction_.component(symmTensor::YY)))
185     );
186     diag.replace
187     (
188         vector::Z,
189         sqrt(mag(valueFraction_.component(symmTensor::ZZ)))
190     );
192     return transformFieldMask<Type>(pow<vector, pTraits<Type>::rank>(diag));
196 template<class Type>
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 // ************************************************************************* //