Revert "Refactor AddGress UserObject build process"

This reverts commit 1d7b5ff0f9.
这个提交包含在:
nmannall
2024-05-20 15:16:59 +01:00
父节点 672dd44094
当前提交 c63b8f3229
共有 3 个文件被更改,包括 11 次插入27 次删除

查看文件

@@ -64,7 +64,7 @@ class AddGrass(UserObjectGeometry):
self.kwargs["p1"] = tuple(rot_pts[0, :]) self.kwargs["p1"] = tuple(rot_pts[0, :])
self.kwargs["p2"] = tuple(rot_pts[1, :]) self.kwargs["p2"] = tuple(rot_pts[1, :])
def build(self, model, uip): def build(self, grid, uip):
"""Add Grass to fractal box.""" """Add Grass to fractal box."""
try: try:
p1 = self.kwargs["p1"] p1 = self.kwargs["p1"]
@@ -91,7 +91,7 @@ class AddGrass(UserObjectGeometry):
self._do_rotate() self._do_rotate()
# Get the correct fractal volume # 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: try:
volume = volumes[0] volume = volumes[0]
except NameError: except NameError:
@@ -114,7 +114,6 @@ class AddGrass(UserObjectGeometry):
raise ValueError raise ValueError
# Check for valid orientations # Check for valid orientations
grid = uip.grid
if xs == xf: if xs == xf:
if ys == yf or zs == zf: if ys == yf or zs == zf:
logger.exception(f"{self.__str__()} dimensions are not specified correctly") logger.exception(f"{self.__str__()} dimensions are not specified correctly")
@@ -250,11 +249,11 @@ class AddGrass(UserObjectGeometry):
surface.grass.append(g) surface.grass.append(g)
# Check to see if grass has been already defined as a material # Check to see if grass has been already defined as a material
if not any(x.ID == "grass" for x in model.materials): if not any(x.ID == "grass" for x in grid.materials):
create_grass(model) create_grass(grid)
# Check if time step for model is suitable for using grass # 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) testgrass = next((x for x in grass.tau if x < grid.dt), None)
if testgrass: if testgrass:
logger.exception( logger.exception(

查看文件

@@ -16,8 +16,6 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with gprMax. If not, see <http://www.gnu.org/licenses/>. # along with gprMax. If not, see <http://www.gnu.org/licenses/>.
from typing import Optional, Tuple
import numpy as np import numpy as np
from scipy import fftpack from scipy import fftpack
@@ -34,17 +32,7 @@ class FractalSurface:
surfaceIDs = ["xminus", "xplus", "yminus", "yplus", "zminus", "zplus"] surfaceIDs = ["xminus", "xplus", "yminus", "yplus", "zminus", "zplus"]
def __init__( def __init__(self, xs, xf, ys, yf, zs, zf, dimension, seed):
self,
xs: float,
xf: float,
ys: float,
yf: float,
zs: float,
zf: float,
dimension: float,
seed: Optional[int] = None,
):
""" """
Args: Args:
xs, xf, ys, yf, zs, zf: floats for the extent of the fractal surface 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. seed: int for seed value for random number generator.
""" """
self.ID: str self.ID = None
self.surfaceID: str self.surfaceID = None
self.operatingonID: str
self.xs = xs self.xs = xs
self.xf = xf self.xf = xf
self.ys = ys self.ys = ys
@@ -73,7 +60,7 @@ class FractalSurface:
dimension # Fractal dimension from: http://dx.doi.org/10.1017/CBO9781139174695 dimension # Fractal dimension from: http://dx.doi.org/10.1017/CBO9781139174695
) )
self.weighting = np.array([1, 1], dtype=np.float64) self.weighting = np.array([1, 1], dtype=np.float64)
self.fractalrange: Tuple[int, int] = (0, 0) self.fractalrange = (0, 0)
self.filldepth = 0 self.filldepth = 0
self.grass = [] self.grass = []
@@ -154,8 +141,8 @@ class FractalVolume:
seed: int for seed value for random number generator. seed: int for seed value for random number generator.
""" """
self.ID: str self.ID = None
self.operatingonID: str self.operatingonID = None
self.xs = xs self.xs = xs
self.xf = xf self.xf = xf
self.ys = ys self.ys = ys

查看文件

@@ -26,7 +26,6 @@ import numpy as np
import psutil import psutil
from colorama import Fore, Style, init from colorama import Fore, Style, init
from gprMax.fractals import FractalVolume
from gprMax.grid.cuda_grid import CUDAGrid from gprMax.grid.cuda_grid import CUDAGrid
from gprMax.grid.opencl_grid import OpenCLGrid from gprMax.grid.opencl_grid import OpenCLGrid
from gprMax.materials import ListMaterial, Material, PeplinskiSoil, RangeMaterial from gprMax.materials import ListMaterial, Material, PeplinskiSoil, RangeMaterial
@@ -68,7 +67,6 @@ class Model:
self.subgrids: List[SubGridBaseGrid] = [] self.subgrids: List[SubGridBaseGrid] = []
self.mixingmodels: List[Union[PeplinskiSoil, RangeMaterial, ListMaterial]] = [] self.mixingmodels: List[Union[PeplinskiSoil, RangeMaterial, ListMaterial]] = []
self.fractalvolumes: List[FractalVolume] = []
self.geometryviews: List[GeometryView] = [] self.geometryviews: List[GeometryView] = []
self.geometryobjects: List[GeometryObjects] = [] self.geometryobjects: List[GeometryObjects] = []