Commit 29c879a6 authored by mattijs's avatar mattijs
Browse files

BUG: globalPoints: handling points on 3 cyclics. Disabled globalPoints on...

BUG: globalPoints: handling points on 3 cyclics. Disabled globalPoints on unordered cyclic patches NOORDERING

Wallfilm uses cyclics to do transform but is not proper subdivision of space.
This conflicts with globalIndexAndTransform determining 3 independent transforms.
parent 06b719a3
......@@ -57,6 +57,30 @@ Foam::label Foam::globalPoints::countPatchPoints
}
Foam::label Foam::globalPoints::findSamePoint
(
const labelPairList& allInfo,
const labelPair& info
) const
{
const label procI = globalIndexAndTransform::processor(info);
const label index = globalIndexAndTransform::index(info);
forAll(allInfo, i)
{
if
(
globalIndexAndTransform::processor(allInfo[i]) == procI
&& globalIndexAndTransform::index(allInfo[i]) == index
)
{
return i;
}
}
return -1;
}
Foam::labelPairList Foam::globalPoints::addSendTransform
(
const label patchI,
......@@ -67,6 +91,15 @@ Foam::labelPairList Foam::globalPoints::addSendTransform
forAll(info, i)
{
//Pout<< " adding send transform to" << nl
// << " proc:" << globalIndexAndTransform::processor(info[i])
// << nl
// << " index:" << globalIndexAndTransform::index(info[i]) << nl
// << " trafo:"
// << globalTransforms_.decodeTransformIndex
// (globalIndexAndTransform::transformIndex(info[i]))
// << endl;
sendInfo[i] = globalIndexAndTransform::encode
(
globalIndexAndTransform::processor(info[i]),
......@@ -129,72 +162,63 @@ bool Foam::globalPoints::mergeInfo
{
bool anyChanged = false;
// Extend to make space for the nbrInfo (trimmed later)
labelPairList newInfo(myInfo);
label newI = newInfo.size();
newInfo.setSize(newI + nbrInfo.size());
forAll(nbrInfo, i)
{
const labelPair& info = nbrInfo[i];
label nbrProcI = globalIndexAndTransform::processor(info);
label nbrIndex = globalIndexAndTransform::index(info);
label nbrTransform = globalIndexAndTransform::transformIndex(info);
// Check if already have information about nbr point. There are two
// possibilities:
// - information found about same point but different transform.
// Combine transforms
// - information not found.
label myIndex = -1;
forAll(myInfo, myI)
label index = findSamePoint(myInfo, nbrInfo[i]);
if (index == -1)
{
if (myInfo[myI] == info)
// New point
newInfo[newI++] = nbrInfo[i];
anyChanged = true;
}
else
{
// Same point. So we already have a connection between localPointI
// and the nbrIndex. Two situations:
// - same transform
// - one transform takes two steps, the other just a single.
if (myInfo[index] == nbrInfo[i])
{
// Fully identical. We already have nbrInfo.
myIndex = myI;
// Everything same (so also transform). Nothing changed.
}
else if
(
globalIndexAndTransform::processor(myInfo[myI]) == nbrProcI
&& globalIndexAndTransform::index(myInfo[myI]) == nbrIndex
)
else
{
// Only differing is the transform.
label myTransform = globalIndexAndTransform::transformIndex
(
myInfo[myI]
myInfo[index]
);
label nbrTransform = globalIndexAndTransform::transformIndex
(
nbrInfo[i]
);
// Combine mine and nbr transform
label t = globalTransforms_.mergeTransformIndex
// Different transform. See which is 'simplest'.
label minTransform = globalTransforms_.minimumTransformIndex
(
nbrTransform,
myTransform
myTransform,
nbrTransform
);
myIndex = myI;
if (t != myTransform)
if (minTransform != myTransform)
{
// Same point but different transformation
newInfo[myI] = globalIndexAndTransform::encode
(
nbrProcI,
nbrIndex,
t
);
// Use nbr info.
newInfo[index] = nbrInfo[i];
anyChanged = true;
break;
}
}
}
if (myIndex == -1)
{
// New point
newInfo[newI++] = nbrInfo[i];
anyChanged = true;
}
}
newInfo.setSize(newI);
......@@ -327,7 +351,7 @@ void Foam::globalPoints::printProcPoints
label index = globalIndexAndTransform::index(pointInfo[i]);
label trafoI = globalIndexAndTransform::transformIndex(pointInfo[i]);
Pout<< "proc:" << procI;
Pout<< " proc:" << procI;
Pout<< " localpoint:";
Pout<< index;
Pout<< " through transform:"
......@@ -386,6 +410,10 @@ void Foam::globalPoints::initOwnPoints
)
);
//Pout<< "For point "<< pp.points()[meshPointI]
// << " inserting info " << knownInfo
// << endl;
// Update changedpoints info.
if (storeInitialInfo(knownInfo, localPointI))
{
......@@ -636,58 +664,34 @@ void Foam::globalPoints::receivePatchPoints
Map<label>::iterator procPointA =
meshToProcPoint_.find(localA);
labelPairList infoA;
if (procPointA != meshToProcPoint_.end())
{
infoA = addSendTransform
const labelPairList infoA = addSendTransform
(
cycPatch.index(),
procPoints_[procPointA()]
);
if (mergeInfo(infoA, localB))
{
changedPoints.insert(localB);
}
}
// Same for info on pointB
Map<label>::iterator procPointB =
meshToProcPoint_.find(localB);
labelPairList infoB;
if (procPointB != meshToProcPoint_.end())
{
infoB = addSendTransform
const labelPairList infoB = addSendTransform
(
cycPatch.neighbPatchID(),
procPoints_[procPointB()]
);
}
if (infoA.size())
{
if (mergeInfo(infoA, localB))
{
//Pout<< " Combined info at point "
// << mesh_.points()[meshPointB]
// << " now " << endl;
//printProcPoints
//(
// patchToMeshPoint,
// procPoints_[meshToProcPoint_[localB]]
//);
changedPoints.insert(localB);
}
}
if (infoB.size())
{
if (mergeInfo(infoB, localA))
{
//Pout<< " Combined info at point "
// << mesh_.points()[meshPointA]
// << " now " << endl;
//printProcPoints
//(
// patchToMeshPoint,
// procPoints_[meshToProcPoint_[localA]]
//);
changedPoints.insert(localA);
}
}
......@@ -845,6 +849,9 @@ void Foam::globalPoints::calculateSharedPoints
{
Pout<< "globalPoints::calculateSharedPoints(..) : "
<< "doing processor to processor communication to get sharedPoints"
<< endl
<< " keepAllPoints :" << keepAllPoints << endl
<< " mergeSeparated:" << mergeSeparated << endl
<< endl;
}
......@@ -951,7 +958,7 @@ void Foam::globalPoints::calculateSharedPoints
// printProcPoints(patchToMeshPoint, pointInfo);
// Pout<< endl;
//}
//
// Remove direct neighbours from point equivalences.
if (!keepAllPoints)
......
......@@ -143,6 +143,13 @@ class globalPoints
// information is collected.
static label countPatchPoints(const polyBoundaryMesh&);
//- Find index of same processor+index
label findSamePoint
(
const labelPairList& allInfo,
const labelPair& info
) const;
labelPairList addSendTransform
(
const label patchI,
......
......@@ -136,7 +136,19 @@ void Foam::globalIndexAndTransform::determineTransforms()
{
const polyPatch& pp = patches[patchI];
if (isA<coupledPolyPatch>(pp))
// Note: special check for unordered cyclics. These are in fact
// transform bcs and should probably be split off.
if
(
isA<coupledPolyPatch>(pp)
&& !(
isA<cyclicPolyPatch>(pp)
&& (
refCast<const cyclicPolyPatch>(pp).transform()
== cyclicPolyPatch::NOORDERING
)
)
)
{
const coupledPolyPatch& cpp = refCast<const coupledPolyPatch>(pp);
......@@ -164,21 +176,19 @@ void Foam::globalIndexAndTransform::determineTransforms()
) == 0
)
{
if (nextTrans == 6)
{
FatalErrorIn
(
"void Foam::globalIndexAndTransform::"
"determineTransforms()"
) << "More than six unsigned transforms"
<< " detected:" << nl << transforms_
<< exit(FatalError);
}
transforms_[nextTrans] = transform;
maxTol[nextTrans++] = cpp.matchTolerance();
}
if (nextTrans > 6)
{
FatalErrorIn
(
"void Foam::globalIndexAndTransform::"
"determineTransforms()"
)
<< "More than six unsigned transforms detected:"
<< nl << transforms_
<< exit(FatalError);
}
}
}
}
......@@ -206,21 +216,19 @@ void Foam::globalIndexAndTransform::determineTransforms()
) == 0
)
{
if (nextTrans == 6)
{
FatalErrorIn
(
"void Foam::globalIndexAndTransform::"
"determineTransforms()"
) << "More than six unsigned transforms"
<< " detected:" << nl << transforms_
<< exit(FatalError);
}
transforms_[nextTrans] = transform;
maxTol[nextTrans++] = cpp.matchTolerance();
}
if (nextTrans > 6)
{
FatalErrorIn
(
"void Foam::globalIndexAndTransform::"
"determineTransforms()"
)
<< "More than six unsigned transforms detected:"
<< nl << transforms_
<< exit(FatalError);
}
}
}
}
......@@ -363,7 +371,19 @@ void Foam::globalIndexAndTransform::determinePatchTransformSign()
// Pout<< nl << patchI << " " << pp.name() << endl;
if (isA<coupledPolyPatch>(pp))
// Note: special check for unordered cyclics. These are in fact
// transform bcs and should probably be split off.
if
(
isA<coupledPolyPatch>(pp)
&& !(
isA<cyclicPolyPatch>(pp)
&& (
refCast<const cyclicPolyPatch>(pp).transform()
== cyclicPolyPatch::NOORDERING
)
)
)
{
const coupledPolyPatch& cpp =
refCast<const coupledPolyPatch>(pp);
......
......@@ -267,85 +267,47 @@ Foam::label Foam::globalIndexAndTransform::addToTransformIndex
}
Foam::label Foam::globalIndexAndTransform::mergeTransformIndex
Foam::label Foam::globalIndexAndTransform::minimumTransformIndex
(
const label transformIndex0,
const label transformIndex1
) const
{
FixedList<label, 3> permutation0 = decodeTransformIndex(transformIndex0);
FixedList<label, 3> permutation1 = decodeTransformIndex(transformIndex1);
forAll(permutation0, i)
if (transformIndex0 == transformIndex1)
{
if (permutation0[i] == 0)
{
// Take over whatever sign 1 has
permutation0[i] = permutation1[i];
}
else if (permutation1[i] != 0 && permutation0[i] != permutation1[i])
{
FatalErrorIn
(
"Foam::label "
"Foam::globalIndexAndTransform::addToTransformIndex\n"
"(\n"
"const label,\n"
"const label\n"
") const\n"
) << "More than one patch accessing the same transform "
<< "but not of the same sign." << endl
<< "Trying to combine two transforms " << transformIndex0
<< " with signs " << permutation0
<< " and " << transformIndex1
<< " with signs " << permutation1
<< exit(FatalError);
}
return transformIndex0;
}
return encodeTransformIndex(permutation0);
}
Foam::label Foam::globalIndexAndTransform::minimumTransformIndex
(
const label transformIndex0,
const label transformIndex1
) const
{
// Count number of transforms
FixedList<label, 3> permutation0 = decodeTransformIndex(transformIndex0);
FixedList<label, 3> permutation1 = decodeTransformIndex(transformIndex1);
label n0 = 0;
forAll(permutation0, i)
{
if (permutation0[i] == 0)
if (permutation0[i] != 0)
{
// 0 wins.
n0++;
}
else if (permutation1[i] == 0)
}
FixedList<label, 3> permutation1 = decodeTransformIndex(transformIndex1);
label n1 = 0;
forAll(permutation1, i)
{
if (permutation1[i] != 0)
{
// 0 wins.
permutation0[i] = permutation1[i];
}
else if (permutation0[i] != permutation1[i])
{
FatalErrorIn
(
"Foam::label "
"Foam::globalIndexAndTransform::minimumTransformIndex\n"
"(\n"
"const label,\n"
"const label\n"
") const\n"
) << "More than one patch accessing the same transform "
<< "but not of the same sign." << endl
<< "Trying to combine two transforms " << transformIndex0
<< " with signs " << permutation0
<< " and " << transformIndex1
<< " with signs " << permutation1
<< exit(FatalError);
n1++;
}
}
return encodeTransformIndex(permutation0);
if (n0 <= n1)
{
return transformIndex0;
}
else
{
return transformIndex1;
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment