BUG: snappyHexMesh: synchronisation when patch edges align with processor edges

This commit is contained in:
mattijs
2013-01-16 17:08:26 +00:00
parent 376f60b844
commit 868a090243
3 changed files with 245 additions and 50 deletions

View File

@ -43,6 +43,30 @@ Foam::scalar Foam::PointEdgeWave<Type, TrackingData>::propagationTol_ = 0.01;
template <class Type, class TrackingData>
int Foam::PointEdgeWave<Type, TrackingData>::dummyTrackData_ = 12345;
namespace Foam
{
//- Reduction class. If x and y are not equal assign value.
template<class Type, class TrackingData>
class combineEqOp
{
TrackingData& td_;
public:
combineEqOp(TrackingData& td)
:
td_(td)
{}
void operator()(Type& x, const Type& y) const
{
if (!x.valid(td_) && y.valid(td_))
{
x = y;
}
}
};
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
@ -325,12 +349,12 @@ void Foam::PointEdgeWave<Type, TrackingData>::handleProcPatches()
// Adapt for leaving domain
leaveDomain(procPatch, thisPoints, patchInfo);
if (debug)
{
Pout<< "Processor patch " << patchI << ' ' << procPatch.name()
<< " communicating with " << procPatch.neighbProcNo()
<< " Sending:" << patchInfo.size() << endl;
}
//if (debug)
//{
// Pout<< "Processor patch " << patchI << ' ' << procPatch.name()
// << " communicating with " << procPatch.neighbProcNo()
// << " Sending:" << patchInfo.size() << endl;
//}
UOPstream toNeighbour(procPatch.neighbProcNo(), pBufs);
toNeighbour << nbrPoints << patchInfo;
@ -357,12 +381,12 @@ void Foam::PointEdgeWave<Type, TrackingData>::handleProcPatches()
fromNeighbour >> patchPoints >> patchInfo;
}
if (debug)
{
Pout<< "Processor patch " << patchI << ' ' << procPatch.name()
<< " communicating with " << procPatch.neighbProcNo()
<< " Received:" << patchInfo.size() << endl;
}
//if (debug)
//{
// Pout<< "Processor patch " << patchI << ' ' << procPatch.name()
// << " communicating with " << procPatch.neighbProcNo()
// << " Received:" << patchInfo.size() << endl;
//}
// Apply transform to received data for non-parallel planes
if (!procPatch.parallel())
@ -492,12 +516,12 @@ void Foam::PointEdgeWave<Type, TrackingData>::handleCyclicPatches()
transform(cycPatch, cycPatch.forwardT(), nbrInfo);
}
if (debug)
{
Pout<< "Cyclic patch " << patchI << ' ' << patch.name()
<< " Changed : " << nbrInfo.size()
<< endl;
}
//if (debug)
//{
// Pout<< "Cyclic patch " << patchI << ' ' << patch.name()
// << " Changed : " << nbrInfo.size()
// << endl;
//}
// Adapt for entering domain
enterDomain(cycPatch, thisPoints, nbrInfo);
@ -523,7 +547,8 @@ void Foam::PointEdgeWave<Type, TrackingData>::handleCyclicPatches()
}
// Propagate information from edge to point. Return number of points changed.
// Guarantee collocated points have same information.
// Return number of points changed.
template <class Type, class TrackingData>
Foam::label Foam::PointEdgeWave<Type, TrackingData>::handleCollocatedPoints()
{
@ -541,30 +566,22 @@ Foam::label Foam::PointEdgeWave<Type, TrackingData>::handleCollocatedPoints()
elems[pointI] = allPointInfo_[meshPoints[pointI]];
}
// Reset changed points counter.
nChangedPoints_ = 0;
// Pull slave data onto master. No need to update transformed slots.
slavesMap.distribute(elems, false);
// Combine master data with slave data
combineEqOp<Type, TrackingData> cop(td_);
forAll(slaves, pointI)
{
Type& elem = elems[pointI];
const labelList& slavePoints = slaves[pointI];
label meshPointI = meshPoints[pointI];
// Combine master with untransformed slave data
forAll(slavePoints, j)
{
updatePoint
(
meshPointI,
elems[slavePoints[j]],
elem
);
cop(elem, elems[slavePoints[j]]);
}
// Copy result back to slave slots
@ -580,7 +597,28 @@ Foam::label Foam::PointEdgeWave<Type, TrackingData>::handleCollocatedPoints()
// Extract back onto mesh
forAll(meshPoints, pointI)
{
allPointInfo_[meshPoints[pointI]] = elems[pointI];
Type& elem = allPointInfo_[meshPoints[pointI]];
// Like updatePoint but bypass Type::updatePoint with its tolerance
// checking
if (!elem.valid(td_) || !elem.equal(elems[pointI], td_))
{
nEvals_++;
elem = elems[pointI];
// See if element now valid
if (elem.valid(td_))
{
--nUnvisitedPoints_;
}
// Update database of changed points
if (!changedPoint_[pointI])
{
changedPoint_[pointI] = true;
changedPoints_[nChangedPoints_++] = pointI;
}
}
}
// Sum nChangedPoints over all procs
@ -658,7 +696,8 @@ Foam::PointEdgeWave<Type, TrackingData>::PointEdgeWave
if (debug)
{
Pout<< "Seed points : " << nChangedPoints_ << endl;
Info<< typeName << ": Seed points : "
<< returnReduce(nChangedPoints_, sumOp<label>()) << endl;
}
// Iterate until nothing changes
@ -761,6 +800,9 @@ void Foam::PointEdgeWave<Type, TrackingData>::setPointInfo
changedPoints_[nChangedPoints_++] = pointI;
}
}
// Sync
handleCollocatedPoints();
}
@ -826,10 +868,10 @@ Foam::label Foam::PointEdgeWave<Type, TrackingData>::edgeToPoint()
handleProcPatches();
}
if (debug)
{
Pout<< "Changed points : " << nChangedPoints_ << endl;
}
//if (debug)
//{
// Pout<< "Changed points : " << nChangedPoints_ << endl;
//}
// Sum nChangedPoints over all procs
label totNChanged = nChangedPoints_;
@ -894,10 +936,10 @@ Foam::label Foam::PointEdgeWave<Type, TrackingData>::pointToEdge()
// Handled all changed points by now
nChangedPoints_ = 0;
if (debug)
{
Pout<< "Changed edges : " << nChangedEdges_ << endl;
}
//if (debug)
//{
// Pout<< "Changed edges : " << nChangedEdges_ << endl;
//}
// Sum nChangedPoints over all procs
label totNChanged = nChangedEdges_;
@ -936,14 +978,15 @@ Foam::label Foam::PointEdgeWave<Type, TrackingData>::iterate
{
if (debug)
{
Pout<< "Iteration " << iter << endl;
Info<< typeName << ": Iteration " << iter << endl;
}
label nEdges = pointToEdge();
if (debug)
{
Pout<< "Total changed edges : " << nEdges << endl;
Info<< typeName << ": Total changed edges : "
<< nEdges << endl;
}
if (nEdges == 0)
@ -955,10 +998,14 @@ Foam::label Foam::PointEdgeWave<Type, TrackingData>::iterate
if (debug)
{
Pout<< "Total changed points : " << nPoints << nl
<< "Total evaluations : " << nEvals_ << nl
<< "Remaining unvisited points: " << nUnvisitedPoints_ << nl
<< "Remaining unvisited edges : " << nUnvisitedEdges_ << nl
Info<< typeName << ": Total changed points : "
<< nPoints << nl
<< typeName << ": Total evaluations : "
<< returnReduce(nEvals_, sumOp<label>()) << nl
<< typeName << ": Remaining unvisited points: "
<< returnReduce(nUnvisitedPoints_, sumOp<label>()) << nl
<< typeName << ": Remaining unvisited edges : "
<< returnReduce(nUnvisitedEdges_, sumOp<label>()) << nl
<< endl;
}
@ -976,8 +1023,8 @@ Foam::label Foam::PointEdgeWave<Type, TrackingData>::iterate
label nPoints = handleCollocatedPoints();
if (debug)
{
Pout<< "Collocated point sync : " << nPoints << nl
<< endl;
Info<< typeName << ": Collocated point sync : "
<< nPoints << nl << endl;
}
if (nPoints == 0)