initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / finiteVolume / fields / fvPatchFields / derived / expDirectionMixed / expDirectionMixedFvPatchField.C
blob88fee229bf3f582a99ad10a726b27faceba90853
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: 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 "expDirectionMixedFvPatchField.H"
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31 namespace Foam
34 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
36 template<class Type>
37 expDirectionMixedFvPatchField<Type>::expDirectionMixedFvPatchField
39     const fvPatch& p,
40     const DimensionedField<Type, volMesh>& iF
43     fvPatchField<Type>(p, iF),
44     refValue_(p.size()),
45     refGrad_(p.size()),
46     valueFraction_(p.size())
50 template<class Type>
51 expDirectionMixedFvPatchField<Type>::expDirectionMixedFvPatchField
53     const expDirectionMixedFvPatchField<Type>& ptf,
54     const fvPatch& p,
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)
66 template<class Type>
67 expDirectionMixedFvPatchField<Type>::expDirectionMixedFvPatchField
69     const fvPatch& p,
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())
79     evaluate();
83 template<class Type>
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_)
96 template<class Type>
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  * * * * * * * * * * * * * //
112 template<class Type>
113 void expDirectionMixedFvPatchField<Type>::autoMap
115     const fvPatchFieldMapper& m
118     fvPatchField<Type>::autoMap(m);
119     refValue_.autoMap(m);
120     refGrad_.autoMap(m);
121     valueFraction_.autoMap(m);
125 // Reverse-map the given fvPatchField onto this fvPatchField
126 template<class Type>
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);
144 template<class Type>
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);
156     return
157         valueFraction_*
158             (mixedValue - patchInternalField())*patch().deltaCoeffs()
159       + (1.0 - valueFraction_)*refGrad_;
163 template<class Type>
164 void expDirectionMixedFvPatchField<Type>::evaluate(const Pstream::commsTypes)
166     if (!updated())
167     {
168         updateCoeffs();
169     }
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=
181     (
182         valueFraction_*mixedValue + (1.0 - valueFraction_)*gradValue
183     );
185     fvPatchField<Type>::evaluate();
189 template<class Type>
190 tmp<Field<Type> > expDirectionMixedFvPatchField<Type>::valueInternalCoeffs
192     const tmp<scalarField>&
193 ) const
195     return Type(pTraits<Type>::one)*(1.0 - valueFraction_);
199 template<class Type>
200 tmp<Field<Type> > expDirectionMixedFvPatchField<Type>::valueBoundaryCoeffs
202     const tmp<scalarField>&
203 ) const
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);
214     return
215         valueFraction_*mixedValue
216       + (1.0 - valueFraction_)*refGrad_/patch().deltaCoeffs();
220 template<class Type>
221 tmp<Field<Type> > expDirectionMixedFvPatchField<Type>::
222 gradientInternalCoeffs() const
224     return -Type(pTraits<Type>::one)*valueFraction_*patch().deltaCoeffs();
228 template<class Type>
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);
241     return
242         valueFraction_*patch().deltaCoeffs()*mixedValue
243       + (1.0 - valueFraction_)*refGrad_;
247 template<class Type>
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 // ************************************************************************* //