1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
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
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 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
36 pointFieldDecomposer::patchFieldDecomposer::patchFieldDecomposer
38 const pointPatch& completeMeshPatch,
39 const pointPatch& procMeshPatch,
40 const labelList& directAddr
43 PointPatchFieldMapperPatchRef<pointPatch>
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)
58 pointMap[completeMeshPatchPoints[pointi]] = pointi;
61 // Use the inverse point addressing to create the addressing table for this
63 const labelList& procMeshPatchPoints = procMeshPatch.meshPoints();
65 forAll (procMeshPatchPoints, pointi)
67 directAddressing_[pointi] =
68 pointMap[directAddr[procMeshPatchPoints[pointi]]];
71 // Check that all the patch point addresses are set
72 if (directAddressing_.size() && min(directAddressing_) < 0)
76 "pointFieldDecomposer::patchFieldDecomposer()"
77 ) << "Incomplete patch point addressing"
83 pointFieldDecomposer::pointFieldDecomposer
85 const pointMesh& completeMesh,
86 const pointMesh& procMesh,
87 const labelList& pointAddressing,
88 const labelList& boundaryAddressing
91 completeMesh_(completeMesh),
93 pointAddressing_(pointAddressing),
94 boundaryAddressing_(boundaryAddressing),
95 patchFieldDecomposerPtrs_
97 procMesh_.boundary().size(),
98 static_cast<patchFieldDecomposer*>(NULL)
101 forAll (boundaryAddressing_, patchi)
103 if (boundaryAddressing_[patchi] >= 0)
105 patchFieldDecomposerPtrs_[patchi] = new patchFieldDecomposer
107 completeMesh_.boundary()[boundaryAddressing_[patchi]],
108 procMesh_.boundary()[patchi],
116 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
118 pointFieldDecomposer::~pointFieldDecomposer()
120 forAll (patchFieldDecomposerPtrs_, patchi)
122 if (patchFieldDecomposerPtrs_[patchi])
124 delete patchFieldDecomposerPtrs_[patchi];
130 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
132 } // End namespace Foam
134 // ************************************************************************* //