1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
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 "mixedPointPatchField.H"
28 #include "pointPatchFieldMapper.H"
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
38 void mixedPointPatchField<Type>::checkFieldSize() const
42 this->size() != this->patch().size()
43 || refValue_.size() != this->patch().size()
44 || valueFraction_.size() != this->patch().size()
49 "void mixedPointPatchField<Type>::checkField() const"
50 ) << "field does not correspond to patch. " << endl
51 << "Field size: " << this->size() << " value size: "
53 << " valueFraction size: " << valueFraction_.size()
54 << " patch size: " << this->patch().size()
60 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
63 mixedPointPatchField<Type>::mixedPointPatchField
66 const DimensionedField<Type, pointMesh>& iF
69 valuePointPatchField<Type>(p, iF),
71 valueFraction_(p.size())
76 mixedPointPatchField<Type>::mixedPointPatchField
79 const DimensionedField<Type, pointMesh>& iF,
80 const dictionary& dict
83 valuePointPatchField<Type>(p, iF, dict, false),
84 refValue_("refValue", dict, p.size()),
85 valueFraction_("valueFraction", dict, p.size())
90 mixedPointPatchField<Type>::mixedPointPatchField
92 const mixedPointPatchField<Type>& ptf,
94 const DimensionedField<Type, pointMesh>& iF,
95 const pointPatchFieldMapper& mapper
98 valuePointPatchField<Type>
105 refValue_(ptf.refValue_, mapper),
106 valueFraction_(ptf.valueFraction_, mapper)
112 mixedPointPatchField<Type>::mixedPointPatchField
114 const mixedPointPatchField<Type>& ptf,
115 const DimensionedField<Type, pointMesh>& iF
118 valuePointPatchField<Type>(ptf, iF),
119 refValue_(ptf.refValue_),
120 valueFraction_(ptf.valueFraction_)
124 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
126 // Map and resize from self given a mapper
128 void mixedPointPatchField<Type>::autoMap
130 const pointPatchFieldMapper& m
133 Field<Type>::autoMap(m);
134 refValue_.autoMap(m);
135 valueFraction_.autoMap(m);
139 // Grab the values using rmap
141 void mixedPointPatchField<Type>::rmap
143 const pointPatchField<Type>& ptf,
144 const labelList& addr
147 const mixedPointPatchField<Type>& mptf =
148 refCast<const mixedPointPatchField<Type> >(ptf);
150 Field<Type>::rmap(mptf, addr);
151 refValue_.rmap(mptf.refValue_, addr);
152 valueFraction_.rmap(mptf.valueFraction_, addr);
156 // Evaluate patch field
158 void mixedPointPatchField<Type>::evaluate(const Pstream::commsTypes)
160 Field<Type>::operator=
162 valueFraction_*refValue_
163 + (1.0 - valueFraction_)*this->patchInternalField()
166 // Get internal field to insert values into
167 Field<Type>& iF = const_cast<Field<Type>&>(this->internalField());
169 setInInternalField(iF, *this);
175 void mixedPointPatchField<Type>::write(Ostream& os) const
177 pointPatchField<Type>::write(os);
178 refValue_.writeEntry("refValue", os);
179 valueFraction_.writeEntry("valueFraction", os);
183 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
185 } // End namespace Foam
187 // ************************************************************************* //