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

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-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 "mixedFvPatchField.H"
00028 
00029 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00030 
00031 namespace Foam
00032 {
00033 
00034 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00035 
00036 template<class Type>
00037 mixedFvPatchField<Type>::mixedFvPatchField
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 mixedFvPatchField<Type>::mixedFvPatchField
00052 (
00053     const mixedFvPatchField<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 mixedFvPatchField<Type>::mixedFvPatchField
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 mixedFvPatchField<Type>::mixedFvPatchField
00085 (
00086     const mixedFvPatchField<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 mixedFvPatchField<Type>::mixedFvPatchField
00098 (
00099     const mixedFvPatchField<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 mixedFvPatchField<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 template<class Type>
00126 void mixedFvPatchField<Type>::rmap
00127 (
00128     const fvPatchField<Type>& ptf,
00129     const labelList& addr
00130 )
00131 {
00132     fvPatchField<Type>::rmap(ptf, addr);
00133 
00134     const mixedFvPatchField<Type>& mptf =
00135         refCast<const mixedFvPatchField<Type> >(ptf);
00136 
00137     refValue_.rmap(mptf.refValue_, addr);
00138     refGrad_.rmap(mptf.refGrad_, addr);
00139     valueFraction_.rmap(mptf.valueFraction_, addr);
00140 }
00141 
00142 
00143 template<class Type>
00144 void mixedFvPatchField<Type>::evaluate(const Pstream::commsTypes)
00145 {
00146     if (!this->updated())
00147     {
00148         this->updateCoeffs();
00149     }
00150 
00151     Field<Type>::operator=
00152     (
00153         valueFraction_*refValue_
00154       +
00155         (1.0 - valueFraction_)*
00156         (
00157             this->patchInternalField()
00158           + refGrad_/this->patch().deltaCoeffs()
00159         )
00160     );
00161 
00162     fvPatchField<Type>::evaluate();
00163 }
00164 
00165 
00166 template<class Type>
00167 tmp<Field<Type> > mixedFvPatchField<Type>::snGrad() const
00168 {
00169     return
00170         valueFraction_
00171        *(refValue_ - this->patchInternalField())
00172        *this->patch().deltaCoeffs()
00173       + (1.0 - valueFraction_)*refGrad_;
00174 }
00175 
00176 
00177 template<class Type>
00178 tmp<Field<Type> > mixedFvPatchField<Type>::valueInternalCoeffs
00179 (
00180     const tmp<scalarField>&
00181 ) const
00182 {
00183     return Type(pTraits<Type>::one)*(1.0 - valueFraction_);
00184 
00185 }
00186 
00187 
00188 template<class Type>
00189 tmp<Field<Type> > mixedFvPatchField<Type>::valueBoundaryCoeffs
00190 (
00191     const tmp<scalarField>&
00192 ) const
00193 {
00194     return
00195          valueFraction_*refValue_
00196        + (1.0 - valueFraction_)*refGrad_/this->patch().deltaCoeffs();
00197 }
00198 
00199 
00200 template<class Type>
00201 tmp<Field<Type> > mixedFvPatchField<Type>::gradientInternalCoeffs() const
00202 {
00203     return -Type(pTraits<Type>::one)*valueFraction_*this->patch().deltaCoeffs();
00204 }
00205 
00206 
00207 template<class Type>
00208 tmp<Field<Type> > mixedFvPatchField<Type>::gradientBoundaryCoeffs() const
00209 {
00210     return
00211         valueFraction_*this->patch().deltaCoeffs()*refValue_
00212       + (1.0 - valueFraction_)*refGrad_;
00213 }
00214 
00215 
00216 template<class Type>
00217 void mixedFvPatchField<Type>::write(Ostream& os) const
00218 {
00219     fvPatchField<Type>::write(os);
00220     refValue_.writeEntry("refValue", os);
00221     refGrad_.writeEntry("refGradient", os);
00222     valueFraction_.writeEntry("valueFraction", os);
00223     this->writeEntry("value", os);
00224 }
00225 
00226 
00227 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00228 
00229 } // End namespace Foam
00230 
00231 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd