1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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
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
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/>.
28 Test global point communication
30 \*---------------------------------------------------------------------------*/
32 #include "globalMeshData.H"
36 #include "mapDistribute.H"
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
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
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
69 coupledPatch.localPoints()
72 // Exchange data. Apply positional transforms.
73 globalPointSlavesMap.distribute
77 mapDistribute::transformPosition()
81 forAll(slaves, pointI)
83 const labelList& slavePoints = slaves[pointI];
85 if (slavePoints.size() > 0)
87 Pout<< "Master point:" << pointI
88 << " coord:" << coords[pointI]
89 << " connected to untransformed slave points:" << endl;
91 forAll(slavePoints, i)
93 Pout<< " " << coords[slavePoints[i]] << endl;
97 const labelList& transformedSlavePoints = transformedSlaves[pointI];
99 if (transformedSlavePoints.size() > 0)
101 Pout<< "Master point:" << pointI
102 << " coord:" << coords[pointI]
103 << " connected to transformed slave points:" << endl;
105 forAll(transformedSlavePoints, i)
107 Pout<< " " << coords[transformedSlavePoints[i]]
115 // Test:print shared edges
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)
128 ec[edgeI] = coupledPatch.edges()[edgeI].centre
130 coupledPatch.localPoints()
134 // Exchange data Apply positional transforms.
135 globalEdgeSlavesMap.distribute
139 mapDistribute::transformPosition()
143 forAll(slaves, edgeI)
145 const labelList& slaveEdges = slaves[edgeI];
147 if (slaveEdges.size() > 0)
149 Pout<< "Master edge:" << edgeI
150 << " centre:" << ec[edgeI]
151 << " connected to slave edges:" << endl;
153 forAll(slaveEdges, i)
155 Pout<< " " << ec[slaveEdges[i]] << endl;
158 const labelList& transformedSlaveEdges = transformedSlaves[edgeI];
160 if (transformedSlaveEdges.size() > 0)
162 Pout<< "Master edge:" << edgeI
163 << " centre:" << ec[edgeI]
164 << " connected to transformed slave edges:" << endl;
166 forAll(transformedSlaveEdges, i)
168 Pout<< " " << ec[transformedSlaveEdges[i]]
176 // Test: point to faces addressing
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
196 mesh.nInternalFaces()
203 globalPointBoundaryFacesMap.distribute
207 mapDistribute::transformPosition()
211 forAll(slaves, pointI)
213 const labelList& slaveFaces = slaves[pointI];
215 if (slaveFaces.size() > 0)
217 Pout<< "Master point:" << pointI
218 << " at:" << coupledPatch.localPoints()[pointI]
219 << " connected to " << slaveFaces.size()
220 << " untransformed faces:" << endl;
222 forAll(slaveFaces, i)
224 Pout<< " " << fc[slaveFaces[i]] << endl;
228 const labelList& transformedSlaveFaces = transformedSlaves[pointI];
230 if (transformedSlaveFaces.size() > 0)
232 Pout<< "Master point:" << pointI
233 << " connected to " << transformedSlaveFaces.size()
234 << " transformed faces:" << endl;
236 forAll(transformedSlaveFaces, i)
238 Pout<< " " << fc[transformedSlaveFaces[i]] << endl;
245 // Test: point to cells addressing
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)
257 cc[i] = mesh.cellCentres()[boundaryCells[i]];
261 globalPointBoundaryCellsMap.distribute
265 mapDistribute::transformPosition()
269 forAll(slaves, pointI)
271 const labelList& pointCells = slaves[pointI];
273 if (pointCells.size() > 0)
275 Pout<< "Master point:" << pointI
276 << " at:" << coupledPatch.localPoints()[pointI]
277 << " connected to " << pointCells.size()
278 << " untransformed boundaryCells:" << endl;
280 forAll(pointCells, i)
282 Pout<< " " << cc[pointCells[i]] << endl;
286 const labelList& transformPointCells = transformedSlaves[pointI];
288 if (transformPointCells.size() > 0)
290 Pout<< "Master point:" << pointI
291 << " connected to " << transformPointCells.size()
292 << " transformed boundaryCells:" << endl;
294 forAll(transformPointCells, i)
296 Pout<< " " << cc[transformPointCells[i]] << endl;
303 Info<< "End\n" << endl;
309 // ************************************************************************* //