Initial commit for version 2.0.x patch release
[OpenFOAM-2.0.x.git] / applications / utilities / parallelProcessing / decomposePar / pointFieldDecomposer.C
blob4ab57ee8b739cfddbe5dc9178bc6ddf56fa156ea
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2004-2010 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
13     the Free Software Foundation, either version 3 of the License, or
14     (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "pointFieldDecomposer.H"
28 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
30 Foam::pointFieldDecomposer::patchFieldDecomposer::patchFieldDecomposer
32     const pointPatch& completeMeshPatch,
33     const pointPatch& procMeshPatch,
34     const labelList& directAddr
37     pointPatchFieldMapperPatchRef
38     (
39         completeMeshPatch,
40         procMeshPatch
41     ),
42     directAddressing_(procMeshPatch.size(), -1)
44     // Create the inverse-addressing of the patch point labels.
45     labelList pointMap(completeMeshPatch.boundaryMesh().mesh().size(), -1);
47     const labelList& completeMeshPatchPoints = completeMeshPatch.meshPoints();
49     forAll(completeMeshPatchPoints, pointi)
50     {
51         pointMap[completeMeshPatchPoints[pointi]] = pointi;
52     }
54     // Use the inverse point addressing to create the addressing table for this
55     // patch
56     const labelList& procMeshPatchPoints = procMeshPatch.meshPoints();
58     forAll(procMeshPatchPoints, pointi)
59     {
60         directAddressing_[pointi] =
61             pointMap[directAddr[procMeshPatchPoints[pointi]]];
62     }
64     // Check that all the patch point addresses are set
65     if (directAddressing_.size() && min(directAddressing_) < 0)
66     {
67         FatalErrorIn
68         (
69             "pointFieldDecomposer::patchFieldDecomposer()"
70         )   << "Incomplete patch point addressing"
71             << abort(FatalError);
72     }
76 Foam::pointFieldDecomposer::pointFieldDecomposer
78     const pointMesh& completeMesh,
79     const pointMesh& procMesh,
80     const labelList& pointAddressing,
81     const labelList& boundaryAddressing
84     completeMesh_(completeMesh),
85     procMesh_(procMesh),
86     pointAddressing_(pointAddressing),
87     boundaryAddressing_(boundaryAddressing),
88     patchFieldDecomposerPtrs_
89     (
90         procMesh_.boundary().size(),
91         static_cast<patchFieldDecomposer*>(NULL)
92     )
94     forAll(boundaryAddressing_, patchi)
95     {
96         if (boundaryAddressing_[patchi] >= 0)
97         {
98             patchFieldDecomposerPtrs_[patchi] = new patchFieldDecomposer
99             (
100                 completeMesh_.boundary()[boundaryAddressing_[patchi]],
101                 procMesh_.boundary()[patchi],
102                 pointAddressing_
103             );
104         }
105     }
109 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
111 Foam::pointFieldDecomposer::~pointFieldDecomposer()
113     forAll(patchFieldDecomposerPtrs_, patchi)
114     {
115         if (patchFieldDecomposerPtrs_[patchi])
116         {
117             delete patchFieldDecomposerPtrs_[patchi];
118         }
119     }
123 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
125 // ************************************************************************* //