mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
lagrangian: Simplification of parallel transfer
This commit is contained in:
committed by
Andrew Heather
parent
241879ecf4
commit
22bd391903
@ -264,38 +264,41 @@ void Foam::Cloud<ParticleType>::move
|
||||
// (i.e. it hasn't passed through an inlet or outlet)
|
||||
if (keepParticle)
|
||||
{
|
||||
// If we are running in parallel and the particle is on a
|
||||
// boundary face
|
||||
if
|
||||
(
|
||||
Pstream::parRun()
|
||||
&& td.switchProcessor
|
||||
&& p.face() >= pMesh().nInternalFaces()
|
||||
)
|
||||
if (td.switchProcessor)
|
||||
{
|
||||
label patchi = pbm.whichPatch(p.face());
|
||||
|
||||
// ... and the face is on a processor patch
|
||||
// prepare it for transfer
|
||||
if (procPatchIndices[patchi] != -1)
|
||||
#ifdef FULLDEBUG
|
||||
if
|
||||
(
|
||||
!Pstream::parRun()
|
||||
|| !p.onBoundaryFace()
|
||||
|| procPatchIndices[p.patch()] < 0
|
||||
)
|
||||
{
|
||||
label n = neighbourProcIndices
|
||||
[
|
||||
refCast<const processorPolyPatch>
|
||||
(
|
||||
pbm[patchi]
|
||||
).neighbProcNo()
|
||||
];
|
||||
|
||||
p.prepareForParallelTransfer(patchi, cloud, td);
|
||||
|
||||
particleTransferLists[n].append(this->remove(&p));
|
||||
|
||||
patchIndexTransferLists[n].append
|
||||
(
|
||||
procPatchNeighbours[patchi]
|
||||
);
|
||||
FatalErrorInFunction
|
||||
<< "Switch processor flag is true when no parallel "
|
||||
<< "transfer is possible. This is a bug."
|
||||
<< exit(FatalError);
|
||||
}
|
||||
#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
|
||||
@ -380,7 +383,7 @@ void Foam::Cloud<ParticleType>::move
|
||||
|
||||
label patchi = procPatches[receivePatchIndex[pI++]];
|
||||
|
||||
newp.correctAfterParallelTransfer(patchi, cloud, td);
|
||||
newp.correctAfterParallelTransfer(patchi, td);
|
||||
|
||||
addParticle(newParticles.remove(&newp));
|
||||
}
|
||||
|
||||
@ -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
|
||||
(
|
||||
const vectorTensorTransform& transform
|
||||
|
||||
@ -661,25 +661,12 @@ public:
|
||||
|
||||
// Parallel transfer
|
||||
|
||||
//- Convert global addressing to the processor patch
|
||||
// local equivalents
|
||||
template<class TrackCloudType>
|
||||
void prepareForParallelTransfer
|
||||
(
|
||||
const label patchi,
|
||||
TrackCloudType& cloud,
|
||||
trackingData& td
|
||||
);
|
||||
//- Convert global addressing to the processor patch local equivalents
|
||||
void prepareForParallelTransfer();
|
||||
|
||||
//- Convert processor patch addressing to the global equivalents
|
||||
// and set the celli to the face-neighbour
|
||||
template<class TrackCloudType>
|
||||
void correctAfterParallelTransfer
|
||||
(
|
||||
const label patchi,
|
||||
TrackCloudType& cloud,
|
||||
trackingData& td
|
||||
);
|
||||
void correctAfterParallelTransfer(const label patchi, trackingData& td);
|
||||
|
||||
|
||||
// Interaction list referral
|
||||
|
||||
@ -35,72 +35,6 @@ License
|
||||
#include "wedgePolyPatch.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 * * * * * * * * * * * * * //
|
||||
|
||||
template<class TrackCloudType>
|
||||
|
||||
@ -264,11 +264,10 @@ void Foam::trackedParticle::hitPatch
|
||||
void Foam::trackedParticle::correctAfterParallelTransfer
|
||||
(
|
||||
const label patchi,
|
||||
Cloud<trackedParticle>& cloud,
|
||||
trackingData& td
|
||||
)
|
||||
{
|
||||
particle::correctAfterParallelTransfer(patchi, cloud, td);
|
||||
particle::correctAfterParallelTransfer(patchi, td);
|
||||
|
||||
label edgeI = k();
|
||||
if (edgeI != -1)
|
||||
|
||||
@ -326,12 +326,7 @@ public:
|
||||
|
||||
//- Convert processor patch addressing to the global equivalents
|
||||
// and set the celli to the face-neighbour
|
||||
void correctAfterParallelTransfer
|
||||
(
|
||||
const label,
|
||||
Cloud<trackedParticle>& cloud,
|
||||
trackingData& td
|
||||
);
|
||||
void correctAfterParallelTransfer(const label, trackingData& td);
|
||||
|
||||
|
||||
// Ostream Operator
|
||||
|
||||
Reference in New Issue
Block a user