Merge branch 'master' of ssh://git.code.sf.net/p/foam-extend/foam-extend-3.2
[foam-extend-3.2.git] / applications / utilities / parallelProcessing / reconstructPar / tetPointFieldReconstructor.C
blob668640cad562ceb3c6b0193de419f3b7b5be460a
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 "tetPointFieldReconstructor.H"
28 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
30 namespace Foam
33 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
35 // Calculate point addressing
36 labelList tetPointFieldReconstructor::procAddressing
38     const label procNo
39 ) const
41     // Allocate the addressing
42     labelList addr(procMeshes_[procNo].nPoints(), -1);
44     const labelList& pointAddr = pointProcAddressing_[procNo];
45     const labelList& cellAddr = cellProcAddressing_[procNo];
47     label nAddr = 0;
49     // Insert point addressing
51     // Use only live points.  HJ, 14/Apr/2009
52     for (label pointI = 0; pointI < procMeshes_[procNo]().nPoints(); pointI++)
53     {
54         addr[nAddr] = pointAddr[pointI];
55         nAddr++;
56     }
58     // Insert face addressing.  Only for face decomposition
59     const labelList& faceAddr = faceProcAddressing_[procNo];
61     const label faceOffset = mesh_.faceOffset();
63     // Use only live faces.  HJ, 14/Apr/2009
64     for (label faceI = 0; faceI < procMeshes_[procNo]().nFaces(); faceI++)
65     {
66         // Remember to decrement the index by one (turning index)
67         addr[nAddr] = faceOffset + mag(faceAddr[faceI]) - 1;
68         nAddr++;
69     }
71     // Insert cell addressing
72     const label cellOffset = mesh_.cellOffset();
74     forAll (cellAddr, cellI)
75     {
76         addr[nAddr] = cellOffset + cellAddr[cellI];
77         nAddr++;
78     }
80     return addr;
84 labelList tetPointFieldReconstructor::procPatchAddressing
86     const labelList& procToGlobalAddr,
87     const label procNo,
88     const label patchNo
89 ) const
91     labelList addr(procMeshes_[procNo].boundary()[patchNo].size(), -1);
93     // Algorithm:
94     // Go to the global patch, create a lookup list the size of all
95     // points in the mesh and then gather the points for the current
96     // patch.
97     labelList pointLookup(mesh_.nPoints(), -1);
99     const labelList& globalPatchPoints =
100         mesh_.boundary()[boundaryProcAddressing_[procNo][patchNo]].meshPoints();
102     forAll (globalPatchPoints, pointI)
103     {
104         pointLookup[globalPatchPoints[pointI]] = pointI;
105     }
107     // Gather the information
109     const labelList& procPatchPoints =
110         procMeshes_[procNo].boundary()[patchNo].meshPoints();
112     forAll (procPatchPoints, pointI)
113     {
114         addr[pointI] =
115             pointLookup[procToGlobalAddr[procPatchPoints[pointI]]];
116     }
118     if (addr.size() && min(addr) < 0)
119     {
120         FatalErrorIn
121         (
122             "labelList tetPointFieldReconstructor::"
123             "patchProcAddressing\n"
124             "(\n"
125             "    const labelList& procToGlobalAddr,\n"
126             "    const label procNo,\n"
127             "    const label patchNo\n"
128             ") const"
129         )   << "error in addressing"
130             << abort(FatalError);
131     }
133     return addr;
137 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
139 // Construct from components
140 tetPointFieldReconstructor::tetPointFieldReconstructor
142     tetPolyMesh& mesh,
143     const PtrList<tetPolyMesh>& procMeshes,
144     const PtrList<labelIOList>& pointProcAddressing,
145     const PtrList<labelIOList>& faceProcAddressing,
146     const PtrList<labelIOList>& cellProcAddressing,
147     const PtrList<labelIOList>& boundaryProcAddressing
150     mesh_(mesh),
151     procMeshes_(procMeshes),
152     pointProcAddressing_(pointProcAddressing),
153     faceProcAddressing_(faceProcAddressing),
154     cellProcAddressing_(cellProcAddressing),
155     boundaryProcAddressing_(boundaryProcAddressing)
159 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
161 } // End namespace Foam
163 // ************************************************************************* //