Merge branch 'master' of ssh://git.code.sf.net/p/foam-extend/foam-extend-3.2
[foam-extend-3.2.git] / src / finiteVolume / fields / fvPatchFields / derived / partialSlip / partialSlipFvPatchField.C
blob1d9cf489fba5655fc4004c239146bb61c0223ef8
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | foam-extend: Open Source CFD
4    \\    /   O peration     | Version:     3.2
5     \\  /    A nd           | Web:         http://www.foam-extend.org
6      \\/     M anipulation  | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
8 License
9     This file is part of foam-extend.
11     foam-extend 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 3 of the License, or (at your
14     option) any later version.
16     foam-extend is distributed in the hope that it will be useful, but
17     WITHOUT ANY WARRANTY; without even the implied warranty of
18     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19     General Public License for more details.
21     You should have received a copy of the GNU General Public License
22     along with foam-extend.  If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "partialSlipFvPatchField.H"
27 #include "symmTransformField.H"
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31 namespace Foam
34 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
36 template<class Type>
37 partialSlipFvPatchField<Type>::partialSlipFvPatchField
39     const fvPatch& p,
40     const DimensionedField<Type, volMesh>& iF
43     transformFvPatchField<Type>(p, iF),
44     valueFraction_(p.size(), 1.0)
48 template<class Type>
49 partialSlipFvPatchField<Type>::partialSlipFvPatchField
51     const partialSlipFvPatchField<Type>& ptf,
52     const fvPatch& p,
53     const DimensionedField<Type, volMesh>& iF,
54     const fvPatchFieldMapper& mapper
57     transformFvPatchField<Type>(ptf, p, iF, mapper),
58     valueFraction_(ptf.valueFraction_, mapper)
62 template<class Type>
63 partialSlipFvPatchField<Type>::partialSlipFvPatchField
65     const fvPatch& p,
66     const DimensionedField<Type, volMesh>& iF,
67     const dictionary& dict
70     transformFvPatchField<Type>(p, iF),
71     valueFraction_("valueFraction", dict, p.size())
73     evaluate();
77 template<class Type>
78 partialSlipFvPatchField<Type>::partialSlipFvPatchField
80     const partialSlipFvPatchField<Type>& ptf
83     transformFvPatchField<Type>(ptf),
84     valueFraction_(ptf.valueFraction_)
88 template<class Type>
89 partialSlipFvPatchField<Type>::partialSlipFvPatchField
91     const partialSlipFvPatchField<Type>& ptf,
92     const DimensionedField<Type, volMesh>& iF
95     transformFvPatchField<Type>(ptf, iF),
96     valueFraction_(ptf.valueFraction_)
100 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
102 template<class Type>
103 void partialSlipFvPatchField<Type>::autoMap
105     const fvPatchFieldMapper& m
108     transformFvPatchField<Type>::autoMap(m);
109     valueFraction_.autoMap(m);
113 template<class Type>
114 void partialSlipFvPatchField<Type>::rmap
116     const fvPatchField<Type>& ptf,
117     const labelList& addr
120     transformFvPatchField<Type>::rmap(ptf, addr);
122     const partialSlipFvPatchField<Type>& dmptf =
123         refCast<const partialSlipFvPatchField<Type> >(ptf);
125     valueFraction_.rmap(dmptf.valueFraction_, addr);
129 template<class Type>
130 tmp<Field<Type> > partialSlipFvPatchField<Type>::snGrad() const
132     vectorField nHat = this->patch().nf();
133     Field<Type> pif = this->patchInternalField();
135     return
136     (
137         (1.0 - valueFraction_)*transform(I - sqr(nHat), pif) - pif
138     )*this->patch().deltaCoeffs();
142 template<class Type>
143 void partialSlipFvPatchField<Type>::evaluate(const Pstream::commsTypes)
145     if (!this->updated())
146     {
147         this->updateCoeffs();
148     }
150     vectorField nHat = this->patch().nf();
152     Field<Type>::operator=
153     (
154         (1.0 - valueFraction_)
155        *transform(I - sqr(nHat), this->patchInternalField())
156     );
158     transformFvPatchField<Type>::evaluate();
162 template<class Type>
163 tmp<Field<Type> > partialSlipFvPatchField<Type>::snGradTransformDiag() const
165     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)));
172     return
173         valueFraction_*pTraits<Type>::one
174       + (1.0 - valueFraction_)
175        *transformFieldMask<Type>(pow<vector, pTraits<Type>::rank>(diag));
179 template<class Type>
180 void partialSlipFvPatchField<Type>::write(Ostream& os) const
182     transformFvPatchField<Type>::write(os);
183     valueFraction_.writeEntry("valueFraction", os);
187 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
189 } // End namespace Foam
191 // ************************************************************************* //