initial commit for version 1.5.x patch release
[OpenFOAM-1.5.x.git] / src / OpenFOAM / fields / pointPatchFields / basic / mixed / mixedPointPatchField.C
blobcf4fbc6d003e698b3ab0fd08fa204e395397f813
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2008 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 "mixedPointPatchField.H"
28 #include "pointPatchFieldMapper.H"
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 namespace Foam
35 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
37 template<class Type>
38 void mixedPointPatchField<Type>::checkFieldSize() const
40     if
41     (
42         this->size() != this->patch().size()
43      || refValue_.size() != this->patch().size()
44      || valueFraction_.size() != this->patch().size()
45     )
46     {
47         FatalErrorIn
48         (
49             "void mixedPointPatchField<Type>::checkField() const"
50         )   << "field does not correspond to patch. " << endl
51             << "Field size: " << this->size() << " value size: "
52             << refValue_.size()
53             << " valueFraction size: " << valueFraction_.size()
54             << " patch size: " << this->patch().size()
55             << abort(FatalError);
56     }
60 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
62 template<class Type>
63 mixedPointPatchField<Type>::mixedPointPatchField
65     const pointPatch& p,
66     const DimensionedField<Type, pointMesh>& iF
69     valuePointPatchField<Type>(p, iF),
70     refValue_(p.size()),
71     valueFraction_(p.size())
75 template<class Type>
76 mixedPointPatchField<Type>::mixedPointPatchField
78     const pointPatch& p,
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())
89 template<class Type>
90 mixedPointPatchField<Type>::mixedPointPatchField
92     const mixedPointPatchField<Type>& ptf,
93     const pointPatch& p,
94     const DimensionedField<Type, pointMesh>& iF,
95     const pointPatchFieldMapper& mapper
98     valuePointPatchField<Type>
99     (
100         ptf,
101         p,
102         iF,
103         mapper
104     ),
105     refValue_(ptf.refValue_, mapper),
106     valueFraction_(ptf.valueFraction_, mapper)
111 template<class Type>
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
127 template<class Type>
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
140 template<class Type>
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
157 template<class Type>
158 void mixedPointPatchField<Type>::evaluate(const Pstream::commsTypes)
160     Field<Type>::operator=
161     (
162         valueFraction_*refValue_
163       + (1.0 - valueFraction_)*this->patchInternalField()
164     );
166     // Get internal field to insert values into
167     Field<Type>& iF = const_cast<Field<Type>&>(this->internalField());
169     setInInternalField(iF, *this);
173 // Write
174 template<class Type>
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 // ************************************************************************* //