1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 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 "globalPointPatchField.H"
28 #include "PstreamCombineReduceOps.H"
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
38 globalPointPatchField<Type>::globalPointPatchField
41 const DimensionedField<Type, pointMesh>& iF
44 coupledPointPatchField<Type>(p, iF),
45 globalPointPatch_(refCast<const globalPointPatch>(p))
50 globalPointPatchField<Type>::globalPointPatchField
53 const DimensionedField<Type, pointMesh>& iF,
54 const dictionary& dict
57 coupledPointPatchField<Type>(p, iF, dict),
58 globalPointPatch_(refCast<const globalPointPatch>(p))
60 if (!isType<globalPointPatch>(p))
64 "globalPointPatchField<Type>::globalPointPatchField\n"
66 " const pointPatch& p,\n"
67 " const Field<Type>& field,\n"
68 " const dictionary& dict\n"
71 ) << "patch " << this->patch().index()
72 << " not processorPoint type. "
73 << "Patch type = " << p.type()
74 << exit(FatalIOError);
80 globalPointPatchField<Type>::globalPointPatchField
82 const globalPointPatchField<Type>& ptf,
84 const DimensionedField<Type, pointMesh>& iF,
85 const pointPatchFieldMapper& mapper
88 coupledPointPatchField<Type>(ptf, p, iF, mapper),
89 globalPointPatch_(refCast<const globalPointPatch>(ptf.patch()))
91 if (!isType<globalPointPatch>(this->patch()))
95 "globalPointPatchField<Type>::globalPointPatchField\n"
97 " const globalPointPatchField<Type>& ptf,\n"
98 " const pointPatch& p,\n"
99 " const DimensionedField<Type, pointMesh>& iF,\n"
100 " const pointPatchFieldMapper& mapper\n"
102 ) << "Field type does not correspond to patch type for patch "
103 << this->patch().index() << "." << endl
104 << "Field type: " << typeName << endl
105 << "Patch type: " << this->patch().type()
112 globalPointPatchField<Type>::globalPointPatchField
114 const globalPointPatchField<Type>& ptf,
115 const DimensionedField<Type, pointMesh>& iF
118 coupledPointPatchField<Type>(ptf, iF),
119 globalPointPatch_(refCast<const globalPointPatch>(ptf.patch()))
123 // * * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
126 globalPointPatchField<Type>::~globalPointPatchField()
130 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
133 void globalPointPatchField<Type>::swapAdd(Field<Type>& pField) const
135 // Create the global list and insert local values
136 if (globalPointPatch_.globalPointSize() > 0)
138 Field<Type> lpf = patchInternalField(pField);
139 const labelList& addr = globalPointPatch_.sharedPointAddr();
143 globalPointPatch_.globalPointSize(),
149 gpf[addr[i]] += lpf[i];
152 combineReduce(gpf, plusEqOp<Field<Type> >());
154 // Extract local data
157 lpf[i] = gpf[addr[i]];
160 setInInternalField(pField, lpf);
165 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
167 } // End namespace Foam
169 // ************************************************************************* //