你已经派生过 gprMax
镜像自地址
https://gitee.com/sunhf/gprMax.git
已同步 2025-08-08 07:24:19 +08:00
Refactor Materials UserObject build process
这个提交包含在:
@@ -1256,7 +1256,7 @@ class Material(UserObjectMulti):
|
|||||||
self.order = 10
|
self.order = 10
|
||||||
self.hash = "#material"
|
self.hash = "#material"
|
||||||
|
|
||||||
def build(self, grid, uip):
|
def build(self, model, uip):
|
||||||
try:
|
try:
|
||||||
er = self.kwargs["er"]
|
er = self.kwargs["er"]
|
||||||
se = self.kwargs["se"]
|
se = self.kwargs["se"]
|
||||||
@@ -1289,13 +1289,13 @@ class Material(UserObjectMulti):
|
|||||||
if sm < 0:
|
if sm < 0:
|
||||||
logger.exception(f"{self.params_str()} requires a positive value for magnetic loss.")
|
logger.exception(f"{self.params_str()} requires a positive value for magnetic loss.")
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if any(x.ID == material_id for x in grid.materials):
|
if any(x.ID == material_id for x in model.materials):
|
||||||
logger.exception(f"{self.params_str()} with ID {material_id} already exists")
|
logger.exception(f"{self.params_str()} with ID {material_id} already exists")
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
# Create a new instance of the Material class material
|
# Create a new instance of the Material class material
|
||||||
# (start index after pec & free_space)
|
# (start index after pec & free_space)
|
||||||
m = MaterialUser(len(grid.materials), material_id)
|
m = MaterialUser(len(model.materials), material_id)
|
||||||
m.se = se
|
m.se = se
|
||||||
m.mr = mr
|
m.mr = mr
|
||||||
m.sm = sm
|
m.sm = sm
|
||||||
@@ -1306,12 +1306,12 @@ class Material(UserObjectMulti):
|
|||||||
|
|
||||||
m.er = er
|
m.er = er
|
||||||
logger.info(
|
logger.info(
|
||||||
f"{self.grid_name(grid)}Material {m.ID} with eps_r={m.er:g}, "
|
f"{[model.title]} Material {m.ID} with eps_r={m.er:g}, "
|
||||||
f"sigma={m.se:g} S/m; mu_r={m.mr:g}, sigma*={m.sm:g} Ohm/m "
|
f"sigma={m.se:g} S/m; mu_r={m.mr:g}, sigma*={m.sm:g} Ohm/m "
|
||||||
f"created."
|
f"created."
|
||||||
)
|
)
|
||||||
|
|
||||||
grid.materials.append(m)
|
model.materials.append(m)
|
||||||
|
|
||||||
|
|
||||||
class AddDebyeDispersion(UserObjectMulti):
|
class AddDebyeDispersion(UserObjectMulti):
|
||||||
|
@@ -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.materials: List[Material] = []
|
|
||||||
self.mixingmodels = []
|
self.mixingmodels = []
|
||||||
self.averagevolumeobjects = True
|
self.averagevolumeobjects = True
|
||||||
self.fractalvolumes = []
|
self.fractalvolumes = []
|
||||||
|
@@ -28,6 +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.subgrids.grid import SubGridBaseGrid
|
from gprMax.subgrids.grid import SubGridBaseGrid
|
||||||
|
|
||||||
init()
|
init()
|
||||||
@@ -64,6 +65,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] = []
|
||||||
|
|
||||||
# Monitor memory usage
|
# Monitor memory usage
|
||||||
self.p = None
|
self.p = None
|
||||||
|
在新工单中引用
屏蔽一个用户