BUG: UListIO: byteSize overflowing on really big faceLists
[OpenFOAM-2.0.x.git] / applications / test / globalMeshData / Test-globalMeshData.C
blob9e47d0e7e370efac2d2b1cbe1f547a53b387277e
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
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 Application
25     globalMeshDataTest
27 Description
28     Test global point communication
30 \*---------------------------------------------------------------------------*/
32 #include "globalMeshData.H"
33 #include "argList.H"
34 #include "polyMesh.H"
35 #include "Time.H"
36 #include "mapDistribute.H"
38 using namespace Foam;
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 // Main program:
45 int main(int argc, char *argv[])
47 #   include "setRootCase.H"
48 #   include "createTime.H"
49 #   include "createPolyMesh.H"
51     const globalMeshData& globalData = mesh.globalData();
52     const indirectPrimitivePatch& coupledPatch = globalData.coupledPatch();
53     const globalIndexAndTransform& transforms = globalData.globalTransforms();
56     // Test:print shared points
57     {
58         const mapDistribute& globalPointSlavesMap =
59             globalData.globalPointSlavesMap();
60         const labelListList& slaves =
61             globalData.globalPointSlaves();
62         const labelListList& transformedSlaves =
63             globalData.globalPointTransformedSlaves();
65         // Create field with my local data
66         pointField coords(globalPointSlavesMap.constructSize());
67         SubList<point>(coords, coupledPatch.nPoints()).assign
68         (
69             coupledPatch.localPoints()
70         );
72         // Exchange data. Apply positional transforms.
73         globalPointSlavesMap.distribute
74         (
75             transforms,
76             coords,
77             mapDistribute::transformPosition()
78         );
80         // Print
81         forAll(slaves, pointI)
82         {
83             const labelList& slavePoints = slaves[pointI];
85             if (slavePoints.size() > 0)
86             {
87                 Pout<< "Master point:" << pointI
88                     << " coord:" << coords[pointI]
89                     << " connected to untransformed slave points:" << endl;
91                 forAll(slavePoints, i)
92                 {
93                     Pout<< "    " << coords[slavePoints[i]] << endl;
94                 }
95             }
97             const labelList& transformedSlavePoints = transformedSlaves[pointI];
99             if (transformedSlavePoints.size() > 0)
100             {
101                 Pout<< "Master point:" << pointI
102                     << " coord:" << coords[pointI]
103                     << " connected to transformed slave points:" << endl;
105                 forAll(transformedSlavePoints, i)
106                 {
107                     Pout<< "    " << coords[transformedSlavePoints[i]]
108                         << endl;
109                 }
110             }
111         }
112     }
115     // Test:print shared edges
116     {
117         const mapDistribute& globalEdgeSlavesMap =
118             globalData.globalEdgeSlavesMap();
119         const labelListList& slaves =
120             globalData.globalEdgeSlaves();
121         const labelListList& transformedSlaves =
122             globalData.globalEdgeTransformedSlaves();
124         // Test: distribute edge centres
125         pointField ec(globalEdgeSlavesMap.constructSize());
126         forAll(coupledPatch.edges(), edgeI)
127         {
128             ec[edgeI] = coupledPatch.edges()[edgeI].centre
129             (
130                 coupledPatch.localPoints()
131             );
132         }
134         // Exchange data Apply positional transforms.
135         globalEdgeSlavesMap.distribute
136         (
137             transforms,
138             ec,
139             mapDistribute::transformPosition()
140         );
142         // Print
143         forAll(slaves, edgeI)
144         {
145             const labelList& slaveEdges = slaves[edgeI];
147             if (slaveEdges.size() > 0)
148             {
149                 Pout<< "Master edge:" << edgeI
150                     << " centre:" << ec[edgeI]
151                     << " connected to slave edges:" << endl;
153                 forAll(slaveEdges, i)
154                 {
155                     Pout<< "    " << ec[slaveEdges[i]] << endl;
156                 }
157             }
158             const labelList& transformedSlaveEdges = transformedSlaves[edgeI];
160             if (transformedSlaveEdges.size() > 0)
161             {
162                 Pout<< "Master edge:" << edgeI
163                     << " centre:" << ec[edgeI]
164                     << " connected to transformed slave edges:" << endl;
166                 forAll(transformedSlaveEdges, i)
167                 {
168                     Pout<< "    " << ec[transformedSlaveEdges[i]]
169                         << endl;
170                 }
171             }
172         }
173     }
176     // Test: point to faces addressing
177     {
178         const mapDistribute& globalPointBoundaryFacesMap =
179             globalData.globalPointBoundaryFacesMap();
180         const labelListList& slaves =
181             globalData.globalPointBoundaryFaces();
182         const labelListList& transformedSlaves =
183             globalData.globalPointTransformedBoundaryFaces();
185         label nBnd = mesh.nFaces()-mesh.nInternalFaces();
187         pointField fc(globalPointBoundaryFacesMap.constructSize());
188         SubList<point>(fc, nBnd).assign
189         (
190             primitivePatch
191             (
192                 SubList<face>
193                 (
194                     mesh.faces(),
195                     nBnd,
196                     mesh.nInternalFaces()
197                 ),
198                 mesh.points()
199             ).faceCentres()
200         );
202         // Exchange data
203         globalPointBoundaryFacesMap.distribute
204         (
205             transforms,
206             fc,
207             mapDistribute::transformPosition()
208         );
210         // Print
211         forAll(slaves, pointI)
212         {
213             const labelList& slaveFaces = slaves[pointI];
215             if (slaveFaces.size() > 0)
216             {
217                 Pout<< "Master point:" << pointI
218                     << " at:" << coupledPatch.localPoints()[pointI]
219                     << " connected to " << slaveFaces.size()
220                     << " untransformed faces:" << endl;
222                 forAll(slaveFaces, i)
223                 {
224                     Pout<< "    " << fc[slaveFaces[i]] << endl;
225                 }
226             }
228             const labelList& transformedSlaveFaces = transformedSlaves[pointI];
230             if (transformedSlaveFaces.size() > 0)
231             {
232                 Pout<< "Master point:" << pointI
233                     << " connected to " << transformedSlaveFaces.size()
234                     << " transformed faces:" << endl;
236                 forAll(transformedSlaveFaces, i)
237                 {
238                     Pout<< "    " << fc[transformedSlaveFaces[i]] << endl;
239                 }
240             }
241         }
242     }
245     // Test: point to cells addressing
246     {
247         const labelList& boundaryCells = globalData.boundaryCells();
248         const mapDistribute& globalPointBoundaryCellsMap =
249             globalData.globalPointBoundaryCellsMap();
250         const labelListList& slaves = globalData.globalPointBoundaryCells();
251         const labelListList& transformedSlaves =
252             globalData.globalPointTransformedBoundaryCells();
254         pointField cc(globalPointBoundaryCellsMap.constructSize());
255         forAll(boundaryCells, i)
256         {
257             cc[i] = mesh.cellCentres()[boundaryCells[i]];
258         }
260         // Exchange data
261         globalPointBoundaryCellsMap.distribute
262         (
263             transforms,
264             cc,
265             mapDistribute::transformPosition()
266         );
268         // Print
269         forAll(slaves, pointI)
270         {
271             const labelList& pointCells = slaves[pointI];
273             if (pointCells.size() > 0)
274             {
275                 Pout<< "Master point:" << pointI
276                     << " at:" << coupledPatch.localPoints()[pointI]
277                     << " connected to " << pointCells.size()
278                     << " untransformed boundaryCells:" << endl;
280                 forAll(pointCells, i)
281                 {
282                     Pout<< "    " << cc[pointCells[i]] << endl;
283                 }
284             }
286             const labelList& transformPointCells = transformedSlaves[pointI];
288             if (transformPointCells.size() > 0)
289             {
290                 Pout<< "Master point:" << pointI
291                     << " connected to " << transformPointCells.size()
292                     << " transformed boundaryCells:" << endl;
294                 forAll(transformPointCells, i)
295                 {
296                     Pout<< "    " << cc[transformPointCells[i]] << endl;
297                 }
298             }
299         }
300     }
303     Info<< "End\n" << endl;
305     return 0;
309 // ************************************************************************* //