initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / finiteVolume / fields / fvPatchFields / derived / partialSlip / partialSlipFvPatchField.C
blobe39d0d33b6e1e07acca81dcc27da3af7f44bc81c
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 namespace Foam
35 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
37 template<class Type>
38 partialSlipFvPatchField<Type>::partialSlipFvPatchField
40     const fvPatch& p,
41     const DimensionedField<Type, volMesh>& iF
44     transformFvPatchField<Type>(p, iF),
45     valueFraction_(p.size(), 1.0)
49 template<class Type>
50 partialSlipFvPatchField<Type>::partialSlipFvPatchField
52     const partialSlipFvPatchField<Type>& ptf,
53     const fvPatch& p,
54     const DimensionedField<Type, volMesh>& iF,
55     const fvPatchFieldMapper& mapper
58     transformFvPatchField<Type>(ptf, p, iF, mapper),
59     valueFraction_(ptf.valueFraction_, mapper)
63 template<class Type>
64 partialSlipFvPatchField<Type>::partialSlipFvPatchField
66     const fvPatch& p,
67     const DimensionedField<Type, volMesh>& iF,
68     const dictionary& dict
71     transformFvPatchField<Type>(p, iF),
72     valueFraction_("valueFraction", dict, p.size())
74     evaluate();
78 template<class Type>
79 partialSlipFvPatchField<Type>::partialSlipFvPatchField
81     const partialSlipFvPatchField<Type>& ptf
84     transformFvPatchField<Type>(ptf),
85     valueFraction_(ptf.valueFraction_)
89 template<class Type>
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  * * * * * * * * * * * * * //
103 template<class Type>
104 void partialSlipFvPatchField<Type>::autoMap
106     const fvPatchFieldMapper& m
109     transformFvPatchField<Type>::autoMap(m);
110     valueFraction_.autoMap(m);
114 template<class Type>
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);
130 template<class Type>
131 tmp<Field<Type> > partialSlipFvPatchField<Type>::snGrad() const
133     vectorField nHat = this->patch().nf();
134     Field<Type> pif = this->patchInternalField();
136     return
137     (
138         (1.0 - valueFraction_)*transform(I - sqr(nHat), pif) - pif
139     )*this->patch().deltaCoeffs();
143 template<class Type>
144 void partialSlipFvPatchField<Type>::evaluate(const Pstream::commsTypes)
146     if (!this->updated())
147     {
148         this->updateCoeffs();
149     }
151     vectorField nHat = this->patch().nf();
153     Field<Type>::operator=
154     (
155         (1.0 - valueFraction_)
156        *transform(I - sqr(nHat), this->patchInternalField())
157     );
159     transformFvPatchField<Type>::evaluate();
163 template<class Type>
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)));
173     return 
174         valueFraction_*pTraits<Type>::one
175       + (1.0 - valueFraction_)
176        *transformFieldMask<Type>(pow<vector, pTraits<Type>::rank>(diag));
180 template<class Type>
181 void partialSlipFvPatchField<Type>::write(Ostream& os) const
183     transformFvPatchField<Type>::write(os);
184     valueFraction_.writeEntry("valueFraction", os);
188 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
190 } // End namespace Foam
192 // ************************************************************************* //