initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / OpenFOAM / fields / pointPatchFields / constraint / processor / processorPointPatchField.C
blobc5b8c8334d1fdda7847c8569cb25c5b020b422f2
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 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 "processorPointPatchField.H"
28 #include "transformField.H"
29 #include "processorPolyPatch.H"
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 namespace Foam
36 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
38 template<class Type>
39 processorPointPatchField<Type>::processorPointPatchField
41     const pointPatch& p,
42     const DimensionedField<Type, pointMesh>& iF
45     coupledPointPatchField<Type>(p, iF),
46     procPatch_(refCast<const processorPointPatch>(p))
50 template<class Type>
51 processorPointPatchField<Type>::processorPointPatchField
53     const pointPatch& p,
54     const DimensionedField<Type, pointMesh>& iF,
55     const dictionary& dict
58     coupledPointPatchField<Type>(p, iF, dict),
59     procPatch_(refCast<const processorPointPatch>(p))
63 template<class Type>
64 processorPointPatchField<Type>::processorPointPatchField
66     const processorPointPatchField<Type>& ptf,
67     const pointPatch& p,
68     const DimensionedField<Type, pointMesh>& iF,
69     const pointPatchFieldMapper& mapper
72     coupledPointPatchField<Type>(ptf, p, iF, mapper),
73     procPatch_(refCast<const processorPointPatch>(ptf.patch()))
77 template<class Type>
78 processorPointPatchField<Type>::processorPointPatchField
80     const processorPointPatchField<Type>& ptf,
81     const DimensionedField<Type, pointMesh>& iF
84     coupledPointPatchField<Type>(ptf, iF),
85     procPatch_(refCast<const processorPointPatch>(ptf.patch()))
89 // * * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * //
91 template<class Type>
92 processorPointPatchField<Type>::~processorPointPatchField()
96 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
98 template<class Type>
99 void processorPointPatchField<Type>::initSwapAdd(Field<Type>& pField) const
101     if (Pstream::parRun())
102     {
103         // Get internal field into my point order
104         Field<Type> pf(this->patchInternalField(pField));
106         OPstream::write
107         (
108             Pstream::blocking,
109             procPatch_.neighbProcNo(),
110             reinterpret_cast<const char*>(pf.begin()),
111             pf.byteSize()
112         );
113     }
117 template<class Type>
118 void processorPointPatchField<Type>::swapAdd(Field<Type>& pField) const
120     if (Pstream::parRun())
121     {
122         Field<Type> pnf(this->size());
124         IPstream::read
125         (
126             Pstream::blocking,
127             procPatch_.neighbProcNo(),
128             reinterpret_cast<char*>(pnf.begin()),
129             pnf.byteSize()
130         );
132         if (doTransform())
133         {
134             const processorPolyPatch& ppp = procPatch_.procPolyPatch();
135             const tensorField& forwardT = ppp.forwardT();
137             if (forwardT.size() == 1)
138             {
139                 transform(pnf, forwardT[0], pnf);
140             }
141             else
142             {
143                 const labelList& nonGlobalPatchPoints =
144                     procPatch_.nonGlobalPatchPoints();
145                 const labelListList& pointFaces = ppp.pointFaces();
147                 forAll(nonGlobalPatchPoints, pfi)
148                 {
149                     pnf[pfi] = transform
150                     (
151                         forwardT[pointFaces[nonGlobalPatchPoints[pfi]][0]],
152                         pnf[pfi]
153                     );
154                 }
155             }
156         }
158         addToInternalField(pField, pnf);
159     }
163 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
165 } // End namespace Foam
167 // ************************************************************************* //