OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

expDirectionMixedFvPatchField.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 \*---------------------------------------------------------------------------*/
00026 
00027 #include "expDirectionMixedFvPatchField.H"
00028 
00029 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00030 
00031 namespace Foam
00032 {
00033 
00034 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00035 
00036 template<class Type>
00037 expDirectionMixedFvPatchField<Type>::expDirectionMixedFvPatchField
00038 (
00039     const fvPatch& p,
00040     const DimensionedField<Type, volMesh>& iF
00041 )
00042 :
00043     fvPatchField<Type>(p, iF),
00044     refValue_(p.size()),
00045     refGrad_(p.size()),
00046     valueFraction_(p.size())
00047 {}
00048 
00049 
00050 template<class Type>
00051 expDirectionMixedFvPatchField<Type>::expDirectionMixedFvPatchField
00052 (
00053     const expDirectionMixedFvPatchField<Type>& ptf,
00054     const fvPatch& p,
00055     const DimensionedField<Type, volMesh>& iF,
00056     const fvPatchFieldMapper& mapper
00057 )
00058 :
00059     fvPatchField<Type>(ptf, p, iF, mapper),
00060     refValue_(ptf.refValue_, mapper),
00061     refGrad_(ptf.refGrad_, mapper),
00062     valueFraction_(ptf.valueFraction_, mapper)
00063 {}
00064 
00065 
00066 template<class Type>
00067 expDirectionMixedFvPatchField<Type>::expDirectionMixedFvPatchField
00068 (
00069     const fvPatch& p,
00070     const DimensionedField<Type, volMesh>& iF,
00071     const dictionary& dict
00072 )
00073 :
00074     fvPatchField<Type>(p, iF, dict),
00075     refValue_("refValue", dict, p.size()),
00076     refGrad_("refGradient", dict, p.size()),
00077     valueFraction_("valueFraction", dict, p.size())
00078 {
00079     evaluate();
00080 }
00081 
00082 
00083 template<class Type>
00084 expDirectionMixedFvPatchField<Type>::expDirectionMixedFvPatchField
00085 (
00086     const expDirectionMixedFvPatchField<Type>& ptf
00087 )
00088 :
00089     fvPatchField<Type>(ptf),
00090     refValue_(ptf.refValue_),
00091     refGrad_(ptf.refGrad_),
00092     valueFraction_(ptf.valueFraction_)
00093 {}
00094 
00095 
00096 template<class Type>
00097 expDirectionMixedFvPatchField<Type>::expDirectionMixedFvPatchField
00098 (
00099     const expDirectionMixedFvPatchField<Type>& ptf,
00100     const DimensionedField<Type, volMesh>& iF
00101 )
00102 :
00103     fvPatchField<Type>(ptf, iF),
00104     refValue_(ptf.refValue_),
00105     refGrad_(ptf.refGrad_),
00106     valueFraction_(ptf.valueFraction_)
00107 {}
00108 
00109 
00110 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00111 
00112 template<class Type>
00113 void expDirectionMixedFvPatchField<Type>::autoMap
00114 (
00115     const fvPatchFieldMapper& m
00116 )
00117 {
00118     fvPatchField<Type>::autoMap(m);
00119     refValue_.autoMap(m);
00120     refGrad_.autoMap(m);
00121     valueFraction_.autoMap(m);
00122 }
00123 
00124 
00125 // Reverse-map the given fvPatchField onto this fvPatchField
00126 template<class Type>
00127 void expDirectionMixedFvPatchField<Type>::rmap
00128 (
00129     const fvPatchField<Type>& ptf,
00130     const labelList& addr
00131 )
00132 {
00133     fvPatchField<Type>::rmap(ptf, addr);
00134 
00135     const expDirectionMixedFvPatchField<Type>& edmptf =
00136         refCast<const expDirectionMixedFvPatchField<Type> >(ptf);
00137 
00138     refValue_.rmap(edmptf.refValue_, addr);
00139     refGrad_.rmap(edmptf.refGrad_, addr);
00140     valueFraction_.rmap(edmptf.valueFraction_, addr);
00141 }
00142 
00143 
00144 template<class Type>
00145 tmp<Field<Type> > expDirectionMixedFvPatchField<Type>::snGrad() const
00146 {
00147     const vectorField& nHat = patch().faceNormals();
00148 
00149     Field<Type> gradValue =
00150         patchInternalField() + refGrad_/patch().deltaCoeffs();
00151 
00152     Field<Type> mixedValue =
00153         nHat*(nHat & refValue_)
00154       + gradValue - nHat*(nHat & gradValue);
00155 
00156     return
00157         valueFraction_*
00158             (mixedValue - patchInternalField())*patch().deltaCoeffs()
00159       + (1.0 - valueFraction_)*refGrad_;
00160 }
00161 
00162 
00163 template<class Type>
00164 void expDirectionMixedFvPatchField<Type>::evaluate(const Pstream::commsTypes)
00165 {
00166     if (!updated())
00167     {
00168         updateCoeffs();
00169     }
00170 
00171     const vectorField& nHat = patch().faceNormals();
00172 
00173     Field<Type> gradValue =
00174         patchInternalField() + refGrad_/patch().deltaCoeffs();
00175 
00176     Field<Type> mixedValue =
00177         nHat*(nHat & refValue_)
00178       + gradValue - nHat*(nHat & gradValue);
00179 
00180     Field<Type>::operator=
00181     (
00182         valueFraction_*mixedValue + (1.0 - valueFraction_)*gradValue
00183     );
00184 
00185     fvPatchField<Type>::evaluate();
00186 }
00187 
00188 
00189 template<class Type>
00190 tmp<Field<Type> > expDirectionMixedFvPatchField<Type>::valueInternalCoeffs
00191 (
00192     const tmp<scalarField>&
00193 ) const
00194 {
00195     return Type(pTraits<Type>::one)*(1.0 - valueFraction_);
00196 }
00197 
00198 
00199 template<class Type>
00200 tmp<Field<Type> > expDirectionMixedFvPatchField<Type>::valueBoundaryCoeffs
00201 (
00202     const tmp<scalarField>&
00203 ) const
00204 {
00205     const vectorField& nHat = patch().faceNormals();
00206 
00207     Field<Type> gradValue =
00208         patchInternalField() + refGrad_/patch().deltaCoeffs();
00209 
00210     Field<Type> mixedValue =
00211         nHat*(nHat & refValue_)
00212       + gradValue - nHat*(nHat & gradValue);
00213 
00214     return
00215         valueFraction_*mixedValue
00216       + (1.0 - valueFraction_)*refGrad_/patch().deltaCoeffs();
00217 }
00218 
00219 
00220 template<class Type>
00221 tmp<Field<Type> > expDirectionMixedFvPatchField<Type>::
00222 gradientInternalCoeffs() const
00223 {
00224     return -Type(pTraits<Type>::one)*valueFraction_*patch().deltaCoeffs();
00225 }
00226 
00227 
00228 template<class Type>
00229 tmp<Field<Type> > expDirectionMixedFvPatchField<Type>::
00230 gradientBoundaryCoeffs() const
00231 {
00232     const vectorField& nHat = patch().faceNormals();
00233 
00234     Field<Type> gradValue =
00235         patchInternalField() + refGrad_/patch().deltaCoeffs();
00236 
00237     Field<Type> mixedValue =
00238         nHat*(nHat & refValue_)
00239       + gradValue - nHat*(nHat & gradValue);
00240 
00241     return
00242         valueFraction_*patch().deltaCoeffs()*mixedValue
00243       + (1.0 - valueFraction_)*refGrad_;
00244 }
00245 
00246 
00247 template<class Type>
00248 void expDirectionMixedFvPatchField<Type>::write(Ostream& os) const
00249 {
00250     fvPatchField<Type>::write(os);
00251     refValue_.writeEntry("refValue", os);
00252     refGrad_.writeEntry("refGradient", os);
00253     valueFraction_.writeEntry("valueFraction", os);
00254     writeEntry("value", os);
00255 }
00256 
00257 
00258 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00259 
00260 } // End namespace Foam
00261 
00262 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd