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

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