initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / applications / solvers / compressible / rhoCentralFoam / BCs / mixedFixedValueSlip / mixedFixedValueSlipFvPatchField.C
bloba9df874e2450a2a78edbd3ca52c5dcdee6e99ef3
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 "mixedFixedValueSlipFvPatchField.H"
28 #include "symmTransformField.H"
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 namespace Foam
35 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
37 template<class Type>
38 mixedFixedValueSlipFvPatchField<Type>::mixedFixedValueSlipFvPatchField
40     const fvPatch& p,
41     const DimensionedField<Type, volMesh>& iF
44     transformFvPatchField<Type>(p, iF),
45     refValue_(p.size()),
46     valueFraction_(p.size(), 1.0)
50 template<class Type>
51 mixedFixedValueSlipFvPatchField<Type>::mixedFixedValueSlipFvPatchField
53     const mixedFixedValueSlipFvPatchField<Type>& ptf,
54     const fvPatch& p,
55     const DimensionedField<Type, volMesh>& iF,
56     const fvPatchFieldMapper& mapper
59     transformFvPatchField<Type>(ptf, p, iF, mapper),
60     refValue_(ptf.refValue_, mapper),
61     valueFraction_(ptf.valueFraction_, mapper)
65 template<class Type>
66 mixedFixedValueSlipFvPatchField<Type>::mixedFixedValueSlipFvPatchField
68     const fvPatch& p,
69     const DimensionedField<Type, volMesh>& iF,
70     const dictionary& dict
73     transformFvPatchField<Type>(p, iF),
74     refValue_("refValue", dict, p.size()),
75     valueFraction_("valueFraction", dict, p.size())
79 template<class Type>
80 mixedFixedValueSlipFvPatchField<Type>::mixedFixedValueSlipFvPatchField
82     const mixedFixedValueSlipFvPatchField<Type>& ptf
85     transformFvPatchField<Type>(ptf),
86     refValue_(ptf.refValue_),
87     valueFraction_(ptf.valueFraction_)
90 template<class Type>
91 mixedFixedValueSlipFvPatchField<Type>::mixedFixedValueSlipFvPatchField
93     const mixedFixedValueSlipFvPatchField<Type>& ptf,
94     const DimensionedField<Type, volMesh>& iF
97     transformFvPatchField<Type>(ptf, iF),
98     refValue_(ptf.refValue_),
99     valueFraction_(ptf.valueFraction_)
102 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
104 // Map from self
105 template<class Type>
106 void mixedFixedValueSlipFvPatchField<Type>::autoMap
108     const fvPatchFieldMapper& m
111     Field<Type>::autoMap(m);
112     refValue_.autoMap(m);
113     valueFraction_.autoMap(m);
117 // Reverse-map the given fvPatchField onto this fvPatchField
118 template<class Type>
119 void mixedFixedValueSlipFvPatchField<Type>::rmap
121     const fvPatchField<Type>& ptf,
122     const labelList& addr
125     transformFvPatchField<Type>::rmap(ptf, addr);
127     const mixedFixedValueSlipFvPatchField<Type>& dmptf =
128         refCast<const mixedFixedValueSlipFvPatchField<Type> >(ptf);
130     refValue_.rmap(dmptf.refValue_, addr);
131     valueFraction_.rmap(dmptf.valueFraction_, addr);
135 // Return gradient at boundary
136 template<class Type>
137 tmp<Field<Type> > mixedFixedValueSlipFvPatchField<Type>::snGrad() const
139     vectorField nHat = this->patch().nf();
140     Field<Type> pif = this->patchInternalField();
142     return
143     (
144         valueFraction_*refValue_
145       + (1.0 - valueFraction_)*transform(I - sqr(nHat), pif) - pif
146     )*this->patch().deltaCoeffs();
150 // Evaluate the field on the patch
151 template<class Type>
152 void mixedFixedValueSlipFvPatchField<Type>::evaluate(const Pstream::commsTypes)
154     if (!this->updated())
155     {
156         this->updateCoeffs();
157     }
159     vectorField nHat = this->patch().nf();
161     Field<Type>::operator=
162     (
163         valueFraction_*refValue_
164       +
165         (1.0 - valueFraction_)
166        *transform(I - nHat*nHat, this->patchInternalField())
167     );
169     transformFvPatchField<Type>::evaluate();
173 // Return defining fields
174 template<class Type>
175 tmp<Field<Type> > mixedFixedValueSlipFvPatchField<Type>::snGradTransformDiag() const
177     vectorField nHat = this->patch().nf();
178     vectorField diag(nHat.size());
180     diag.replace(vector::X, mag(nHat.component(vector::X)));
181     diag.replace(vector::Y, mag(nHat.component(vector::Y)));
182     diag.replace(vector::Z, mag(nHat.component(vector::Z)));
184     return
185         valueFraction_*Type(pTraits<Type>::one)
186       + (1.0 - valueFraction_)*transformFieldMask<Type>(pow<vector, pTraits<Type>::rank>(diag));
190 // Write
191 template<class Type>
192 void mixedFixedValueSlipFvPatchField<Type>::write(Ostream& os) const
194     transformFvPatchField<Type>::write(os);
195     refValue_.writeEntry("refValue", os);
196     valueFraction_.writeEntry("valueFraction", os);
200 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
202 } // End namespace Foam
204 // ************************************************************************* //