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

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