lagrangian: Simplification of parallel transfer

This commit is contained in:
Will Bainbridge
2017-08-22 17:57:11 +01:00
committed by Andrew Heather
parent 241879ecf4
commit 22bd391903
6 changed files with 94 additions and 120 deletions

View File

@ -264,38 +264,41 @@ void Foam::Cloud<ParticleType>::move
// (i.e. it hasn't passed through an inlet or outlet) // (i.e. it hasn't passed through an inlet or outlet)
if (keepParticle) if (keepParticle)
{ {
// If we are running in parallel and the particle is on a if (td.switchProcessor)
// boundary face
if
(
Pstream::parRun()
&& td.switchProcessor
&& p.face() >= pMesh().nInternalFaces()
)
{ {
label patchi = pbm.whichPatch(p.face()); #ifdef FULLDEBUG
if
// ... and the face is on a processor patch (
// prepare it for transfer !Pstream::parRun()
if (procPatchIndices[patchi] != -1) || !p.onBoundaryFace()
|| procPatchIndices[p.patch()] < 0
)
{ {
label n = neighbourProcIndices FatalErrorInFunction
[ << "Switch processor flag is true when no parallel "
refCast<const processorPolyPatch> << "transfer is possible. This is a bug."
( << exit(FatalError);
pbm[patchi]
).neighbProcNo()
];
p.prepareForParallelTransfer(patchi, cloud, td);
particleTransferLists[n].append(this->remove(&p));
patchIndexTransferLists[n].append
(
procPatchNeighbours[patchi]
);
} }
#endif
const label patchi = p.patch();
const label n = neighbourProcIndices
[
refCast<const processorPolyPatch>
(
pbm[patchi]
).neighbProcNo()
];
p.prepareForParallelTransfer();
particleTransferLists[n].append(this->remove(&p));
patchIndexTransferLists[n].append
(
procPatchNeighbours[patchi]
);
} }
} }
else else
@ -380,7 +383,7 @@ void Foam::Cloud<ParticleType>::move
label patchi = procPatches[receivePatchIndex[pI++]]; label patchi = procPatches[receivePatchIndex[pI++]];
newp.correctAfterParallelTransfer(patchi, cloud, td); newp.correctAfterParallelTransfer(patchi, td);
addParticle(newParticles.remove(&newp)); addParticle(newParticles.remove(&newp));
} }

View File

@ -1024,6 +1024,62 @@ Foam::scalar Foam::particle::wallImpactDistance(const vector&) const
} }
void Foam::particle::prepareForParallelTransfer()
{
// Convert the face index to be local to the processor patch
facei_ = mesh_.boundaryMesh()[patch()].whichFace(facei_);
}
void Foam::particle::correctAfterParallelTransfer
(
const label patchi,
trackingData& td
)
{
const coupledPolyPatch& ppp =
refCast<const coupledPolyPatch>(mesh_.boundaryMesh()[patchi]);
if (!ppp.parallel())
{
const tensor& T =
(
ppp.forwardT().size() == 1
? ppp.forwardT()[0]
: ppp.forwardT()[facei_]
);
transformProperties(T);
}
else if (ppp.separated())
{
const vector& s =
(
(ppp.separation().size() == 1)
? ppp.separation()[0]
: ppp.separation()[facei_]
);
transformProperties(-s);
}
// Set the topology
celli_ = ppp.faceCells()[facei_];
facei_ += ppp.start();
tetFacei_ = facei_;
// Faces either side of a coupled patch are numbered in opposite directions
// as their normals both point away from their connected cells. The tet
// point therefore counts in the opposite direction from the base point.
tetPti_ = mesh_.faces()[tetFacei_].size() - 1 - tetPti_;
// Reflect to account for the change of triangle orientation in the new cell
reflect();
// Note that the position does not need transforming explicitly. The face-
// triangle on the receive patch is the transformation of the one on the
// send patch, so whilst the barycentric coordinates remain the same, the
// change of triangle implicitly transforms the position.
}
void Foam::particle::prepareForInteractionListReferral void Foam::particle::prepareForInteractionListReferral
( (
const vectorTensorTransform& transform const vectorTensorTransform& transform

View File

@ -661,25 +661,12 @@ public:
// Parallel transfer // Parallel transfer
//- Convert global addressing to the processor patch //- Convert global addressing to the processor patch local equivalents
// local equivalents void prepareForParallelTransfer();
template<class TrackCloudType>
void prepareForParallelTransfer
(
const label patchi,
TrackCloudType& cloud,
trackingData& td
);
//- Convert processor patch addressing to the global equivalents //- Convert processor patch addressing to the global equivalents
// and set the celli to the face-neighbour // and set the celli to the face-neighbour
template<class TrackCloudType> void correctAfterParallelTransfer(const label patchi, trackingData& td);
void correctAfterParallelTransfer
(
const label patchi,
TrackCloudType& cloud,
trackingData& td
);
// Interaction list referral // Interaction list referral

View File

@ -35,72 +35,6 @@ License
#include "wedgePolyPatch.H" #include "wedgePolyPatch.H"
#include "meshTools.H" #include "meshTools.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class TrackCloudType>
void Foam::particle::prepareForParallelTransfer
(
const label patchi,
TrackCloudType& cloud,
trackingData& td
)
{
// Convert the face index to be local to the processor patch
facei_ = mesh_.boundaryMesh()[patchi].whichFace(facei_);
}
template<class TrackCloudType>
void Foam::particle::correctAfterParallelTransfer
(
const label patchi,
TrackCloudType& cloud,
trackingData& td
)
{
const coupledPolyPatch& ppp =
refCast<const coupledPolyPatch>(mesh_.boundaryMesh()[patchi]);
if (!ppp.parallel())
{
const tensor& T =
(
ppp.forwardT().size() == 1
? ppp.forwardT()[0]
: ppp.forwardT()[facei_]
);
transformProperties(T);
}
else if (ppp.separated())
{
const vector& s =
(
(ppp.separation().size() == 1)
? ppp.separation()[0]
: ppp.separation()[facei_]
);
transformProperties(-s);
}
// Set the topology
celli_ = ppp.faceCells()[facei_];
facei_ += ppp.start();
tetFacei_ = facei_;
// Faces either side of a coupled patch are numbered in opposite directions
// as their normals both point away from their connected cells. The tet
// point therefore counts in the opposite direction from the base point.
tetPti_ = mesh_.faces()[tetFacei_].size() - 1 - tetPti_;
// Reflect to account for the change of triangle orientation in the new cell
reflect();
// Note that the position does not need transforming explicitly. The face-
// triangle on the receive patch is the transformation of the one on the
// send patch, so whilst the barycentric coordinates remain the same, the
// change of triangle implicitly transforms the position.
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class TrackCloudType> template<class TrackCloudType>

View File

@ -264,11 +264,10 @@ void Foam::trackedParticle::hitPatch
void Foam::trackedParticle::correctAfterParallelTransfer void Foam::trackedParticle::correctAfterParallelTransfer
( (
const label patchi, const label patchi,
Cloud<trackedParticle>& cloud,
trackingData& td trackingData& td
) )
{ {
particle::correctAfterParallelTransfer(patchi, cloud, td); particle::correctAfterParallelTransfer(patchi, td);
label edgeI = k(); label edgeI = k();
if (edgeI != -1) if (edgeI != -1)

View File

@ -326,12 +326,7 @@ public:
//- Convert processor patch addressing to the global equivalents //- Convert processor patch addressing to the global equivalents
// and set the celli to the face-neighbour // and set the celli to the face-neighbour
void correctAfterParallelTransfer void correctAfterParallelTransfer(const label, trackingData& td);
(
const label,
Cloud<trackedParticle>& cloud,
trackingData& td
);
// Ostream Operator // Ostream Operator