FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

mixedFvPatchField.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-2010 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
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your 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, see <http://www.gnu.org/licenses/>.
00023 
00024 \*---------------------------------------------------------------------------*/
00025 
00026 #include <finiteVolume/mixedFvPatchField.H>
00027 
00028 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00029 
00030 namespace Foam
00031 {
00032 
00033 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00034 
00035 template<class Type>
00036 mixedFvPatchField<Type>::mixedFvPatchField
00037 (
00038     const fvPatch& p,
00039     const DimensionedField<Type, volMesh>& iF
00040 )
00041 :
00042     fvPatchField<Type>(p, iF),
00043     refValue_(p.size()),
00044     refGrad_(p.size()),
00045     valueFraction_(p.size())
00046 {}
00047 
00048 
00049 template<class Type>
00050 mixedFvPatchField<Type>::mixedFvPatchField
00051 (
00052     const mixedFvPatchField<Type>& ptf,
00053     const fvPatch& p,
00054     const DimensionedField<Type, volMesh>& iF,
00055     const fvPatchFieldMapper& mapper
00056 )
00057 :
00058     fvPatchField<Type>(ptf, p, iF, mapper),
00059     refValue_(ptf.refValue_, mapper),
00060     refGrad_(ptf.refGrad_, mapper),
00061     valueFraction_(ptf.valueFraction_, mapper)
00062 {}
00063 
00064 
00065 template<class Type>
00066 mixedFvPatchField<Type>::mixedFvPatchField
00067 (
00068     const fvPatch& p,
00069     const DimensionedField<Type, volMesh>& iF,
00070     const dictionary& dict
00071 )
00072 :
00073     fvPatchField<Type>(p, iF, dict),
00074     refValue_("refValue", dict, p.size()),
00075     refGrad_("refGradient", dict, p.size()),
00076     valueFraction_("valueFraction", dict, p.size())
00077 {
00078     evaluate();
00079 }
00080 
00081 
00082 template<class Type>
00083 mixedFvPatchField<Type>::mixedFvPatchField
00084 (
00085     const mixedFvPatchField<Type>& ptf
00086 )
00087 :
00088     fvPatchField<Type>(ptf),
00089     refValue_(ptf.refValue_),
00090     refGrad_(ptf.refGrad_),
00091     valueFraction_(ptf.valueFraction_)
00092 {}
00093 
00094 
00095 template<class Type>
00096 mixedFvPatchField<Type>::mixedFvPatchField
00097 (
00098     const mixedFvPatchField<Type>& ptf,
00099     const DimensionedField<Type, volMesh>& iF
00100 )
00101 :
00102     fvPatchField<Type>(ptf, iF),
00103     refValue_(ptf.refValue_),
00104     refGrad_(ptf.refGrad_),
00105     valueFraction_(ptf.valueFraction_)
00106 {}
00107 
00108 
00109 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00110 
00111 template<class Type>
00112 void mixedFvPatchField<Type>::autoMap
00113 (
00114     const fvPatchFieldMapper& m
00115 )
00116 {
00117     fvPatchField<Type>::autoMap(m);
00118     refValue_.autoMap(m);
00119     refGrad_.autoMap(m);
00120     valueFraction_.autoMap(m);
00121 }
00122 
00123 
00124 template<class Type>
00125 void mixedFvPatchField<Type>::rmap
00126 (
00127     const fvPatchField<Type>& ptf,
00128     const labelList& addr
00129 )
00130 {
00131     fvPatchField<Type>::rmap(ptf, addr);
00132 
00133     const mixedFvPatchField<Type>& mptf =
00134         refCast<const mixedFvPatchField<Type> >(ptf);
00135 
00136     refValue_.rmap(mptf.refValue_, addr);
00137     refGrad_.rmap(mptf.refGrad_, addr);
00138     valueFraction_.rmap(mptf.valueFraction_, addr);
00139 }
00140 
00141 
00142 template<class Type>
00143 void mixedFvPatchField<Type>::evaluate(const Pstream::commsTypes)
00144 {
00145     if (!this->updated())
00146     {
00147         this->updateCoeffs();
00148     }
00149 
00150     Field<Type>::operator=
00151     (
00152         valueFraction_*refValue_
00153       +
00154         (1.0 - valueFraction_)*
00155         (
00156             this->patchInternalField()
00157           + refGrad_/this->patch().deltaCoeffs()
00158         )
00159     );
00160 
00161     fvPatchField<Type>::evaluate();
00162 }
00163 
00164 
00165 template<class Type>
00166 tmp<Field<Type> > mixedFvPatchField<Type>::snGrad() const
00167 {
00168     return
00169         valueFraction_
00170        *(refValue_ - this->patchInternalField())
00171        *this->patch().deltaCoeffs()
00172       + (1.0 - valueFraction_)*refGrad_;
00173 }
00174 
00175 
00176 template<class Type>
00177 tmp<Field<Type> > mixedFvPatchField<Type>::valueInternalCoeffs
00178 (
00179     const tmp<scalarField>&
00180 ) const
00181 {
00182     return Type(pTraits<Type>::one)*(1.0 - valueFraction_);
00183 
00184 }
00185 
00186 
00187 template<class Type>
00188 tmp<Field<Type> > mixedFvPatchField<Type>::valueBoundaryCoeffs
00189 (
00190     const tmp<scalarField>&
00191 ) const
00192 {
00193     return
00194          valueFraction_*refValue_
00195        + (1.0 - valueFraction_)*refGrad_/this->patch().deltaCoeffs();
00196 }
00197 
00198 
00199 template<class Type>
00200 tmp<Field<Type> > mixedFvPatchField<Type>::gradientInternalCoeffs() const
00201 {
00202     return -Type(pTraits<Type>::one)*valueFraction_*this->patch().deltaCoeffs();
00203 }
00204 
00205 
00206 template<class Type>
00207 tmp<Field<Type> > mixedFvPatchField<Type>::gradientBoundaryCoeffs() const
00208 {
00209     return
00210         valueFraction_*this->patch().deltaCoeffs()*refValue_
00211       + (1.0 - valueFraction_)*refGrad_;
00212 }
00213 
00214 
00215 template<class Type>
00216 void mixedFvPatchField<Type>::write(Ostream& os) const
00217 {
00218     fvPatchField<Type>::write(os);
00219     refValue_.writeEntry("refValue", os);
00220     refGrad_.writeEntry("refGradient", os);
00221     valueFraction_.writeEntry("valueFraction", os);
00222     this->writeEntry("value", os);
00223 }
00224 
00225 
00226 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00227 
00228 } // End namespace Foam
00229 
00230 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines