From afa971e4d60e6a67ff1430167b65ec360bfccd57 Mon Sep 17 00:00:00 2001 From: jasminium Date: Mon, 4 Jan 2021 18:21:05 +0100 Subject: [PATCH] report box geometry in subgrid relative to main grid --- gprMax/cmds_geometry/box.py | 12 ++++++++---- gprMax/user_inputs.py | 10 ++++++++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/gprMax/cmds_geometry/box.py b/gprMax/cmds_geometry/box.py index cddad936..5094cd48 100644 --- a/gprMax/cmds_geometry/box.py +++ b/gprMax/cmds_geometry/box.py @@ -91,9 +91,12 @@ class Box(UserObjectGeometry): # if they havent specfied - go with the grid default averagebox = grid.averagevolumeobjects - p1, p2 = uip.check_box_points(p1, p2, self.__str__()) - xs, ys, zs = p1 - xf, yf, zf = p2 + p3, p4 = uip.check_box_points(p1, p2, self.__str__()) + # find nearest point on grid without translation + p5 = uip.round_to_grid_static_point(p1) + p6 = uip.round_to_grid_static_point(p2) + xs, ys, zs = p3 + xf, yf, zf = p4 # Look up requested materials in existing list of material instances materials = [y for x in materialsrequested for y in grid.materials if y.ID == x] @@ -134,4 +137,5 @@ class Box(UserObjectGeometry): build_box(xs, xf, ys, yf, zs, zf, numID, numIDx, numIDy, numIDz, averaging, grid.solid, grid.rigidE, grid.rigidH, grid.ID) dielectricsmoothing = 'on' if averaging else 'off' - logger.info(self.grid_name(grid) + f"Box from {xs * grid.dx:g}m, {ys * grid.dy:g}m, {zs * grid.dz:g}m, to {xf * grid.dx:g}m, {yf * grid.dy:g}m, {zf * grid.dz:g}m of material(s) {', '.join(materialsrequested)} created, dielectric smoothing is {dielectricsmoothing}.") + + logger.info(self.grid_name(grid) + f"Box from {p5[0]:g}m, {p5[1]:g}m, {p5[2]:g}m, to {p6[0]:g}m, {p6[1]:g}m, {p6[2]:g}m of material(s) {', '.join(materialsrequested)} created, dielectric smoothing is {dielectricsmoothing}.") diff --git a/gprMax/user_inputs.py b/gprMax/user_inputs.py index f5b90af6..8d4c3a84 100644 --- a/gprMax/user_inputs.py +++ b/gprMax/user_inputs.py @@ -126,6 +126,11 @@ class MainGridUserInput(UserInput): """Function to get the index of a continuous point regardless of the point of origin of the grid.""" return super().discretise_point(p) + def round_to_grid_static_point(self, p): + """Function to get the index of a continuous point regardless of the point of origin of the grid.""" + return super().discretise_point(p) * self.grid.dl + + class SubgridUserInput(MainGridUserInput): """Class to handle (x, y, z) points supplied by the user in the sub grid. This class autotranslates points from main grid to subgrid equivalent @@ -182,4 +187,9 @@ class SubgridUserInput(MainGridUserInput): def discretise_static_point(self, p): """Function to get the index of a continuous point regardless of the point of origin of the grid.""" return super().discretise_point(p) + + def round_to_grid_static_point(self, p): + """Function to get the index of a continuous point regardless of the point of origin of the grid.""" + return super().discretise_point(p) * self.grid.dl +