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

fixedGradientFvPatchField.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 "fixedGradientFvPatchField.H"
00027 #include <OpenFOAM/dictionary.H>
00028 
00029 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00030 
00031 namespace Foam
00032 {
00033 
00034 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00035 
00036 template<class Type>
00037 fixedGradientFvPatchField<Type>::fixedGradientFvPatchField
00038 (
00039     const fvPatch& p,
00040     const DimensionedField<Type, volMesh>& iF
00041 )
00042 :
00043     fvPatchField<Type>(p, iF),
00044     gradient_(p.size(), pTraits<Type>::zero)
00045 {}
00046 
00047 
00048 template<class Type>
00049 fixedGradientFvPatchField<Type>::fixedGradientFvPatchField
00050 (
00051     const fixedGradientFvPatchField<Type>& ptf,
00052     const fvPatch& p,
00053     const DimensionedField<Type, volMesh>& iF,
00054     const fvPatchFieldMapper& mapper
00055 )
00056 :
00057     fvPatchField<Type>(ptf, p, iF, mapper),
00058     gradient_(ptf.gradient_, mapper)
00059 {}
00060 
00061 
00062 template<class Type>
00063 fixedGradientFvPatchField<Type>::fixedGradientFvPatchField
00064 (
00065     const fvPatch& p,
00066     const DimensionedField<Type, volMesh>& iF,
00067     const dictionary& dict
00068 )
00069 :
00070     fvPatchField<Type>(p, iF, dict),
00071     gradient_("gradient", dict, p.size())
00072 {
00073     evaluate();
00074 }
00075 
00076 
00077 template<class Type>
00078 fixedGradientFvPatchField<Type>::fixedGradientFvPatchField
00079 (
00080     const fixedGradientFvPatchField<Type>& ptf
00081 )
00082 :
00083     fvPatchField<Type>(ptf),
00084     gradient_(ptf.gradient_)
00085 {}
00086 
00087 
00088 template<class Type>
00089 fixedGradientFvPatchField<Type>::fixedGradientFvPatchField
00090 (
00091     const fixedGradientFvPatchField<Type>& ptf,
00092     const DimensionedField<Type, volMesh>& iF
00093 )
00094 :
00095     fvPatchField<Type>(ptf, iF),
00096     gradient_(ptf.gradient_)
00097 {}
00098 
00099 
00100 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00101 
00102 template<class Type>
00103 void fixedGradientFvPatchField<Type>::autoMap
00104 (
00105     const fvPatchFieldMapper& m
00106 )
00107 {
00108     fvPatchField<Type>::autoMap(m);
00109     gradient_.autoMap(m);
00110 }
00111 
00112 
00113 template<class Type>
00114 void fixedGradientFvPatchField<Type>::rmap
00115 (
00116     const fvPatchField<Type>& ptf,
00117     const labelList& addr
00118 )
00119 {
00120     fvPatchField<Type>::rmap(ptf, addr);
00121 
00122     const fixedGradientFvPatchField<Type>& fgptf =
00123         refCast<const fixedGradientFvPatchField<Type> >(ptf);
00124 
00125     gradient_.rmap(fgptf.gradient_, addr);
00126 }
00127 
00128 
00129 template<class Type>
00130 void fixedGradientFvPatchField<Type>::evaluate(const Pstream::commsTypes)
00131 {
00132     if (!this->updated())
00133     {
00134         this->updateCoeffs();
00135     }
00136 
00137     Field<Type>::operator=
00138     (
00139         this->patchInternalField() + gradient_/this->patch().deltaCoeffs()
00140     );
00141 
00142     fvPatchField<Type>::evaluate();
00143 }
00144 
00145 
00146 template<class Type>
00147 tmp<Field<Type> > fixedGradientFvPatchField<Type>::valueInternalCoeffs
00148 (
00149     const tmp<scalarField>&
00150 ) const
00151 {
00152     return tmp<Field<Type> >(new Field<Type>(this->size(), pTraits<Type>::one));
00153 }
00154 
00155 
00156 template<class Type>
00157 tmp<Field<Type> > fixedGradientFvPatchField<Type>::valueBoundaryCoeffs
00158 (
00159     const tmp<scalarField>&
00160 ) const
00161 {
00162     return gradient()/this->patch().deltaCoeffs();
00163 }
00164 
00165 
00166 template<class Type>
00167 tmp<Field<Type> > fixedGradientFvPatchField<Type>::
00168 gradientInternalCoeffs() const
00169 {
00170     return tmp<Field<Type> >
00171     (
00172         new Field<Type>(this->size(), pTraits<Type>::zero)
00173     );
00174 }
00175 
00176 
00177 template<class Type>
00178 tmp<Field<Type> > fixedGradientFvPatchField<Type>::
00179 gradientBoundaryCoeffs() const
00180 {
00181     return gradient();
00182 }
00183 
00184 
00185 template<class Type>
00186 void fixedGradientFvPatchField<Type>::write(Ostream& os) const
00187 {
00188     fvPatchField<Type>::write(os);
00189     gradient_.writeEntry("gradient", os);
00190 }
00191 
00192 
00193 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00194 
00195 } // End namespace Foam
00196 
00197 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines