From c63b8f3229c20a1fa4840fd8bf694187e0dd6eac Mon Sep 17 00:00:00 2001 From: nmannall Date: Mon, 20 May 2024 15:16:59 +0100 Subject: [PATCH] Revert "Refactor AddGress UserObject build process" This reverts commit 1d7b5ff0f93505d9fecfb5d23fd1140de1dfe5c8. --- gprMax/cmds_geometry/add_grass.py | 11 +++++------ gprMax/fractals.py | 25 ++++++------------------- gprMax/model.py | 2 -- 3 files changed, 11 insertions(+), 27 deletions(-) diff --git a/gprMax/cmds_geometry/add_grass.py b/gprMax/cmds_geometry/add_grass.py index 256b22ab..fa263173 100644 --- a/gprMax/cmds_geometry/add_grass.py +++ b/gprMax/cmds_geometry/add_grass.py @@ -64,7 +64,7 @@ class AddGrass(UserObjectGeometry): self.kwargs["p1"] = tuple(rot_pts[0, :]) self.kwargs["p2"] = tuple(rot_pts[1, :]) - def build(self, model, uip): + def build(self, grid, uip): """Add Grass to fractal box.""" try: p1 = self.kwargs["p1"] @@ -91,7 +91,7 @@ class AddGrass(UserObjectGeometry): self._do_rotate() # Get the correct fractal volume - volumes = [volume for volume in model.fractalvolumes if volume.ID == fractal_box_id] + volumes = [volume for volume in grid.fractalvolumes if volume.ID == fractal_box_id] try: volume = volumes[0] except NameError: @@ -114,7 +114,6 @@ class AddGrass(UserObjectGeometry): raise ValueError # Check for valid orientations - grid = uip.grid if xs == xf: if ys == yf or zs == zf: logger.exception(f"{self.__str__()} dimensions are not specified correctly") @@ -250,11 +249,11 @@ class AddGrass(UserObjectGeometry): surface.grass.append(g) # Check to see if grass has been already defined as a material - if not any(x.ID == "grass" for x in model.materials): - create_grass(model) + if not any(x.ID == "grass" for x in grid.materials): + create_grass(grid) # Check if time step for model is suitable for using grass - grass = next((x for x in model.materials if x.ID == "grass")) + grass = next((x for x in grid.materials if x.ID == "grass")) testgrass = next((x for x in grass.tau if x < grid.dt), None) if testgrass: logger.exception( diff --git a/gprMax/fractals.py b/gprMax/fractals.py index 39b5048d..d2670a1f 100644 --- a/gprMax/fractals.py +++ b/gprMax/fractals.py @@ -16,8 +16,6 @@ # You should have received a copy of the GNU General Public License # along with gprMax. If not, see . -from typing import Optional, Tuple - import numpy as np from scipy import fftpack @@ -34,17 +32,7 @@ class FractalSurface: surfaceIDs = ["xminus", "xplus", "yminus", "yplus", "zminus", "zplus"] - def __init__( - self, - xs: float, - xf: float, - ys: float, - yf: float, - zs: float, - zf: float, - dimension: float, - seed: Optional[int] = None, - ): + def __init__(self, xs, xf, ys, yf, zs, zf, dimension, seed): """ Args: xs, xf, ys, yf, zs, zf: floats for the extent of the fractal surface @@ -55,9 +43,8 @@ class FractalSurface: seed: int for seed value for random number generator. """ - self.ID: str - self.surfaceID: str - self.operatingonID: str + self.ID = None + self.surfaceID = None self.xs = xs self.xf = xf self.ys = ys @@ -73,7 +60,7 @@ class FractalSurface: dimension # Fractal dimension from: http://dx.doi.org/10.1017/CBO9781139174695 ) self.weighting = np.array([1, 1], dtype=np.float64) - self.fractalrange: Tuple[int, int] = (0, 0) + self.fractalrange = (0, 0) self.filldepth = 0 self.grass = [] @@ -154,8 +141,8 @@ class FractalVolume: seed: int for seed value for random number generator. """ - self.ID: str - self.operatingonID: str + self.ID = None + self.operatingonID = None self.xs = xs self.xf = xf self.ys = ys diff --git a/gprMax/model.py b/gprMax/model.py index 7928bb20..496ecb88 100644 --- a/gprMax/model.py +++ b/gprMax/model.py @@ -26,7 +26,6 @@ import numpy as np import psutil from colorama import Fore, Style, init -from gprMax.fractals import FractalVolume from gprMax.grid.cuda_grid import CUDAGrid from gprMax.grid.opencl_grid import OpenCLGrid from gprMax.materials import ListMaterial, Material, PeplinskiSoil, RangeMaterial @@ -68,7 +67,6 @@ class Model: self.subgrids: List[SubGridBaseGrid] = [] self.mixingmodels: List[Union[PeplinskiSoil, RangeMaterial, ListMaterial]] = [] - self.fractalvolumes: List[FractalVolume] = [] self.geometryviews: List[GeometryView] = [] self.geometryobjects: List[GeometryObjects] = []