Forward compatibility: flex
[foam-extend-3.2.git] / applications / utilities / parallelProcessing / decomposePar / pointFieldDecomposer.C
blobbbe32e2237dbe47c8073b3fd3b9b02e3a018f56c
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | foam-extend: Open Source CFD
4    \\    /   O peration     | Version:     3.2
5     \\  /    A nd           | Web:         http://www.foam-extend.org
6      \\/     M anipulation  | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
8 License
9     This file is part of foam-extend.
11     foam-extend 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 3 of the License, or (at your
14     option) any later version.
16     foam-extend is distributed in the hope that it will be useful, but
17     WITHOUT ANY WARRANTY; without even the implied warranty of
18     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19     General Public License for more details.
21     You should have received a copy of the GNU General Public License
22     along with foam-extend.  If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "pointFieldDecomposer.H"
28 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
30 namespace Foam
33 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
35 pointFieldDecomposer::patchFieldDecomposer::patchFieldDecomposer
37     const pointPatch& completeMeshPatch,
38     const pointPatch& procMeshPatch,
39     const labelList& directAddr
42     PointPatchFieldMapperPatchRef<pointPatch>
43     (
44         completeMeshPatch,
45         procMeshPatch
46     ),
47     sizeBeforeMapping_(completeMeshPatch.size()),
48     directAddressing_(procMeshPatch.size(), -1)
50     // Create the inverse-addressing of the patch point labels.
51     labelList pointMap(completeMeshPatch.boundaryMesh().mesh().size(), -1);
53     const labelList& completeMeshPatchPoints = completeMeshPatch.meshPoints();
55     forAll (completeMeshPatchPoints, pointi)
56     {
57         pointMap[completeMeshPatchPoints[pointi]] = pointi;
58     }
60     // Use the inverse point addressing to create the addressing table for this
61     // patch
62     const labelList& procMeshPatchPoints = procMeshPatch.meshPoints();
64     forAll (procMeshPatchPoints, pointi)
65     {
66         directAddressing_[pointi] =
67             pointMap[directAddr[procMeshPatchPoints[pointi]]];
68     }
70     // Check that all the patch point addresses are set
71     if (directAddressing_.size() && min(directAddressing_) < 0)
72     {
73         FatalErrorIn
74         (
75             "pointFieldDecomposer::patchFieldDecomposer()"
76         )   << "Incomplete patch point addressing"
77             << abort(FatalError);
78     }
82 pointFieldDecomposer::pointFieldDecomposer
84     const pointMesh& completeMesh,
85     const pointMesh& procMesh,
86     const labelList& pointAddressing,
87     const labelList& boundaryAddressing
90     completeMesh_(completeMesh),
91     procMesh_(procMesh),
92     pointAddressing_(pointAddressing),
93     boundaryAddressing_(boundaryAddressing),
94     patchFieldDecomposerPtrs_
95     (
96         procMesh_.boundary().size(),
97         static_cast<patchFieldDecomposer*>(NULL)
98     )
100     forAll (boundaryAddressing_, patchi)
101     {
102         if (boundaryAddressing_[patchi] >= 0)
103         {
104             patchFieldDecomposerPtrs_[patchi] = new patchFieldDecomposer
105             (
106                 completeMesh_.boundary()[boundaryAddressing_[patchi]],
107                 procMesh_.boundary()[patchi],
108                 pointAddressing_
109             );
110         }
111     }
115 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
117 pointFieldDecomposer::~pointFieldDecomposer()
119     forAll (patchFieldDecomposerPtrs_, patchi)
120     {
121         if (patchFieldDecomposerPtrs_[patchi])
122         {
123             delete patchFieldDecomposerPtrs_[patchi];
124         }
125     }
129 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
131 } // End namespace Foam
133 // ************************************************************************* //