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

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