From 4616e059e4e4d87988d046ac5a7f332af6589609 Mon Sep 17 00:00:00 2001 From: Fuad Hasibul Hasan Date: Tue, 11 Feb 2025 15:13:02 -0500 Subject: [PATCH 1/3] calculate tol for search if given is not valid/negative - passing all tests except smoke_test_particle It is giving a warning for MPI oversubscribing and "Structure not initalized at Particle" --- src/pumipic_adjacency.tpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/pumipic_adjacency.tpp b/src/pumipic_adjacency.tpp index 86393847..6d97ec1d 100644 --- a/src/pumipic_adjacency.tpp +++ b/src/pumipic_adjacency.tpp @@ -466,7 +466,8 @@ namespace pumipic { o::Write& inter_points, int looplimit, bool debug, - Func& func) { + Func& func, + o::Real tol = -1.0) { static_assert( std::is_invocable_r_v< void, Func, o::Mesh &, ParticleStructure *, @@ -488,7 +489,10 @@ namespace pumipic { o::Write lastExit(psCapacity,-1, "search_last_exit"); const auto elmArea = measure_elements_real(&mesh); bool useBcc = !requireIntersection; - o::Real tol = compute_tolerance_from_area(elmArea); + + if (tol < 0) { + tol = compute_tolerance_from_area(elmArea); + } int rank; MPI_Comm_rank(mesh.comm()->get_impl(), &rank); From 05c485d57b5e8ce25541face0846df322d3dd395 Mon Sep 17 00:00:00 2001 From: Fuad Hasibul Hasan Date: Tue, 11 Feb 2025 15:31:08 -0500 Subject: [PATCH 2/3] pass tol as reference - passing all tests --- src/pumipic_adjacency.tpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/pumipic_adjacency.tpp b/src/pumipic_adjacency.tpp index 6d97ec1d..95032b7e 100644 --- a/src/pumipic_adjacency.tpp +++ b/src/pumipic_adjacency.tpp @@ -455,6 +455,7 @@ namespace pumipic { * @param looplimit Maximum number of iterations * @param debug True if debug information is printed * @param func Callable object to handle particles at element sides or destination + * @param tol Tolerance for intersection. If not positive, it is computed from the minimum element area * @return True if all particles are found at destination or left domain */ template @@ -467,7 +468,7 @@ namespace pumipic { int looplimit, bool debug, Func& func, - o::Real tol = -1.0) { + o::Real &tol) { static_assert( std::is_invocable_r_v< void, Func, o::Mesh &, ParticleStructure *, @@ -490,7 +491,7 @@ namespace pumipic { const auto elmArea = measure_elements_real(&mesh); bool useBcc = !requireIntersection; - if (tol < 0) { + if (tol <= 0.0) { tol = compute_tolerance_from_area(elmArea); } @@ -652,9 +653,9 @@ namespace pumipic { int looplimit, int debug) { RemoveParticleOnGeometricModelExit native_handler(mesh, requireIntersection); - + o::Real tol = -1.0; return trace_particle_through_mesh(mesh, ptcls, x_ps_orig, x_ps_tgt, pids, elem_ids, requireIntersection, - inter_faces, inter_points, looplimit, debug, native_handler); + inter_faces, inter_points, looplimit, debug, native_handler, tol); } } #endif From 996c9a3d0db8ecf14967263b8123f8a02938c1cf Mon Sep 17 00:00:00 2001 From: Fuad Hasibul Hasan Date: Wed, 12 Feb 2025 13:09:01 -0500 Subject: [PATCH 3/3] made tol optional instead of checking if tol was passed using negative values, it is made optional. In the future, tol will be calculated outside according to the standardization plan and for this reason, we don't need it to be passed as reference or pointer --- src/pumipic_adjacency.tpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/pumipic_adjacency.tpp b/src/pumipic_adjacency.tpp index 95032b7e..2a451c1e 100644 --- a/src/pumipic_adjacency.tpp +++ b/src/pumipic_adjacency.tpp @@ -455,7 +455,7 @@ namespace pumipic { * @param looplimit Maximum number of iterations * @param debug True if debug information is printed * @param func Callable object to handle particles at element sides or destination - * @param tol Tolerance for intersection. If not positive, it is computed from the minimum element area + * @param given_tol Tolerance for intersection. If not positive, it is computed from the minimum element area * @return True if all particles are found at destination or left domain */ template @@ -468,7 +468,7 @@ namespace pumipic { int looplimit, bool debug, Func& func, - o::Real &tol) { + std::optional given_tol = std::nullopt) { static_assert( std::is_invocable_r_v< void, Func, o::Mesh &, ParticleStructure *, @@ -491,8 +491,11 @@ namespace pumipic { const auto elmArea = measure_elements_real(&mesh); bool useBcc = !requireIntersection; - if (tol <= 0.0) { + o::Real tol = 0; + if (!given_tol.has_value()) { tol = compute_tolerance_from_area(elmArea); + } else { + tol = given_tol.value(); } int rank; @@ -653,9 +656,8 @@ namespace pumipic { int looplimit, int debug) { RemoveParticleOnGeometricModelExit native_handler(mesh, requireIntersection); - o::Real tol = -1.0; return trace_particle_through_mesh(mesh, ptcls, x_ps_orig, x_ps_tgt, pids, elem_ids, requireIntersection, - inter_faces, inter_points, looplimit, debug, native_handler, tol); + inter_faces, inter_points, looplimit, debug, native_handler); } } #endif