diff --git a/src/lagrangian/basic/particle/particle.C b/src/lagrangian/basic/particle/particle.C index 3c04ec9c5958e87a0bb357ba9452d49cb17d14dc..2cd179b12c7443aa38d90d5ce8dd80e5995a1742 100644 --- a/src/lagrangian/basic/particle/particle.C +++ b/src/lagrangian/basic/particle/particle.C @@ -435,6 +435,40 @@ void Foam::particle::changeCell() } +void Foam::particle::changeToMasterPatch() +{ + label thisPatch = patch(); + + forAll(mesh_.cells()[celli_], cellFaceI) + { + // Skip the current face and any internal faces + const label otherFaceI = mesh_.cells()[celli_][cellFaceI]; + if (facei_ == otherFaceI || mesh_.isInternalFace(otherFaceI)) + { + continue; + } + + // Compare the two faces. If they are the same, chose the one with the + // lower patch index. In the case of an ACMI-wall pair, this will be + // the ACMI, which is what we want. + const class face& thisFace = mesh_.faces()[facei_]; + const class face& otherFace = mesh_.faces()[otherFaceI]; + if (face::compare(thisFace, otherFace) != 0) + { + const label otherPatch = + mesh_.boundaryMesh().whichPatch(otherFaceI); + if (thisPatch > otherPatch) + { + facei_ = otherFaceI; + thisPatch = otherPatch; + } + } + } + + tetFacei_ = facei_; +} + + void Foam::particle::locate ( const vector& position, diff --git a/src/lagrangian/basic/particle/particle.H b/src/lagrangian/basic/particle/particle.H index 3a6f8213efe497c5a835f3636958e898dc66b423..37d6031df49b2cd8f60c40ad2f0ea31a541342ec 100644 --- a/src/lagrangian/basic/particle/particle.H +++ b/src/lagrangian/basic/particle/particle.H @@ -278,6 +278,13 @@ private: //- Change cell. Called when the particle hits an internal face. void changeCell(); + //- Put the particle on the lowest indexed patch for the current set + // of coincident faces. In the case of an ACMI-wall pair, this will + // move the particle from the wall face to the ACMI face, because + // ACMI patches are always listed before their associated non- + // overlapping patch. + void changeToMasterPatch(); + // Geometry changes diff --git a/src/lagrangian/basic/particle/particleTemplates.C b/src/lagrangian/basic/particle/particleTemplates.C index 307dcafff40fe87a1c340d833d660a8e250058a7..6ce265dd87869cd8495db1230c86f0d726e1a3f4 100644 --- a/src/lagrangian/basic/particle/particleTemplates.C +++ b/src/lagrangian/basic/particle/particleTemplates.C @@ -206,32 +206,21 @@ void Foam::particle::hitFace typename TrackData::cloudType::particleType& p = static_cast<typename TrackData::cloudType::particleType&>(*this); - // No action is taken for tetPti_ for tetFacei_ here. These are handled - // by the patch interaction call or later during processor transfer. - - const label origFacei = facei_; - label patchi = mesh_.boundaryMesh().whichPatch(facei_); const tetIndices faceHitTetIs(celli_, tetFacei_, tetPti_); if ( !p.hitPatch ( - mesh_.boundaryMesh()[patchi], + mesh_.boundaryMesh()[patch()], td, - patchi, + patch(), stepFraction(), faceHitTetIs ) ) { - // Did patch interaction model switch patches? - if (facei_ != origFacei) - { - patchi = mesh_.boundaryMesh().whichPatch(facei_); - } - - const polyPatch& patch = mesh_.boundaryMesh()[patchi]; + const polyPatch& patch = mesh_.boundaryMesh()[this->patch()]; if (isA<wedgePolyPatch>(patch)) { @@ -311,6 +300,12 @@ void Foam::particle::trackToAndHitFace ) { trackToFace(direction, fraction); + + if (onBoundaryFace()) + { + changeToMasterPatch(); + } + hitFace(direction, td); }