diff --git a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C index 5790d951eb..fd39d1d0f8 100644 --- a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C +++ b/src/OpenFOAM/meshes/polyMesh/globalMeshData/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 @@ -30,7 +30,6 @@ License #include "processorPolyPatch.H" #include "demandDrivenData.H" #include "globalPoints.H" -//#include "geomGlobalPoints.H" #include "polyMesh.H" #include "mapDistribute.H" #include "labelIOList.H" @@ -38,6 +37,7 @@ License #include "mergePoints.H" #include "matchPoints.H" #include "OFstream.H" +#include "globalIndexAndTransform.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -117,6 +117,126 @@ void Foam::globalMeshData::initProcAddr() } +void Foam::globalMeshData::calcSharedPoints() const +{ + if + ( + nGlobalPoints_ != -1 + || sharedPointLabelsPtr_.valid() + || sharedPointAddrPtr_.valid() + ) + { + FatalErrorIn("globalMeshData::calcSharedPoints()") + << "Shared point addressing already done" << abort(FatalError); + } + + // Calculate all shared points (exclude points that are only + // on two coupled patches). This does all the hard work. + globalPoints parallelPoints(mesh_, false, true); + + // Count the number of master points + label nMaster = 0; + forAll(parallelPoints.pointPoints(), i) + { + const labelList& pPoints = parallelPoints.pointPoints()[i]; + const labelList& transPPoints = + parallelPoints.transformedPointPoints()[i]; + + if (pPoints.size()+transPPoints.size() > 0) + { + nMaster++; + } + } + + // Allocate global numbers + globalIndex masterNumbering(nMaster); + + nGlobalPoints_ = masterNumbering.size(); + + + // Push master number to slaves + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + // 1. Fill master and slave slots + nMaster = 0; + labelList master(parallelPoints.map().constructSize(), -1); + forAll(parallelPoints.pointPoints(), i) + { + const labelList& pPoints = parallelPoints.pointPoints()[i]; + const labelList& transPPoints = + parallelPoints.transformedPointPoints()[i]; + + if (pPoints.size()+transPPoints.size() > 0) + { + master[i] = masterNumbering.toGlobal(nMaster); + forAll(pPoints, j) + { + master[pPoints[j]] = master[i]; + } + forAll(transPPoints, j) + { + master[transPPoints[j]] = master[i]; + } + nMaster++; + } + } + + + // 2. Push slave slots back to local storage on originating processor + // For all the four types of points: + // - local master : already set + // - local transformed slave point : the reverse transform at + // reverseDistribute will have copied it back to its originating local + // point + // - remote untransformed slave point : sent back to originating processor + // - remote transformed slave point : the reverse transform will + // copy it back into the remote slot which then gets sent back to + // originating processor + + parallelPoints.map().reverseDistribute + ( + parallelPoints.map().constructSize(), + master + ); + + + // Collect all points that are a master or refer to a master. + nMaster = 0; + forAll(parallelPoints.pointPoints(), i) + { + if (master[i] != -1) + { + nMaster++; + } + } + + sharedPointLabelsPtr_.reset(new labelList(nMaster)); + labelList& sharedPointLabels = sharedPointLabelsPtr_(); + sharedPointAddrPtr_.reset(new labelList(nMaster)); + labelList& sharedPointAddr = sharedPointAddrPtr_(); + nMaster = 0; + + forAll(parallelPoints.pointPoints(), i) + { + if (master[i] != -1) + { + // I am master or slave + sharedPointLabels[nMaster] = i; + sharedPointAddr[nMaster] = master[i]; + nMaster++; + } + } + + if (debug) + { + Pout<< "globalMeshData : nGlobalPoints_:" << nGlobalPoints_ << nl + << "globalMeshData : sharedPointLabels_:" + << sharedPointLabelsPtr_().size() << nl + << "globalMeshData : sharedPointAddr_:" + << sharedPointAddrPtr_().size() << endl; + } +} + + // Given information about locally used edges allocate global shared edges. void Foam::globalMeshData::countSharedEdges ( @@ -166,7 +286,12 @@ void Foam::globalMeshData::countSharedEdges // clusters of shared points) void Foam::globalMeshData::calcSharedEdges() const { - if (nGlobalEdges_ != -1 || sharedEdgeLabelsPtr_ || sharedEdgeAddrPtr_) + if + ( + nGlobalEdges_ != -1 + || sharedEdgeLabelsPtr_.valid() + || sharedEdgeAddrPtr_.valid() + ) { FatalErrorIn("globalMeshData::calcSharedEdges()") << "Shared edge addressing already done" << abort(FatalError); @@ -370,12 +495,12 @@ void Foam::globalMeshData::calcSharedEdges() const } } - sharedEdgeLabelsPtr_ = new labelList(); - labelList& sharedEdgeLabels = *sharedEdgeLabelsPtr_; + sharedEdgeLabelsPtr_.reset(new labelList()); + labelList& sharedEdgeLabels = sharedEdgeLabelsPtr_(); sharedEdgeLabels.transfer(dynSharedEdgeLabels); - sharedEdgeAddrPtr_ = new labelList(); - labelList& sharedEdgeAddr = *sharedEdgeAddrPtr_; + sharedEdgeAddrPtr_.reset(new labelList()); + labelList& sharedEdgeAddr = sharedEdgeAddrPtr_(); sharedEdgeAddr.transfer(dynSharedEdgeAddr); if (debug) @@ -389,220 +514,41 @@ void Foam::globalMeshData::calcSharedEdges() const } -// Helper function to count coincident faces. This part used to be -// in updateMesh but I've had to move it to a separate function -// because of aliasing optimisation errors in icc9.1 on the -// Itanium. -Foam::label Foam::globalMeshData::countCoincidentFaces -( - const scalar tolDim, - const vectorField& separationDist -) -{ - label nCoincident = 0; - - forAll(separationDist, faceI) - { - if (mag(separationDist[faceI]) < tolDim) - { - // Faces coincide - nCoincident++; - } - } - return nCoincident; -} - - -void Foam::globalMeshData::calcGlobalPointSlaves -( - const globalPoints& globalData, - autoPtr& globalIndicesPtr, - autoPtr& globalPointSlavesPtr, - autoPtr& globalPointSlavesMapPtr -) const -{ - // Create global numbering for coupled points - globalIndicesPtr.reset - ( - new globalIndex(globalData.globalIndices()) - ); - const globalIndex& globalIndices = globalIndicesPtr(); - - // Create master to slave addressing. Empty for slave points. - globalPointSlavesPtr.reset - ( - new labelListList(coupledPatch().nPoints()) - ); - labelListList& globalPointSlaves = globalPointSlavesPtr(); - - - const Map