Refactor SoilPeplinski UserObject build process

Move mixingmodels from FDTDGrid to Model class
这个提交包含在:
nmannall
2024-05-17 12:00:36 +01:00
父节点 437ca34470
当前提交 7544a84e8c
共有 3 个文件被更改,包括 7 次插入7 次删除

查看文件

@@ -1572,7 +1572,7 @@ class SoilPeplinski(UserObjectMulti):
self.order = 14 self.order = 14
self.hash = "#soil_peplinski" self.hash = "#soil_peplinski"
def build(self, grid, uip): def build(self, model, uip):
try: try:
sand_fraction = self.kwargs["sand_fraction"] sand_fraction = self.kwargs["sand_fraction"]
clay_fraction = self.kwargs["clay_fraction"] clay_fraction = self.kwargs["clay_fraction"]
@@ -1615,7 +1615,7 @@ class SoilPeplinski(UserObjectMulti):
"fraction." "fraction."
) )
raise ValueError raise ValueError
if any(x.ID == ID for x in grid.mixingmodels): if any(x.ID == ID for x in model.mixingmodels):
logger.exception(f"{self.params_str()} with ID {ID} already exists") logger.exception(f"{self.params_str()} with ID {ID} already exists")
raise ValueError raise ValueError
@@ -1631,14 +1631,14 @@ class SoilPeplinski(UserObjectMulti):
) )
logger.info( logger.info(
f"{self.grid_name(grid)}Mixing model (Peplinski) used to " f"{self.model_name(model)}Mixing model (Peplinski) used to "
f"create {s.ID} with sand fraction {s.S:g}, clay fraction " f"create {s.ID} with sand fraction {s.S:g}, clay fraction "
f"{s.C:g}, bulk density {s.rb:g}g/cm3, sand particle " f"{s.C:g}, bulk density {s.rb:g}g/cm3, sand particle "
f"density {s.rs:g}g/cm3, and water volumetric fraction " f"density {s.rs:g}g/cm3, and water volumetric fraction "
f"{s.mu[0]:g} to {s.mu[1]:g} created." f"{s.mu[0]:g} to {s.mu[1]:g} created."
) )
grid.mixingmodels.append(s) model.mixingmodels.append(s)
class MaterialRange(UserObjectMulti): class MaterialRange(UserObjectMulti):

查看文件

@@ -32,7 +32,7 @@ from gprMax import config
from gprMax.cython.yee_cell_build import build_electric_components, build_magnetic_components from gprMax.cython.yee_cell_build import build_electric_components, build_magnetic_components
# from gprMax.geometry_outputs import GeometryObjects, GeometryView # from gprMax.geometry_outputs import GeometryObjects, GeometryView
from gprMax.materials import Material, process_materials from gprMax.materials import process_materials
from gprMax.pml import CFS, PML, build_pml, print_pml_info from gprMax.pml import CFS, PML, build_pml, print_pml_info
from gprMax.receivers import Rx from gprMax.receivers import Rx
from gprMax.snapshots import Snapshot from gprMax.snapshots import Snapshot
@@ -76,7 +76,6 @@ class FDTDGrid:
# TODO: Add type information. # TODO: Add type information.
# Currently importing GeometryObjects, GeometryView, and # Currently importing GeometryObjects, GeometryView, and
# SubGridBaseGrid cause cyclic dependencies # SubGridBaseGrid cause cyclic dependencies
self.mixingmodels = []
self.averagevolumeobjects = True self.averagevolumeobjects = True
self.fractalvolumes = [] self.fractalvolumes = []
self.geometryviews = [] self.geometryviews = []

查看文件

@@ -28,7 +28,7 @@ from colorama import Fore, Style, init
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 Material from gprMax.materials import Material, PeplinskiSoil
from gprMax.subgrids.grid import SubGridBaseGrid from gprMax.subgrids.grid import SubGridBaseGrid
init() init()
@@ -66,6 +66,7 @@ class Model:
self.G = self._create_grid() self.G = self._create_grid()
self.subgrids: List[SubGridBaseGrid] = [] self.subgrids: List[SubGridBaseGrid] = []
self.materials: List[Material] = [] self.materials: List[Material] = []
self.mixingmodels: List[PeplinskiSoil] = []
# Monitor memory usage # Monitor memory usage
self.p = None self.p = None