BUG: UListIO: byteSize overflowing on really big faceLists
[OpenFOAM-2.0.x.git] / applications / solvers / compressible / rhoCentralFoam / BCs / mixedFixedValueSlip / mixedFixedValueSlipFvPatchField.C
blob8f31a2b460b8cda1cd2eb670b91327b4fffa8e2f
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
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
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
19     for more details.
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 "mixedFixedValueSlipFvPatchField.H"
27 #include "symmTransformField.H"
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31 namespace Foam
34 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
36 template<class Type>
37 mixedFixedValueSlipFvPatchField<Type>::mixedFixedValueSlipFvPatchField
39     const fvPatch& p,
40     const DimensionedField<Type, volMesh>& iF
43     transformFvPatchField<Type>(p, iF),
44     refValue_(p.size()),
45     valueFraction_(p.size(), 1.0)
49 template<class Type>
50 mixedFixedValueSlipFvPatchField<Type>::mixedFixedValueSlipFvPatchField
52     const mixedFixedValueSlipFvPatchField<Type>& ptf,
53     const fvPatch& p,
54     const DimensionedField<Type, volMesh>& iF,
55     const fvPatchFieldMapper& mapper
58     transformFvPatchField<Type>(ptf, p, iF, mapper),
59     refValue_(ptf.refValue_, mapper),
60     valueFraction_(ptf.valueFraction_, mapper)
64 template<class Type>
65 mixedFixedValueSlipFvPatchField<Type>::mixedFixedValueSlipFvPatchField
67     const fvPatch& p,
68     const DimensionedField<Type, volMesh>& iF,
69     const dictionary& dict
72     transformFvPatchField<Type>(p, iF),
73     refValue_("refValue", dict, p.size()),
74     valueFraction_("valueFraction", dict, p.size())
78 template<class Type>
79 mixedFixedValueSlipFvPatchField<Type>::mixedFixedValueSlipFvPatchField
81     const mixedFixedValueSlipFvPatchField<Type>& ptf
84     transformFvPatchField<Type>(ptf),
85     refValue_(ptf.refValue_),
86     valueFraction_(ptf.valueFraction_)
89 template<class Type>
90 mixedFixedValueSlipFvPatchField<Type>::mixedFixedValueSlipFvPatchField
92     const mixedFixedValueSlipFvPatchField<Type>& ptf,
93     const DimensionedField<Type, volMesh>& iF
96     transformFvPatchField<Type>(ptf, iF),
97     refValue_(ptf.refValue_),
98     valueFraction_(ptf.valueFraction_)
101 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
103 // Map from self
104 template<class Type>
105 void mixedFixedValueSlipFvPatchField<Type>::autoMap
107     const fvPatchFieldMapper& m
110     Field<Type>::autoMap(m);
111     refValue_.autoMap(m);
112     valueFraction_.autoMap(m);
116 // Reverse-map the given fvPatchField onto this fvPatchField
117 template<class Type>
118 void mixedFixedValueSlipFvPatchField<Type>::rmap
120     const fvPatchField<Type>& ptf,
121     const labelList& addr
124     transformFvPatchField<Type>::rmap(ptf, addr);
126     const mixedFixedValueSlipFvPatchField<Type>& dmptf =
127         refCast<const mixedFixedValueSlipFvPatchField<Type> >(ptf);
129     refValue_.rmap(dmptf.refValue_, addr);
130     valueFraction_.rmap(dmptf.valueFraction_, addr);
134 // Return gradient at boundary
135 template<class Type>
136 tmp<Field<Type> > mixedFixedValueSlipFvPatchField<Type>::snGrad() const
138     tmp<vectorField> nHat = this->patch().nf();
139     Field<Type> pif(this->patchInternalField());
141     return
142     (
143         valueFraction_*refValue_
144       + (1.0 - valueFraction_)*transform(I - sqr(nHat), pif) - pif
145     )*this->patch().deltaCoeffs();
149 // Evaluate the field on the patch
150 template<class Type>
151 void mixedFixedValueSlipFvPatchField<Type>::evaluate(const Pstream::commsTypes)
153     if (!this->updated())
154     {
155         this->updateCoeffs();
156     }
158     vectorField nHat(this->patch().nf());
160     Field<Type>::operator=
161     (
162         valueFraction_*refValue_
163       +
164         (1.0 - valueFraction_)
165        *transform(I - nHat*nHat, this->patchInternalField())
166     );
168     transformFvPatchField<Type>::evaluate();
172 // Return defining fields
173 template<class Type>
174 tmp<Field<Type> >
175 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_)
187        *transformFieldMask<Type>(pow<vector, pTraits<Type>::rank>(diag));
191 // Write
192 template<class Type>
193 void mixedFixedValueSlipFvPatchField<Type>::write(Ostream& os) const
195     transformFvPatchField<Type>::write(os);
196     refValue_.writeEntry("refValue", os);
197     valueFraction_.writeEntry("valueFraction", os);
201 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
203 } // End namespace Foam
205 // ************************************************************************* //