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

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