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 "mixedFixedValueSlipFvPatchField.H"
28 #include "symmTransformField.H"
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
38 mixedFixedValueSlipFvPatchField<Type>::mixedFixedValueSlipFvPatchField
41 const DimensionedField<Type, volMesh>& iF
44 transformFvPatchField<Type>(p, iF),
45 refValue_(p.size(), pTraits<Type>::zero),
46 valueFraction_(p.size(), 1.0)
51 mixedFixedValueSlipFvPatchField<Type>::mixedFixedValueSlipFvPatchField
53 const mixedFixedValueSlipFvPatchField<Type>& ptf,
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)
66 mixedFixedValueSlipFvPatchField<Type>::mixedFixedValueSlipFvPatchField
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())
80 mixedFixedValueSlipFvPatchField<Type>::mixedFixedValueSlipFvPatchField
82 const mixedFixedValueSlipFvPatchField<Type>& ptf
85 transformFvPatchField<Type>(ptf),
86 refValue_(ptf.refValue_),
87 valueFraction_(ptf.valueFraction_)
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 * * * * * * * * * * * * * //
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
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
137 tmp<Field<Type> > mixedFixedValueSlipFvPatchField<Type>::snGrad() const
139 vectorField nHat = this->patch().nf();
140 Field<Type> pif = this->patchInternalField();
144 valueFraction_*refValue_
145 + (1.0 - valueFraction_)*transform(I - sqr(nHat), pif) - pif
146 )*this->patch().deltaCoeffs();
150 // Evaluate the field on the patch
152 void mixedFixedValueSlipFvPatchField<Type>::evaluate(const Pstream::commsTypes)
154 if (!this->updated())
156 this->updateCoeffs();
159 vectorField nHat = this->patch().nf();
161 Field<Type>::operator=
163 valueFraction_*refValue_
165 (1.0 - valueFraction_)
166 *transform(I - nHat*nHat, this->patchInternalField())
169 transformFvPatchField<Type>::evaluate();
173 // Return defining fields
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)));
185 valueFraction_*Type(pTraits<Type>::one)
186 + (1.0 - valueFraction_)*transformFieldMask<Type>(pow<vector, pTraits<Type>::rank>(diag));
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 // ************************************************************************* //