1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "partialSlipFvPatchField.H"
28 #include "symmTransformField.H"
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
38 partialSlipFvPatchField<Type>::partialSlipFvPatchField
41 const DimensionedField<Type, volMesh>& iF
44 transformFvPatchField<Type>(p, iF),
45 valueFraction_(p.size(), 1.0)
50 partialSlipFvPatchField<Type>::partialSlipFvPatchField
52 const partialSlipFvPatchField<Type>& ptf,
54 const DimensionedField<Type, volMesh>& iF,
55 const fvPatchFieldMapper& mapper
58 transformFvPatchField<Type>(ptf, p, iF, mapper),
59 valueFraction_(ptf.valueFraction_, mapper)
64 partialSlipFvPatchField<Type>::partialSlipFvPatchField
67 const DimensionedField<Type, volMesh>& iF,
68 const dictionary& dict
71 transformFvPatchField<Type>(p, iF),
72 valueFraction_("valueFraction", dict, p.size())
79 partialSlipFvPatchField<Type>::partialSlipFvPatchField
81 const partialSlipFvPatchField<Type>& ptf
84 transformFvPatchField<Type>(ptf),
85 valueFraction_(ptf.valueFraction_)
90 partialSlipFvPatchField<Type>::partialSlipFvPatchField
92 const partialSlipFvPatchField<Type>& ptf,
93 const DimensionedField<Type, volMesh>& iF
96 transformFvPatchField<Type>(ptf, iF),
97 valueFraction_(ptf.valueFraction_)
101 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
104 void partialSlipFvPatchField<Type>::autoMap
106 const fvPatchFieldMapper& m
109 transformFvPatchField<Type>::autoMap(m);
110 valueFraction_.autoMap(m);
115 void partialSlipFvPatchField<Type>::rmap
117 const fvPatchField<Type>& ptf,
118 const labelList& addr
121 transformFvPatchField<Type>::rmap(ptf, addr);
123 const partialSlipFvPatchField<Type>& dmptf =
124 refCast<const partialSlipFvPatchField<Type> >(ptf);
126 valueFraction_.rmap(dmptf.valueFraction_, addr);
131 tmp<Field<Type> > partialSlipFvPatchField<Type>::snGrad() const
133 vectorField nHat = this->patch().nf();
134 Field<Type> pif = this->patchInternalField();
138 (1.0 - valueFraction_)*transform(I - sqr(nHat), pif) - pif
139 )*this->patch().deltaCoeffs();
144 void partialSlipFvPatchField<Type>::evaluate(const Pstream::commsTypes)
146 if (!this->updated())
148 this->updateCoeffs();
151 vectorField nHat = this->patch().nf();
153 Field<Type>::operator=
155 (1.0 - valueFraction_)
156 *transform(I - sqr(nHat), this->patchInternalField())
159 transformFvPatchField<Type>::evaluate();
164 tmp<Field<Type> > partialSlipFvPatchField<Type>::snGradTransformDiag() const
166 vectorField nHat = this->patch().nf();
167 vectorField diag(nHat.size());
169 diag.replace(vector::X, mag(nHat.component(vector::X)));
170 diag.replace(vector::Y, mag(nHat.component(vector::Y)));
171 diag.replace(vector::Z, mag(nHat.component(vector::Z)));
174 valueFraction_*pTraits<Type>::one
175 + (1.0 - valueFraction_)
176 *transformFieldMask<Type>(pow<vector, pTraits<Type>::rank>(diag));
181 void partialSlipFvPatchField<Type>::write(Ostream& os) const
183 transformFvPatchField<Type>::write(os);
184 valueFraction_.writeEntry("valueFraction", os);
188 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
190 } // End namespace Foam
192 // ************************************************************************* //