initial commit for version 1.5.x patch release
[OpenFOAM-1.5.x.git] / applications / utilities / parallelProcessing / decomposePar / pointFieldDecomposer.C
blob60985f18320dd21f4163f843a4eff7ab8579d506
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2008 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 "pointFieldDecomposer.H"
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31 namespace Foam
34 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
35     
36 pointFieldDecomposer::patchFieldDecomposer::patchFieldDecomposer
38     const pointPatch& completeMeshPatch,
39     const pointPatch& procMeshPatch,
40     const labelList& directAddr
43     pointPatchFieldMapperPatchRef
44     (
45         completeMeshPatch,
46         procMeshPatch
47     ),
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 // ************************************************************************* //