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

directionMixedFvPatchField.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenOAM: 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 "directionMixedFvPatchField.H"
00028 #include "symmTransformField.H"
00029 
00030 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00031 
00032 namespace Foam
00033 {
00034 
00035 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00036 
00037 template<class Type>
00038 directionMixedFvPatchField<Type>::directionMixedFvPatchField
00039 (
00040     const fvPatch& p,
00041     const DimensionedField<Type, volMesh>& iF
00042 )
00043 :
00044     transformFvPatchField<Type>(p, iF),
00045     refValue_(p.size()),
00046     refGrad_(p.size()),
00047     valueFraction_(p.size())
00048 {}
00049 
00050 
00051 template<class Type>
00052 directionMixedFvPatchField<Type>::directionMixedFvPatchField
00053 (
00054     const directionMixedFvPatchField<Type>& ptf,
00055     const fvPatch& p,
00056     const DimensionedField<Type, volMesh>& iF,
00057     const fvPatchFieldMapper& mapper
00058 )
00059 :
00060     transformFvPatchField<Type>(ptf, p, iF, mapper),
00061     refValue_(ptf.refValue_, mapper),
00062     refGrad_(ptf.refGrad_, mapper),
00063     valueFraction_(ptf.valueFraction_, mapper)
00064 {}
00065 
00066 
00067 template<class Type>
00068 directionMixedFvPatchField<Type>::directionMixedFvPatchField
00069 (
00070     const fvPatch& p,
00071     const DimensionedField<Type, volMesh>& iF,
00072     const dictionary& dict
00073 )
00074 :
00075     transformFvPatchField<Type>(p, iF, dict),
00076     refValue_("refValue", dict, p.size()),
00077     refGrad_("refGradient", dict, p.size()),
00078     valueFraction_("valueFraction", dict, p.size())
00079 {
00080     evaluate();
00081 }
00082 
00083 
00084 template<class Type>
00085 directionMixedFvPatchField<Type>::directionMixedFvPatchField
00086 (
00087     const directionMixedFvPatchField<Type>& ptf,
00088     const DimensionedField<Type, volMesh>& iF
00089 )
00090 :
00091     transformFvPatchField<Type>(ptf, iF),
00092     refValue_(ptf.refValue_),
00093     refGrad_(ptf.refGrad_),
00094     valueFraction_(ptf.valueFraction_)
00095 {}
00096 
00097 
00098 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00099 
00100 template<class Type>
00101 void directionMixedFvPatchField<Type>::autoMap
00102 (
00103     const fvPatchFieldMapper& m
00104 )
00105 {
00106     transformFvPatchField<Type>::autoMap(m);
00107     refValue_.autoMap(m);
00108     refGrad_.autoMap(m);
00109     valueFraction_.autoMap(m);
00110 }
00111 
00112 
00113 template<class Type>
00114 void directionMixedFvPatchField<Type>::rmap
00115 (
00116     const fvPatchField<Type>& ptf,
00117     const labelList& addr
00118 )
00119 {
00120     transformFvPatchField<Type>::rmap(ptf, addr);
00121 
00122     const directionMixedFvPatchField<Type>& dmptf =
00123         refCast<const directionMixedFvPatchField<Type> >(ptf);
00124 
00125     refValue_.rmap(dmptf.refValue_, addr);
00126     refGrad_.rmap(dmptf.refGrad_, addr);
00127     valueFraction_.rmap(dmptf.valueFraction_, addr);
00128 }
00129 
00130 
00131 template<class Type>
00132 tmp<Field<Type> > directionMixedFvPatchField<Type>::snGrad() const
00133 {
00134     Field<Type> pif = this->patchInternalField();
00135 
00136     Field<Type> normalValue = transform(valueFraction_, refValue_);
00137 
00138     Field<Type> gradValue = pif + refGrad_/this->patch().deltaCoeffs();
00139 
00140     Field<Type> transformGradValue =
00141         transform(I - valueFraction_, gradValue);
00142 
00143     return
00144         (normalValue + transformGradValue - pif)*
00145         this->patch().deltaCoeffs();
00146 }
00147 
00148 
00149 template<class Type>
00150 void directionMixedFvPatchField<Type>::evaluate(const Pstream::commsTypes)
00151 {
00152     if (!this->updated())
00153     {
00154         this->updateCoeffs();
00155     }
00156 
00157     Field<Type> normalValue = transform(valueFraction_, refValue_);
00158 
00159     Field<Type> gradValue =
00160         this->patchInternalField() + refGrad_/this->patch().deltaCoeffs();
00161 
00162     Field<Type> transformGradValue =
00163         transform(I - valueFraction_, gradValue);
00164 
00165     Field<Type>::operator=(normalValue + transformGradValue);
00166 
00167     transformFvPatchField<Type>::evaluate();
00168 }
00169 
00170 
00171 template<class Type>
00172 tmp<Field<Type> > directionMixedFvPatchField<Type>::snGradTransformDiag() const
00173 {
00174     vectorField diag(valueFraction_.size());
00175 
00176     diag.replace
00177     (
00178         vector::X,
00179         sqrt(mag(valueFraction_.component(symmTensor::XX)))
00180     );
00181     diag.replace
00182     (
00183         vector::Y,
00184         sqrt(mag(valueFraction_.component(symmTensor::YY)))
00185     );
00186     diag.replace
00187     (
00188         vector::Z,
00189         sqrt(mag(valueFraction_.component(symmTensor::ZZ)))
00190     );
00191 
00192     return transformFieldMask<Type>(pow<vector, pTraits<Type>::rank>(diag));
00193 }
00194 
00195 
00196 template<class Type>
00197 void directionMixedFvPatchField<Type>::write(Ostream& os) const
00198 {
00199     transformFvPatchField<Type>::write(os);
00200     refValue_.writeEntry("refValue", os);
00201     refGrad_.writeEntry("refGradient", os);
00202     valueFraction_.writeEntry("valueFraction", os);
00203     this->writeEntry("value", os);
00204 }
00205 
00206 
00207 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00208 
00209 } // End namespace Foam
00210 
00211 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd