From fe987dad110f786bc91a433580b54cda07bee9e6 Mon Sep 17 00:00:00 2001 From: mattijs Date: Thu, 20 Jan 2011 15:31:43 +0000 Subject: [PATCH] ENH: Test-globalMeshData.C : updated to include transforms --- .../test/globalMeshData/Test-globalMeshData.C | 220 ++++++++++-------- 1 file changed, 125 insertions(+), 95 deletions(-) diff --git a/applications/test/globalMeshData/Test-globalMeshData.C b/applications/test/globalMeshData/Test-globalMeshData.C index 551e3e5365..6feaf5cc05 100644 --- a/applications/test/globalMeshData/Test-globalMeshData.C +++ b/applications/test/globalMeshData/Test-globalMeshData.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -50,133 +50,71 @@ int main(int argc, char *argv[]) const globalMeshData& globalData = mesh.globalData(); const indirectPrimitivePatch& coupledPatch = globalData.coupledPatch(); + const globalIndexAndTransform& transforms = globalData.globalTransforms(); - // Test:print (collocated) shared points + // Test:print shared points { - const labelListList& globalPointSlaves = - globalData.globalPointSlaves(); const mapDistribute& globalPointSlavesMap = globalData.globalPointSlavesMap(); + const labelListList& slaves = + globalData.globalPointSlaves(); + const labelListList& transformedSlaves = + globalData.globalPointTransformedSlaves(); + // Create field with my local data pointField coords(globalPointSlavesMap.constructSize()); SubList(coords, coupledPatch.nPoints()).assign ( coupledPatch.localPoints() ); - // Exchange data - globalPointSlavesMap.distribute(coords); + // Exchange data. Apply positional transforms. + globalPointSlavesMap.distribute(transforms, coords, true); // Print - forAll(globalPointSlaves, pointI) + forAll(slaves, pointI) { - const labelList& slavePoints = globalPointSlaves[pointI]; + const labelList& slavePoints = slaves[pointI]; if (slavePoints.size() > 0) { Pout<< "Master point:" << pointI << " coord:" << coords[pointI] - << " connected to slave points:" << endl; + << " connected to untransformed slave points:" << endl; forAll(slavePoints, i) { Pout<< " " << coords[slavePoints[i]] << endl; } } - } - } + const labelList& transformedSlavePoints = transformedSlaves[pointI]; - - // Test: (collocated) 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) + if (transformedSlavePoints.size() > 0) { - Pout<< " " << fc[bFaces[i]] << endl; + Pout<< "Master point:" << pointI + << " coord:" << coords[pointI] + << " connected to transformed slave points:" << endl; + + forAll(transformedSlavePoints, i) + { + Pout<< " " << coords[transformedSlavePoints[i]] + << endl; + } } } } - - - - // Test:(collocated) point to cells addressing + // Test:print shared edges { - 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 (collocated) shared edges - { - const labelListList& globalEdgeSlaves = - globalData.globalEdgeSlaves(); const mapDistribute& globalEdgeSlavesMap = globalData.globalEdgeSlavesMap(); + const labelListList& slaves = + globalData.globalEdgeSlaves(); + const labelListList& transformedSlaves = + globalData.globalEdgeTransformedSlaves(); // Test: distribute edge centres pointField ec(globalEdgeSlavesMap.constructSize()); @@ -188,13 +126,13 @@ int main(int argc, char *argv[]) ); } - // Exchange data - globalEdgeSlavesMap.distribute(ec); + // Exchange data Apply positional transforms. + globalEdgeSlavesMap.distribute(transforms, ec, true); // Print - forAll(globalEdgeSlaves, edgeI) + forAll(slaves, edgeI) { - const labelList& slaveEdges = globalEdgeSlaves[edgeI]; + const labelList& slaveEdges = slaves[edgeI]; if (slaveEdges.size() > 0) { @@ -207,10 +145,102 @@ int main(int argc, char *argv[]) Pout<< " " << ec[slaveEdges[i]] << endl; } } + const labelList& transformedSlaveEdges = transformedSlaves[edgeI]; + + if (transformedSlaveEdges.size() > 0) + { + Pout<< "Master edge:" << edgeI + << " centre:" << ec[edgeI] + << " connected to transformed slave edges:" << endl; + + forAll(transformedSlaveEdges, i) + { + Pout<< " " << ec[transformedSlaveEdges[i]] + << endl; + } + } } } + //// Test: (collocated) 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:(collocated) 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; + // } + // } + //} + + Info<< "End\n" << endl; return 0;