Commit c0f841e4 authored by Henry Weller's avatar Henry Weller
Browse files

globalIndexAndTransform: Support any number of transforms but no more than 3 per point

Patch contributed by Mattijs Janssens
Resolves bug-report http://bugs.openfoam.org/view.php?id=1815
parent 40f87094
......@@ -24,19 +24,14 @@ License
\*---------------------------------------------------------------------------*/
#include "globalMeshData.H"
#include "Time.H"
#include "Pstream.H"
#include "PstreamCombineReduceOps.H"
#include "processorPolyPatch.H"
#include "demandDrivenData.H"
#include "globalPoints.H"
#include "polyMesh.H"
#include "mapDistribute.H"
#include "labelIOList.H"
#include "PackedList.H"
#include "mergePoints.H"
#include "matchPoints.H"
#include "OFstream.H"
#include "globalIndexAndTransform.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
......@@ -577,7 +572,7 @@ void Foam::globalMeshData::calcPointConnectivity
labelPairList myData(globalPointSlavesMap().constructSize());
forAll(slaves, pointi)
{
myData[pointi] = globalIndexAndTransform::encode
myData[pointi] = transforms.encode
(
Pstream::myProcNo(),
pointi,
......@@ -624,9 +619,9 @@ void Foam::globalMeshData::calcPointConnectivity
);
// Add transform to connectivity
const labelPair& n = myData[pTransformSlaves[i]];
label proci = globalIndexAndTransform::processor(n);
label index = globalIndexAndTransform::index(n);
pConnectivity[connI++] = globalIndexAndTransform::encode
label proci = transforms.processor(n);
label index = transforms.index(n);
pConnectivity[connI++] = transforms.encode
(
proci,
index,
......@@ -678,6 +673,8 @@ void Foam::globalMeshData::calcGlobalPointEdges
const globalIndex& globalEdgeNumbers = globalEdgeNumbering();
const labelListList& slaves = globalPointSlaves();
const labelListList& transformedSlaves = globalPointTransformedSlaves();
const globalIndexAndTransform& transforms = globalTransforms();
// Create local version
globalPointEdges.setSize(globalPointSlavesMap().constructSize());
......@@ -697,11 +694,11 @@ void Foam::globalMeshData::calcGlobalPointEdges
forAll(pEdges, i)
{
label otherPointi = edges[pEdges[i]].otherVertex(pointi);
globalPPoints[i] = globalIndexAndTransform::encode
globalPPoints[i] = transforms.encode
(
Pstream::myProcNo(),
otherPointi,
globalTransforms().nullTransformIndex()
transforms.nullTransformIndex()
);
}
}
......@@ -790,9 +787,9 @@ void Foam::globalMeshData::calcGlobalPointEdges
{
// Add transform to connectivity
const labelPair& n = otherData[j];
label proci = globalIndexAndTransform::processor(n);
label index = globalIndexAndTransform::index(n);
globalPPoints[sz++] = globalIndexAndTransform::encode
label proci = transforms.processor(n);
label index = transforms.index(n);
globalPPoints[sz++] = transforms.encode
(
proci,
index,
......@@ -834,16 +831,18 @@ Foam::label Foam::globalMeshData::findTransform
const label localPoint
) const
{
const label remoteProci = globalIndexAndTransform::processor(remotePoint);
const label remoteIndex = globalIndexAndTransform::index(remotePoint);
const globalIndexAndTransform& transforms = globalTransforms();
const label remoteProci = transforms.processor(remotePoint);
const label remoteIndex = transforms.index(remotePoint);
label remoteTransformI = -1;
label localTransformI = -1;
forAll(info, i)
{
label proci = globalIndexAndTransform::processor(info[i]);
label pointi = globalIndexAndTransform::index(info[i]);
label transformI = globalIndexAndTransform::transformIndex(info[i]);
label proci = transforms.processor(info[i]);
label pointi = transforms.index(info[i]);
label transformI = transforms.transformIndex(info[i]);
if (proci == Pstream::myProcNo() && pointi == localPoint)
{
......@@ -875,7 +874,7 @@ Foam::label Foam::globalMeshData::findTransform
<< abort(FatalError);
}
return globalTransforms().subtractTransformIndex
return transforms.subtractTransformIndex
(
remoteTransformI,
localTransformI
......@@ -893,6 +892,7 @@ void Foam::globalMeshData::calcGlobalEdgeSlaves() const
const edgeList& edges = coupledPatch().edges();
const globalIndex& globalEdgeNumbers = globalEdgeNumbering();
const globalIndexAndTransform& transforms = globalTransforms();
// The whole problem with deducting edge-connectivity from
......@@ -941,11 +941,11 @@ void Foam::globalMeshData::calcGlobalEdgeSlaves() const
// Append myself.
eEdges.append
(
globalIndexAndTransform::encode
transforms.encode
(
Pstream::myProcNo(),
edgeI,
globalTransforms().nullTransformIndex()
transforms.nullTransformIndex()
)
);
......@@ -986,7 +986,7 @@ void Foam::globalMeshData::calcGlobalEdgeSlaves() const
label proci = globalEdgeNumbers.whichProcID(pEdges0[i]);
eEdges.append
(
globalIndexAndTransform::encode
transforms.encode
(
proci,
globalEdgeNumbers.toLocal(proci, pEdges0[i]),
......@@ -999,7 +999,11 @@ void Foam::globalMeshData::calcGlobalEdgeSlaves() const
}
allEdgeConnectivity[edgeI].transfer(eEdges);
sort(allEdgeConnectivity[edgeI], globalIndexAndTransform::less());
sort
(
allEdgeConnectivity[edgeI],
globalIndexAndTransform::less(transforms)
);
}
// We now have - in allEdgeConnectivity - a list of edges which are shared
......@@ -1020,10 +1024,10 @@ void Foam::globalMeshData::calcGlobalEdgeSlaves() const
if
(
(
globalIndexAndTransform::processor(masterInfo)
transforms.processor(masterInfo)
== Pstream::myProcNo()
)
&& (globalIndexAndTransform::index(masterInfo) == edgeI)
&& (transforms.index(masterInfo) == edgeI)
)
{
// Sort into transformed and untransformed
......@@ -1039,14 +1043,14 @@ void Foam::globalMeshData::calcGlobalEdgeSlaves() const
for (label i = 1; i < edgeInfo.size(); i++)
{
const labelPair& info = edgeInfo[i];
label proci = globalIndexAndTransform::processor(info);
label index = globalIndexAndTransform::index(info);
label transform = globalIndexAndTransform::transformIndex
label proci = transforms.processor(info);
label index = transforms.index(info);
label transform = transforms.transformIndex
(
info
);
if (transform == globalTransforms().nullTransformIndex())
if (transform == transforms.nullTransformIndex())
{
eEdges[nonTransformI++] = globalEdgeNumbers.toGlobal
(
......@@ -1078,7 +1082,7 @@ void Foam::globalMeshData::calcGlobalEdgeSlaves() const
globalEdgeNumbers,
globalEdgeSlaves,
globalTransforms(),
transforms,
transformedEdges,
globalEdgeTransformedSlavesPtr_(),
......@@ -1351,6 +1355,7 @@ void Foam::globalMeshData::calcGlobalPointBoundaryFaces() const
const labelListList& pointSlaves = globalPointSlaves();
const labelListList& pointTransformSlaves =
globalPointTransformedSlaves();
const globalIndexAndTransform& transforms = globalTransforms();
// Any faces coming in through transformation
......@@ -1432,7 +1437,7 @@ void Foam::globalMeshData::calcGlobalPointBoundaryFaces() const
label proci = globalIndices.whichProcID(slave);
label facei = globalIndices.toLocal(proci, slave);
myBFaces[n++] = globalIndexAndTransform::encode
myBFaces[n++] = transforms.encode
(
proci,
facei,
......@@ -1466,7 +1471,7 @@ void Foam::globalMeshData::calcGlobalPointBoundaryFaces() const
globalIndices,
globalPointBoundaryFaces,
globalTransforms(),
transforms,
transformedFaces,
globalPointTransformedBoundaryFacesPtr_(),
......@@ -1581,6 +1586,7 @@ void Foam::globalMeshData::calcGlobalPointBoundaryCells() const
const labelListList& pointSlaves = globalPointSlaves();
const labelListList& pointTransformSlaves =
globalPointTransformedSlaves();
const globalIndexAndTransform& transforms = globalTransforms();
List<labelPairList> transformedCells(pointSlaves.size());
......@@ -1660,7 +1666,7 @@ void Foam::globalMeshData::calcGlobalPointBoundaryCells() const
{
label proci = globalIndices.whichProcID(slave);
label celli = globalIndices.toLocal(proci, slave);
myBCells[n++] = globalIndexAndTransform::encode
myBCells[n++] = transforms.encode
(
proci,
celli,
......@@ -1693,7 +1699,7 @@ void Foam::globalMeshData::calcGlobalPointBoundaryCells() const
globalIndices,
globalPointBoundaryCells,
globalTransforms(),
transforms,
transformedCells,
globalPointTransformedBoundaryCellsPtr_(),
......@@ -1765,12 +1771,12 @@ Foam::globalMeshData::globalMeshData(const polyMesh& mesh)
processorPatchIndices_(0),
processorPatchNeighbours_(0),
nGlobalPoints_(-1),
sharedPointLabelsPtr_(nullptr),
sharedPointAddrPtr_(nullptr),
sharedPointGlobalLabelsPtr_(nullptr),
sharedPointLabelsPtr_(NULL),
sharedPointAddrPtr_(NULL),
sharedPointGlobalLabelsPtr_(NULL),
nGlobalEdges_(-1),
sharedEdgeLabelsPtr_(nullptr),
sharedEdgeAddrPtr_(nullptr)
sharedEdgeLabelsPtr_(NULL),
sharedEdgeAddrPtr_(NULL)
{
updateMesh();
}
......
......@@ -72,7 +72,6 @@ See also
mapDistribute
globalIndexAndTransform
SourceFiles
globalMeshData.C
globalMeshDataTemplates.C
......
......@@ -64,15 +64,15 @@ Foam::label Foam::globalPoints::findSamePoint
const labelPair& info
) const
{
const label proci = globalIndexAndTransform::processor(info);
const label index = globalIndexAndTransform::index(info);
const label proci = globalTransforms_.processor(info);
const label index = globalTransforms_.index(info);
forAll(allInfo, i)
{
if
(
globalIndexAndTransform::processor(allInfo[i]) == proci
&& globalIndexAndTransform::index(allInfo[i]) == index
globalTransforms_.processor(allInfo[i]) == proci
&& globalTransforms_.index(allInfo[i]) == index
)
{
return i;
......@@ -98,21 +98,21 @@ Foam::labelPairList Foam::globalPoints::addSendTransform
forAll(info, i)
{
//Pout<< " adding send transform to" << nl
// << " proc:" << globalIndexAndTransform::processor(info[i])
// << " proc:" << globalTransforms_.processor(info[i])
// << nl
// << " index:" << globalIndexAndTransform::index(info[i]) << nl
// << " index:" << globalTransforms_.index(info[i]) << nl
// << " trafo:"
// << globalTransforms_.decodeTransformIndex
// (globalIndexAndTransform::transformIndex(info[i]))
// (globalTransforms_.transformIndex(info[i]))
// << endl;
sendInfo[i] = globalIndexAndTransform::encode
sendInfo[i] = globalTransforms_.encode
(
globalIndexAndTransform::processor(info[i]),
globalIndexAndTransform::index(info[i]),
globalTransforms_.processor(info[i]),
globalTransforms_.index(info[i]),
globalTransforms_.addToTransformIndex
(
globalIndexAndTransform::transformIndex(info[i]),
globalTransforms_.transformIndex(info[i]),
patchi,
true, // patchi is sending side
tol // tolerance for comparison
......@@ -204,11 +204,11 @@ bool Foam::globalPoints::mergeInfo
}
else
{
label myTransform = globalIndexAndTransform::transformIndex
label myTransform = globalTransforms_.transformIndex
(
myInfo[index]
);
label nbrTransform = globalIndexAndTransform::transformIndex
label nbrTransform = globalTransforms_.transformIndex
(
nbrInfo[i]
);
......@@ -294,7 +294,7 @@ bool Foam::globalPoints::mergeInfo
labelPairList knownInfo
(
1,
globalIndexAndTransform::encode
globalTransforms_.encode
(
Pstream::myProcNo(),
localPointi,
......@@ -356,9 +356,9 @@ void Foam::globalPoints::printProcPoint
const labelPair& pointInfo
) const
{
label proci = globalIndexAndTransform::processor(pointInfo);
label index = globalIndexAndTransform::index(pointInfo);
label trafoI = globalIndexAndTransform::transformIndex(pointInfo);
label proci = globalTransforms_.processor(pointInfo);
label index = globalTransforms_.index(pointInfo);
label trafoI = globalTransforms_.transformIndex(pointInfo);
Pout<< " proc:" << proci;
Pout<< " localpoint:";
......@@ -421,7 +421,7 @@ void Foam::globalPoints::initOwnPoints
labelPairList knownInfo
(
1,
globalIndexAndTransform::encode
globalTransforms_.encode
(
Pstream::myProcNo(),
localPointi,
......@@ -457,7 +457,7 @@ void Foam::globalPoints::initOwnPoints
labelPairList knownInfo
(
1,
globalIndexAndTransform::encode
globalTransforms_.encode
(
Pstream::myProcNo(),
localPointi,
......@@ -750,8 +750,8 @@ void Foam::globalPoints::remove
// is in it. This would be an ordinary connection and can be
// handled by normal face-face connectivity.
label proc0 = globalIndexAndTransform::processor(pointInfo[0]);
label proc1 = globalIndexAndTransform::processor(pointInfo[1]);
label proc0 = globalTransforms_.processor(pointInfo[0]);
label proc1 = globalTransforms_.processor(pointInfo[1]);
if
(
......@@ -759,14 +759,14 @@ void Foam::globalPoints::remove
proc0 == Pstream::myProcNo()
&& directNeighbours.found
(
globalIndexAndTransform::index(pointInfo[0])
globalTransforms_.index(pointInfo[0])
)
)
|| (
proc1 == Pstream::myProcNo()
&& directNeighbours.found
(
globalIndexAndTransform::index(pointInfo[1])
globalTransforms_.index(pointInfo[1])
)
)
)
......@@ -776,14 +776,14 @@ void Foam::globalPoints::remove
{
//Pout<< "Removing direct neighbour:"
// << mesh_.points()
// [globalIndexAndTransform::index(pointInfo[0])]
// [globalTransforms_.index(pointInfo[0])]
// << endl;
}
else if (proc1 == Pstream::myProcNo())
{
//Pout<< "Removing direct neighbour:"
// << mesh_.points()
// [globalIndexAndTransform::index(pointInfo[1])]
// [globalTransforms_.index(pointInfo[1])]
// << endl;
}
}
......@@ -812,11 +812,11 @@ void Foam::globalPoints::remove
// So this meshPoint will have info of size one only.
if
(
globalIndexAndTransform::processor(pointInfo[0])
globalTransforms_.processor(pointInfo[0])
!= Pstream::myProcNo()
|| !directNeighbours.found
(
globalIndexAndTransform::index(pointInfo[0])
globalTransforms_.index(pointInfo[0])
)
)
{
......@@ -995,7 +995,7 @@ void Foam::globalPoints::calculateSharedPoints
forAllConstIter(Map<label>, meshToProcPoint_, iter)
{
labelPairList& pointInfo = procPoints_[iter()];
sort(pointInfo, globalIndexAndTransform::less());
sort(pointInfo, globalIndexAndTransform::less(globalTransforms_));
}
......@@ -1017,10 +1017,10 @@ void Foam::globalPoints::calculateSharedPoints
if
(
(
globalIndexAndTransform::processor(masterInfo)
globalTransforms_.processor(masterInfo)
== Pstream::myProcNo()
)
&& (globalIndexAndTransform::index(masterInfo) == iter.key())
&& (globalTransforms_.index(masterInfo) == iter.key())
)
{
labelList& pPoints = pointPoints_[iter.key()];
......@@ -1035,9 +1035,9 @@ void Foam::globalPoints::calculateSharedPoints
for (label i = 1; i < pointInfo.size(); i++)
{
const labelPair& info = pointInfo[i];
label proci = globalIndexAndTransform::processor(info);
label index = globalIndexAndTransform::index(info);
label transform = globalIndexAndTransform::transformIndex
label proci = globalTransforms_.processor(info);
label index = globalTransforms_.index(info);
label transform = globalTransforms_.transformIndex
(
info
);
......
......@@ -270,10 +270,10 @@ Foam::mapDistribute::mapDistribute
forAll(transformedElements, i)
{
labelPair elem = transformedElements[i];
label proci = globalIndexAndTransform::processor(elem);
label proci = globalTransforms.processor(elem);
if (proci != Pstream::myProcNo())
{
label index = globalIndexAndTransform::index(elem);
label index = globalTransforms.index(elem);
label nCompact = compactMap[proci].size();
compactMap[proci].insert(index, nCompact);
}
......@@ -301,7 +301,7 @@ Foam::mapDistribute::mapDistribute
forAll(transformedElements, i)
{
labelPair elem = transformedElements[i];
label trafoI = globalIndexAndTransform::transformIndex(elem);
label trafoI = globalTransforms.transformIndex(elem);
nPerTransform[trafoI]++;
}
// Offset per transformIndex
......@@ -321,9 +321,9 @@ Foam::mapDistribute::mapDistribute
forAll(transformedElements, i)
{
labelPair elem = transformedElements[i];
label proci = globalIndexAndTransform::processor(elem);
label index = globalIndexAndTransform::index(elem);
label trafoI = globalIndexAndTransform::transformIndex(elem);
label proci = globalTransforms.processor(elem);
label index = globalTransforms.index(elem);
label trafoI = globalTransforms.transformIndex(elem);
// Get compact index for untransformed element
label rawElemI =
......@@ -378,10 +378,10 @@ Foam::mapDistribute::mapDistribute
forAll(elems, i)
{
label proci = globalIndexAndTransform::processor(elems[i]);
label proci = globalTransforms.processor(elems[i]);
if (proci != Pstream::myProcNo())
{
label index = globalIndexAndTransform::index(elems[i]);
label index = globalTransforms.index(elems[i]);
label nCompact = compactMap[proci].size();
compactMap[proci].insert(index, nCompact);
}
......@@ -413,7 +413,7 @@ Foam::mapDistribute::mapDistribute
forAll(elems, i)
{
label trafoI = globalIndexAndTransform::transformIndex(elems[i]);
label trafoI = globalTransforms.transformIndex(elems[i]);
nPerTransform[trafoI]++;
}
}
......@@ -438,9 +438,9 @@ Foam::mapDistribute::mapDistribute
forAll(elems, i)
{
label proci = globalIndexAndTransform::processor(elems[i]);
label index = globalIndexAndTransform::index(elems[i]);
label trafoI = globalIndexAndTransform::transformIndex(elems[i]);
label proci = globalTransforms.processor(elems[i]);
label index = globalTransforms.index(elems[i]);
label trafoI = globalTransforms.transformIndex(elems[i]);
// Get compact index for untransformed element
label rawElemI =
......
......@@ -461,7 +461,7 @@ void Foam::mapDistributeBase::distribute
{
// Set up sends to neighbours
List<List<T>> sendFields(Pstream::nProcs());
List<List<T > > sendFields(Pstream::nProcs());
for (label domain = 0; domain < Pstream::nProcs(); domain++)
{
......@@ -495,7 +495,7 @@ void Foam::mapDistributeBase::distribute
// Set up receives from neighbours
List<List<T>> recvFields(Pstream::nProcs());
List<List<T > > recvFields(Pstream::nProcs());
for (label domain = 0; domain < Pstream::nProcs(); domain++)
{
......@@ -938,7 +938,7 @@ void Foam::mapDistributeBase::distribute
{
// Set up sends to neighbours
List<List<T>> sendFields(Pstream::nProcs());
List<List<T > > sendFields(Pstream::nProcs());
for (label domain = 0; domain < Pstream::nProcs(); domain++)
{
......@@ -972,7 +972,7 @@ void Foam::mapDistributeBase::distribute
// Set up receives from neighbours
List<List<T>> recvFields(Pstream::nProcs());
List<List<T > > recvFields(Pstream::nProcs());
for (label domain = 0; domain < Pstream::nProcs(); domain++)
{
......
......@@ -25,13 +25,14 @@ License
#include "globalIndexAndTransform.H"
#include "cyclicPolyPatch.H"
#include "DynamicField.H"
#include "globalMeshData.H"
// * * * * * * * * * * * * Private Static Data Members * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(globalIndexAndTransform, 0);
const label globalIndexAndTransform::base_ = 32;
defineTypeNameAndDebug(globalIndexAndTransform, 0);
}
......@@ -127,10 +128,8 @@ void Foam::globalIndexAndTransform::determineTransforms()
{
const polyBoundaryMesh& patches = mesh_.boundaryMesh();
transforms_ = List<vectorTensorTransform>(6);
scalarField maxTol(6);
label nextTrans = 0;
DynamicList<vectorTensorTransform> localTransforms;
DynamicField<scalar> localTols;
label dummyMatch = -1;
......@@ -170,7 +169,7 @@ void Foam::globalIndexAndTransform::determineTransforms()