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

outletMappedUniformInletFvPatchField.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 "outletMappedUniformInletFvPatchField.H"
00027 #include <finiteVolume/volFields.H>
00028 #include <finiteVolume/surfaceFields.H>
00029 
00030 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00031 
00032 namespace Foam
00033 {
00034 
00035 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00036 
00037 template<class Type>
00038 outletMappedUniformInletFvPatchField<Type>::
00039 outletMappedUniformInletFvPatchField
00040 (
00041     const fvPatch& p,
00042     const DimensionedField<Type, volMesh>& iF
00043 )
00044 :
00045     fixedValueFvPatchField<Type>(p, iF),
00046     outletPatchName_(),
00047     phiName_("phi")
00048 {}
00049 
00050 
00051 template<class Type>
00052 outletMappedUniformInletFvPatchField<Type>::
00053 outletMappedUniformInletFvPatchField
00054 (
00055     const outletMappedUniformInletFvPatchField<Type>& ptf,
00056     const fvPatch& p,
00057     const DimensionedField<Type, volMesh>& iF,
00058     const fvPatchFieldMapper& mapper
00059 )
00060 :
00061     fixedValueFvPatchField<Type>(ptf, p, iF, mapper),
00062     outletPatchName_(ptf.outletPatchName_),
00063     phiName_(ptf.phiName_)
00064 {}
00065 
00066 
00067 template<class Type>
00068 outletMappedUniformInletFvPatchField<Type>::
00069 outletMappedUniformInletFvPatchField
00070 (
00071     const fvPatch& p,
00072     const DimensionedField<Type, volMesh>& iF,
00073     const dictionary& dict
00074 )
00075 :
00076     fixedValueFvPatchField<Type>(p, iF, dict),
00077     outletPatchName_(dict.lookup("outletPatchName")),
00078     phiName_(dict.lookupOrDefault<word>("phi", "phi"))
00079 {}
00080 
00081 
00082 template<class Type>
00083 outletMappedUniformInletFvPatchField<Type>::
00084 outletMappedUniformInletFvPatchField
00085 (
00086     const outletMappedUniformInletFvPatchField<Type>& ptf
00087 )
00088 :
00089     fixedValueFvPatchField<Type>(ptf),
00090     outletPatchName_(ptf.outletPatchName_),
00091     phiName_(ptf.phiName_)
00092 {}
00093 
00094 
00095 
00096 template<class Type>
00097 outletMappedUniformInletFvPatchField<Type>::
00098 outletMappedUniformInletFvPatchField
00099 (
00100     const outletMappedUniformInletFvPatchField<Type>& ptf,
00101     const DimensionedField<Type, volMesh>& iF
00102 )
00103 :
00104     fixedValueFvPatchField<Type>(ptf, iF),
00105     outletPatchName_(ptf.outletPatchName_),
00106     phiName_(ptf.phiName_)
00107 {}
00108 
00109 
00110 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00111 
00112 template<class Type>
00113 void outletMappedUniformInletFvPatchField<Type>::updateCoeffs()
00114 {
00115     if (this->updated())
00116     {
00117         return;
00118     }
00119 
00120     const GeometricField<Type, fvPatchField, volMesh>& f
00121     (
00122         dynamic_cast<const GeometricField<Type, fvPatchField, volMesh>&>
00123         (
00124             this->dimensionedInternalField()
00125         )
00126     );
00127 
00128     const fvPatch& p = this->patch();
00129     label outletPatchID =
00130         p.patch().boundaryMesh().findPatchID(outletPatchName_);
00131 
00132     if (outletPatchID < 0)
00133     {
00134         FatalErrorIn
00135         (
00136             "void outletMappedUniformInletFvPatchField<Type>::updateCoeffs()"
00137         )   << "Unable to find outlet patch " << outletPatchName_
00138             << abort(FatalError);
00139     }
00140 
00141     const fvPatch& outletPatch = p.boundaryMesh()[outletPatchID];
00142 
00143     const fvPatchField<Type>& outletPatchField =
00144         f.boundaryField()[outletPatchID];
00145 
00146     const surfaceScalarField& phi =
00147         this->db().objectRegistry::lookupObject<surfaceScalarField>(phiName_);
00148     const scalarField& outletPatchPhi = phi.boundaryField()[outletPatchID];
00149     scalar sumOutletPatchPhi = gSum(outletPatchPhi);
00150 
00151     if (sumOutletPatchPhi > SMALL)
00152     {
00153         Type averageOutletField =
00154             gSum(outletPatchPhi*outletPatchField)
00155            /sumOutletPatchPhi;
00156 
00157         this->operator==(averageOutletField);
00158     }
00159     else
00160     {
00161         Type averageOutletField =
00162             gSum(outletPatch.magSf()*outletPatchField)
00163            /gSum(outletPatch.magSf());
00164 
00165         this->operator==(averageOutletField);
00166     }
00167 
00168     fixedValueFvPatchField<Type>::updateCoeffs();
00169 }
00170 
00171 
00172 template<class Type>
00173 void outletMappedUniformInletFvPatchField<Type>::write(Ostream& os) const
00174 {
00175     fvPatchField<Type>::write(os);
00176     os.writeKeyword("outletPatchName")
00177         << outletPatchName_ << token::END_STATEMENT << nl;
00178     if (phiName_ != "phi")
00179     {
00180         os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
00181     }
00182     this->writeEntry("value", os);
00183 }
00184 
00185 
00186 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00187 
00188 } // End namespace Foam
00189 
00190 // ************************************************************************* //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines