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

inletOutletFvPatchField.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/inletOutletFvPatchField.H>
00027 
00028 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00029 
00030 namespace Foam
00031 {
00032 
00033 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00034 
00035 template<class Type>
00036 inletOutletFvPatchField<Type>::inletOutletFvPatchField
00037 (
00038     const fvPatch& p,
00039     const DimensionedField<Type, volMesh>& iF
00040 )
00041 :
00042     mixedFvPatchField<Type>(p, iF),
00043     phiName_("phi")
00044 {
00045     this->refValue() = pTraits<Type>::zero;
00046     this->refGrad() = pTraits<Type>::zero;
00047     this->valueFraction() = 0.0;
00048 }
00049 
00050 
00051 template<class Type>
00052 inletOutletFvPatchField<Type>::inletOutletFvPatchField
00053 (
00054     const inletOutletFvPatchField<Type>& ptf,
00055     const fvPatch& p,
00056     const DimensionedField<Type, volMesh>& iF,
00057     const fvPatchFieldMapper& mapper
00058 )
00059 :
00060     mixedFvPatchField<Type>(ptf, p, iF, mapper),
00061     phiName_(ptf.phiName_)
00062 {}
00063 
00064 
00065 template<class Type>
00066 inletOutletFvPatchField<Type>::inletOutletFvPatchField
00067 (
00068     const fvPatch& p,
00069     const DimensionedField<Type, volMesh>& iF,
00070     const dictionary& dict
00071 )
00072 :
00073     mixedFvPatchField<Type>(p, iF),
00074     phiName_(dict.lookupOrDefault<word>("phi", "phi"))
00075 {
00076     this->refValue() = Field<Type>("inletValue", dict, p.size());
00077 
00078     if (dict.found("value"))
00079     {
00080         fvPatchField<Type>::operator=
00081         (
00082             Field<Type>("value", dict, p.size())
00083         );
00084     }
00085     else
00086     {
00087         fvPatchField<Type>::operator=(this->refValue());
00088     }
00089 
00090     this->refGrad() = pTraits<Type>::zero;
00091     this->valueFraction() = 0.0;
00092 }
00093 
00094 
00095 template<class Type>
00096 inletOutletFvPatchField<Type>::inletOutletFvPatchField
00097 (
00098     const inletOutletFvPatchField<Type>& ptf
00099 )
00100 :
00101     mixedFvPatchField<Type>(ptf),
00102     phiName_(ptf.phiName_)
00103 {}
00104 
00105 
00106 template<class Type>
00107 inletOutletFvPatchField<Type>::inletOutletFvPatchField
00108 (
00109     const inletOutletFvPatchField<Type>& ptf,
00110     const DimensionedField<Type, volMesh>& iF
00111 )
00112 :
00113     mixedFvPatchField<Type>(ptf, iF),
00114     phiName_(ptf.phiName_)
00115 {}
00116 
00117 
00118 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00119 
00120 template<class Type>
00121 void inletOutletFvPatchField<Type>::updateCoeffs()
00122 {
00123     if (this->updated())
00124     {
00125         return;
00126     }
00127 
00128     const Field<scalar>& phip = this->patch().lookupPatchField
00129     (
00130         phiName_,
00131         reinterpret_cast<const surfaceScalarField*>(0),
00132         reinterpret_cast<const scalar*>(0)
00133     );
00134 
00135     this->valueFraction() = 1.0 - pos(phip);
00136 
00137     mixedFvPatchField<Type>::updateCoeffs();
00138 }
00139 
00140 
00141 template<class Type>
00142 void inletOutletFvPatchField<Type>::write(Ostream& os) const
00143 {
00144     fvPatchField<Type>::write(os);
00145     if (phiName_ != "phi")
00146     {
00147         os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
00148     }
00149     this->refValue().writeEntry("inletValue", os);
00150     this->writeEntry("value", os);
00151 }
00152 
00153 
00154 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
00155 
00156 template<class Type>
00157 void inletOutletFvPatchField<Type>::operator=
00158 (
00159     const fvPatchField<Type>& ptf
00160 )
00161 {
00162     fvPatchField<Type>::operator=
00163     (
00164         this->valueFraction()*this->refValue()
00165         + (1 - this->valueFraction())*ptf
00166     );
00167 }
00168 
00169 
00170 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00171 
00172 } // End namespace Foam
00173 
00174 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines