proper parallellisation of patch smoothing

This commit is contained in:
mattijs
2008-10-29 12:56:25 +00:00
parent 0f05c04153
commit 8c950850ba
2 changed files with 64 additions and 24 deletions

View File

@ -218,7 +218,8 @@ Foam::label Foam::autoSnapDriver::getCollocatedPoints
// Calculate displacement as average of patch points. // Calculate displacement as average of patch points.
Foam::pointField Foam::autoSnapDriver::smoothPatchDisplacement Foam::pointField Foam::autoSnapDriver::smoothPatchDisplacement
( (
const motionSmoother& meshMover const motionSmoother& meshMover,
const List<labelPair>& baffles
) const ) const
{ {
const indirectPrimitivePatch& pp = meshMover.patch(); const indirectPrimitivePatch& pp = meshMover.patch();
@ -253,6 +254,34 @@ Foam::pointField Foam::autoSnapDriver::smoothPatchDisplacement
const pointField& points = pp.points(); const pointField& points = pp.points();
const polyMesh& mesh = meshMover.mesh(); const polyMesh& mesh = meshMover.mesh();
// Get labels of faces to count (master of coupled faces and baffle pairs)
PackedList<1> isMasterFace(syncTools::getMasterFaces(mesh));
{
forAll(baffles, i)
{
label f0 = baffles[i].first();
label f1 = baffles[i].second();
if (isMasterFace.get(f0) == 1)
{
// Make f1 a slave
isMasterFace.set(f1, 0);
}
else if (isMasterFace.get(f1) == 1)
{
isMasterFace.set(f0, 0);
}
else
{
FatalErrorIn("autoSnapDriver::smoothPatchDisplacement(..)")
<< "Both sides of baffle consisting of faces " << f0
<< " and " << f1 << " are already slave faces."
<< abort(FatalError);
}
}
}
// Get average position of boundary face centres // Get average position of boundary face centres
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -266,9 +295,14 @@ Foam::pointField Foam::autoSnapDriver::smoothPatchDisplacement
forAll(pFaces, pfI) forAll(pFaces, pfI)
{ {
avgBoundary[patchPointI] += pp[pFaces[pfI]].centre(points); label faceI = pFaces[pfI];
if (isMasterFace.get(pp.addressing()[faceI]) == 1)
{
avgBoundary[patchPointI] += pp[faceI].centre(points);
nBoundary[patchPointI]++;
}
} }
nBoundary[patchPointI] = pFaces.size();
} }
syncTools::syncPointList syncTools::syncPointList
@ -886,7 +920,7 @@ void Foam::autoSnapDriver::preSmoothPatch
checkFaces[faceI] = faceI; checkFaces[faceI] = faceI;
} }
pointField patchDisp(smoothPatchDisplacement(meshMover)); pointField patchDisp(smoothPatchDisplacement(meshMover, baffles));
// The current mesh is the starting mesh to smooth from. // The current mesh is the starting mesh to smooth from.
meshMover.setDisplacement(patchDisp); meshMover.setDisplacement(patchDisp);
@ -1008,9 +1042,11 @@ Foam::vectorField Foam::autoSnapDriver::calcNearestSurface
// Displacement per patch point // Displacement per patch point
vectorField patchDisp(localPoints.size(), vector::zero); vectorField patchDisp(localPoints.size(), vector::zero);
if (returnReduce(localPoints.size(), sumOp<label>()) > 0) if (returnReduce(localPoints.size(), sumOp<label>()) > 0)
{ {
// Current surface snapped to
labelList snapSurf(localPoints.size(), -1);
// Divide surfaces into zoned and unzoned // Divide surfaces into zoned and unzoned
labelList zonedSurfaces; labelList zonedSurfaces;
labelList unzonedSurfaces; labelList unzonedSurfaces;
@ -1039,16 +1075,9 @@ Foam::vectorField Foam::autoSnapDriver::calcNearestSurface
patchDisp[pointI] = patchDisp[pointI] =
hitInfo[pointI].hitPoint() hitInfo[pointI].hitPoint()
- localPoints[pointI]; - localPoints[pointI];
snapSurf[pointI] = hitSurface[pointI];
} }
//else
//{
// WarningIn("autoSnapDriver::calcNearestSurface(..)")
// << "For point:" << pointI
// << " coordinate:" << localPoints[pointI]
// << " did not find any surface within:"
// << 4*snapDist[pointI]
// << " meter." << endl;
//}
} }
} }
@ -1060,6 +1089,7 @@ Foam::vectorField Foam::autoSnapDriver::calcNearestSurface
// Surfaces with zone information // Surfaces with zone information
const wordList& faceZoneNames = surfaces.faceZoneNames(); const wordList& faceZoneNames = surfaces.faceZoneNames();
// Current best snap distance
scalarField minSnapDist(snapDist); scalarField minSnapDist(snapDist);
forAll(zonedSurfaces, i) forAll(zonedSurfaces, i)
@ -1105,19 +1135,25 @@ Foam::vectorField Foam::autoSnapDriver::calcNearestSurface
minSnapDist[pointI], minSnapDist[pointI],
mag(patchDisp[pointI]) mag(patchDisp[pointI])
); );
snapSurf[pointI] = zoneSurfI;
} }
else }
}
// Check if all points are being snapped
forAll(snapSurf, pointI)
{
if (snapSurf[pointI] == -1)
{ {
WarningIn("autoSnapDriver::calcNearestSurface(..)") WarningIn("autoSnapDriver::calcNearestSurface(..)")
<< "For point:" << pointI << "For point:" << pointI
<< " coordinate:" << localPoints[pointI] << " coordinate:" << localPoints[pointI]
<< " did not find any surface within:" << " did not find any surface within:"
<< 4*minSnapDist[pointI] << minSnapDist[pointI]
<< " meter." << endl; << " meter." << endl;
} }
} }
}
{ {
scalarField magDisp(mag(patchDisp)); scalarField magDisp(mag(patchDisp));

View File

@ -100,7 +100,11 @@ class autoSnapDriver
//- Calculate displacement per patch point to smooth out patch. //- Calculate displacement per patch point to smooth out patch.
// Quite complicated in determining which points to move where. // Quite complicated in determining which points to move where.
pointField smoothPatchDisplacement(const motionSmoother&) const; pointField smoothPatchDisplacement
(
const motionSmoother&,
const List<labelPair>&
) const;
//- Check that face zones are synced //- Check that face zones are synced
void checkCoupledFaceZones() const; void checkCoupledFaceZones() const;