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

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