BUGFIX: Uninitialised member variables
[foam-extend-3.2.git] / applications / utilities / parallelProcessing / decomposePar / pointFieldDecomposer.C
blobe66328460bedfce4febbc5abf8df4a94ce266c76
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright held by original author
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 "pointFieldDecomposer.H"
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31 namespace Foam
34 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
36 pointFieldDecomposer::patchFieldDecomposer::patchFieldDecomposer
38     const pointPatch& completeMeshPatch,
39     const pointPatch& procMeshPatch,
40     const labelList& directAddr
43     PointPatchFieldMapperPatchRef<pointPatch>
44     (
45         completeMeshPatch,
46         procMeshPatch
47     ),
48     sizeBeforeMapping_(completeMeshPatch.size()),
49     directAddressing_(procMeshPatch.size(), -1)
51     // Create the inverse-addressing of the patch point labels.
52     labelList pointMap(completeMeshPatch.boundaryMesh().mesh().size(), -1);
54     const labelList& completeMeshPatchPoints = completeMeshPatch.meshPoints();
56     forAll (completeMeshPatchPoints, pointi)
57     {
58         pointMap[completeMeshPatchPoints[pointi]] = pointi;
59     }
61     // Use the inverse point addressing to create the addressing table for this
62     // patch
63     const labelList& procMeshPatchPoints = procMeshPatch.meshPoints();
65     forAll (procMeshPatchPoints, pointi)
66     {
67         directAddressing_[pointi] =
68             pointMap[directAddr[procMeshPatchPoints[pointi]]];
69     }
71     // Check that all the patch point addresses are set
72     if (directAddressing_.size() && min(directAddressing_) < 0)
73     {
74         FatalErrorIn
75         (
76             "pointFieldDecomposer::patchFieldDecomposer()"
77         )   << "Incomplete patch point addressing"
78             << abort(FatalError);
79     }
83 pointFieldDecomposer::pointFieldDecomposer
85     const pointMesh& completeMesh,
86     const pointMesh& procMesh,
87     const labelList& pointAddressing,
88     const labelList& boundaryAddressing
91     completeMesh_(completeMesh),
92     procMesh_(procMesh),
93     pointAddressing_(pointAddressing),
94     boundaryAddressing_(boundaryAddressing),
95     patchFieldDecomposerPtrs_
96     (
97         procMesh_.boundary().size(),
98         static_cast<patchFieldDecomposer*>(NULL)
99     )
101     forAll (boundaryAddressing_, patchi)
102     {
103         if (boundaryAddressing_[patchi] >= 0)
104         {
105             patchFieldDecomposerPtrs_[patchi] = new patchFieldDecomposer
106             (
107                 completeMesh_.boundary()[boundaryAddressing_[patchi]],
108                 procMesh_.boundary()[patchi],
109                 pointAddressing_
110             );
111         }
112     }
116 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
118 pointFieldDecomposer::~pointFieldDecomposer()
120     forAll (patchFieldDecomposerPtrs_, patchi)
121     {
122         if (patchFieldDecomposerPtrs_[patchi])
123         {
124             delete patchFieldDecomposerPtrs_[patchi];
125         }
126     }
130 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
132 } // End namespace Foam
134 // ************************************************************************* //