From 6fbb94f058fc8e8e830894e8e562fd2414654e74 Mon Sep 17 00:00:00 2001 From: Nathan Mannall Date: Fri, 21 Feb 2025 10:37:20 +0000 Subject: [PATCH] Fix bug when Edge or Plate is in a positive halo Edges and plates are no longer built in the positive halo as they are not needed. Previously this caused a memory corruption as the cython functions were performing out of bounds memory access in the rigidE and rigidH arrays. --- gprMax/user_inputs.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gprMax/user_inputs.py b/gprMax/user_inputs.py index d805a2f3..1f712bbf 100644 --- a/gprMax/user_inputs.py +++ b/gprMax/user_inputs.py @@ -173,7 +173,7 @@ class MainGridUserInput(UserInput[GridType]): lower_within_grid, lower_point = self.check_point(p1, cmd_str, "lower") upper_within_grid, upper_point = self.check_point(p2, cmd_str, "upper") - if np.greater(lower_point, upper_point).any(): + if np.greater(lower_point, upper_point).any() or np.equal(lower_point, upper_point).all(): raise ValueError( f"'{cmd_str}' the lower coordinates should be less than the upper coordinates." ) @@ -296,7 +296,11 @@ class MPIUserInput(MainGridUserInput[MPIGrid]): lower_point = np.where(lower_point < 0, 0, lower_point) upper_point = np.where(upper_point > self.grid.size, self.grid.size, upper_point) - return all(lower_point <= upper_point), lower_point, upper_point + return ( + all(lower_point <= upper_point) and all(lower_point < self.grid.size), + lower_point, + upper_point, + ) class SubgridUserInput(MainGridUserInput[SubGridBaseGrid]):