1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "partialSlipFvPatchField.H"
27 #include "symmTransformField.H"
29 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32 Foam::partialSlipFvPatchField<Type>::partialSlipFvPatchField
35 const DimensionedField<Type, volMesh>& iF
38 transformFvPatchField<Type>(p, iF),
39 valueFraction_(p.size(), 1.0)
44 Foam::partialSlipFvPatchField<Type>::partialSlipFvPatchField
46 const partialSlipFvPatchField<Type>& ptf,
48 const DimensionedField<Type, volMesh>& iF,
49 const fvPatchFieldMapper& mapper
52 transformFvPatchField<Type>(ptf, p, iF, mapper),
53 valueFraction_(ptf.valueFraction_, mapper)
58 Foam::partialSlipFvPatchField<Type>::partialSlipFvPatchField
61 const DimensionedField<Type, volMesh>& iF,
62 const dictionary& dict
65 transformFvPatchField<Type>(p, iF),
66 valueFraction_("valueFraction", dict, p.size())
73 Foam::partialSlipFvPatchField<Type>::partialSlipFvPatchField
75 const partialSlipFvPatchField<Type>& ptf
78 transformFvPatchField<Type>(ptf),
79 valueFraction_(ptf.valueFraction_)
84 Foam::partialSlipFvPatchField<Type>::partialSlipFvPatchField
86 const partialSlipFvPatchField<Type>& ptf,
87 const DimensionedField<Type, volMesh>& iF
90 transformFvPatchField<Type>(ptf, iF),
91 valueFraction_(ptf.valueFraction_)
95 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
98 void Foam::partialSlipFvPatchField<Type>::autoMap
100 const fvPatchFieldMapper& m
103 transformFvPatchField<Type>::autoMap(m);
104 valueFraction_.autoMap(m);
109 void Foam::partialSlipFvPatchField<Type>::rmap
111 const fvPatchField<Type>& ptf,
112 const labelList& addr
115 transformFvPatchField<Type>::rmap(ptf, addr);
117 const partialSlipFvPatchField<Type>& dmptf =
118 refCast<const partialSlipFvPatchField<Type> >(ptf);
120 valueFraction_.rmap(dmptf.valueFraction_, addr);
125 Foam::tmp<Foam::Field<Type> >
126 Foam::partialSlipFvPatchField<Type>::snGrad() const
128 tmp<vectorField> nHat = this->patch().nf();
129 const Field<Type> pif(this->patchInternalField());
133 (1.0 - valueFraction_)*transform(I - sqr(nHat), pif) - pif
134 )*this->patch().deltaCoeffs();
139 void Foam::partialSlipFvPatchField<Type>::evaluate
141 const Pstream::commsTypes
144 if (!this->updated())
146 this->updateCoeffs();
149 tmp<vectorField> nHat = this->patch().nf();
151 Field<Type>::operator=
153 (1.0 - valueFraction_)
154 *transform(I - sqr(nHat), this->patchInternalField())
157 transformFvPatchField<Type>::evaluate();
162 Foam::tmp<Foam::Field<Type> >
163 Foam::partialSlipFvPatchField<Type>::snGradTransformDiag() const
165 const vectorField nHat(this->patch().nf());
166 vectorField diag(nHat.size());
168 diag.replace(vector::X, mag(nHat.component(vector::X)));
169 diag.replace(vector::Y, mag(nHat.component(vector::Y)));
170 diag.replace(vector::Z, mag(nHat.component(vector::Z)));
173 valueFraction_*pTraits<Type>::one
174 + (1.0 - valueFraction_)
175 *transformFieldMask<Type>(pow<vector, pTraits<Type>::rank>(diag));
180 void Foam::partialSlipFvPatchField<Type>::write(Ostream& os) const
182 transformFvPatchField<Type>::write(os);
183 valueFraction_.writeEntry("valueFraction", os);
187 // ************************************************************************* //