diff --git a/applications/test/globalMeshData/Make/files b/applications/test/globalMeshData/Make/files new file mode 100644 index 0000000000000000000000000000000000000000..dc5877e38355722c4836cf2f346bc877c33d04d4 --- /dev/null +++ b/applications/test/globalMeshData/Make/files @@ -0,0 +1,3 @@ +globalMeshDataTest.C + +EXE = $(FOAM_USER_APPBIN)/globalMeshDataTest diff --git a/applications/test/globalMeshData/Make/options b/applications/test/globalMeshData/Make/options new file mode 100644 index 0000000000000000000000000000000000000000..4c3dd783cb4170feefb3f5385510a83257b43b18 --- /dev/null +++ b/applications/test/globalMeshData/Make/options @@ -0,0 +1,3 @@ +EXE_INC = + +EXE_LIBS = diff --git a/applications/test/globalMeshData/globalMeshDataTest.C b/applications/test/globalMeshData/globalMeshDataTest.C new file mode 100644 index 0000000000000000000000000000000000000000..75f98b1b9cef2f068417955fbb50d992c3289bf0 --- /dev/null +++ b/applications/test/globalMeshData/globalMeshDataTest.C @@ -0,0 +1,221 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Application + globalMeshDataTest + +Description + Test global point communication + +\*---------------------------------------------------------------------------*/ + +#include "globalMeshData.H" +#include "argList.H" +#include "polyMesh.H" +#include "Time.H" +#include "mapDistribute.H" + +using namespace Foam; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +// Main program: + +int main(int argc, char *argv[]) +{ +# include "setRootCase.H" +# include "createTime.H" +# include "createPolyMesh.H" + + const globalMeshData& globalData = mesh.globalData(); + const indirectPrimitivePatch& coupledPatch = globalData.coupledPatch(); + + + // Test:print shared points + { + const labelListList& globalPointSlaves = + globalData.globalPointSlaves(); + const mapDistribute& globalPointSlavesMap = + globalData.globalPointSlavesMap(); + + pointField coords(globalPointSlavesMap.constructSize()); + SubList(coords, coupledPatch.nPoints()).assign + ( + coupledPatch.localPoints() + ); + + // Exchange data + globalPointSlavesMap.distribute(coords); + + // Print + forAll(globalPointSlaves, pointI) + { + const labelList& slavePoints = globalPointSlaves[pointI]; + + if (slavePoints.size() > 0) + { + Pout<< "Master point:" << pointI + << " coord:" << coords[pointI] + << " connected to slave points:" << endl; + + forAll(slavePoints, i) + { + Pout<< " " << coords[slavePoints[i]] << endl; + } + } + } + } + + + + // Test: point to faces addressing + { + const labelListList& globalPointBoundaryFaces = + globalData.globalPointBoundaryFaces(); + const mapDistribute& globalPointBoundaryFacesMap = + globalData.globalPointBoundaryFacesMap(); + + label nBnd = mesh.nFaces()-mesh.nInternalFaces(); + + pointField fc(globalPointBoundaryFacesMap.constructSize()); + SubList(fc, nBnd).assign + ( + primitivePatch + ( + SubList + ( + mesh.faces(), + nBnd, + mesh.nInternalFaces() + ), + mesh.points() + ).faceCentres() + ); + + // Exchange data + globalPointBoundaryFacesMap.distribute(fc); + + // Print + forAll(globalPointBoundaryFaces, pointI) + { + const labelList& bFaces = globalPointBoundaryFaces[pointI]; + + Pout<< "Point:" << pointI + << " at:" << coupledPatch.localPoints()[pointI] + << " connected to faces:" << endl; + + forAll(bFaces, i) + { + Pout<< " " << fc[bFaces[i]] << endl; + } + } + } + + + + + + // Test:point to cells addressing + { + const labelList& boundaryCells = globalData.boundaryCells(); + const labelListList& globalPointBoundaryCells = + globalData.globalPointBoundaryCells(); + const mapDistribute& globalPointBoundaryCellsMap = + globalData.globalPointBoundaryCellsMap(); + + pointField cc(globalPointBoundaryCellsMap.constructSize()); + forAll(boundaryCells, i) + { + cc[i] = mesh.cellCentres()[boundaryCells[i]]; + } + + // Exchange data + globalPointBoundaryCellsMap.distribute(cc); + + // Print + forAll(globalPointBoundaryCells, pointI) + { + const labelList& bCells = globalPointBoundaryCells[pointI]; + + Pout<< "Point:" << pointI + << " at:" << coupledPatch.localPoints()[pointI] + << " connected to cells:" << endl; + + forAll(bCells, i) + { + Pout<< " " << cc[bCells[i]] << endl; + } + } + } + + + + // Test:print shared edges + { + const labelListList& globalEdgeSlaves = + globalData.globalEdgeSlaves(); + const mapDistribute& globalEdgeSlavesMap = + globalData.globalEdgeSlavesMap(); + + // Test: distribute edge centres + pointField ec(globalEdgeSlavesMap.constructSize()); + forAll(coupledPatch.edges(), edgeI) + { + ec[edgeI] = coupledPatch.edges()[edgeI].centre + ( + coupledPatch.localPoints() + ); + } + + // Exchange data + globalEdgeSlavesMap.distribute(ec); + + // Print + forAll(globalEdgeSlaves, edgeI) + { + const labelList& slaveEdges = globalEdgeSlaves[edgeI]; + + if (slaveEdges.size() > 0) + { + Pout<< "Master edge:" << edgeI + << " centre:" << ec[edgeI] + << " connected to slave edges:" << endl; + + forAll(slaveEdges, i) + { + Pout<< " " << ec[slaveEdges[i]] << endl; + } + } + } + } + + + Info<< "End\n" << endl; + + return 0; +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C index 147b370d1a2aed21c8584dff457290d7481520dd..1b3bb264a2147086193552f52551eac30fd5e575 100644 --- a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C +++ b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C @@ -32,6 +32,8 @@ License #include "demandDrivenData.H" #include "globalPoints.H" //#include "geomGlobalPoints.H" +#include "polyMesh.H" +#include "mapDistribute.H" #include "labelIOList.H" #include "PackedList.H" #include "mergePoints.H" @@ -115,24 +117,17 @@ void Foam::globalMeshData::initProcAddr() // Given information about locally used edges allocate global shared edges. void Foam::globalMeshData::countSharedEdges ( - const HashTable >& procSharedEdges, - HashTable >& globalShared, + const EdgeMap& procSharedEdges, + EdgeMap