From 48fdec46c7bdc2337be558aae956adce1746c8a2 Mon Sep 17 00:00:00 2001 From: sergio Date: Mon, 15 Feb 2021 12:20:02 -0800 Subject: [PATCH] BUG: Improving robustness of tracking on cells with detA zero 1) Small modification to the tracking logic for detA zero. 2) Adding small vector displacement to locate function to avoid error where particle is inserted at the cell centre. --- src/lagrangian/basic/particle/particle.C | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/lagrangian/basic/particle/particle.C b/src/lagrangian/basic/particle/particle.C index dbb6fe2d2c..c4d4382873 100644 --- a/src/lagrangian/basic/particle/particle.C +++ b/src/lagrangian/basic/particle/particle.C @@ -432,7 +432,12 @@ void Foam::particle::locate } } - const vector displacement = position - mesh_.cellCentres()[celli_]; + // Perturbing displacement to avoid zero in case position is the + // cellCentre + const vector displacement = + position + - mesh_.cellCentres()[celli_] + + vector(VSMALL, VSMALL, VSMALL); // Loop all cell tets to find the one containing the position. Track // through each tet from the cell centre. If a tet contains the position @@ -748,7 +753,7 @@ Foam::scalar Foam::particle::trackToStationaryTri // Calculate the hit fraction label iH = -1; - scalar muH = std::isnormal(detA) && detA <= 0 ? VGREAT : 1/detA; + scalar muH = detA <= 0 ? VGREAT : 1/detA; for (label i = 0; i < 4; ++ i) { if (Tx1[i] < - detA*SMALL) @@ -903,7 +908,7 @@ Foam::scalar Foam::particle::trackToMovingTri // Calculate the hit fraction label iH = -1; - scalar muH = std::isnormal(detA[0]) && detA[0] <= 0 ? VGREAT : 1/detA[0]; + scalar muH = detA[0] <= 0 ? VGREAT : 1/detA[0]; for (label i = 0; i < 4; ++i) { const Roots<3> mu = hitEqn[i].roots();