你已经派生过 gprMax
镜像自地址
https://gitee.com/sunhf/gprMax.git
已同步 2025-08-07 15:10:13 +08:00
Fixed pre-commit errors and updated black version.
这个提交包含在:
@@ -9,7 +9,7 @@ repos:
|
|||||||
- id: check-added-large-files
|
- id: check-added-large-files
|
||||||
- id: check-toml
|
- id: check-toml
|
||||||
- repo: https://github.com/psf/black-pre-commit-mirror
|
- repo: https://github.com/psf/black-pre-commit-mirror
|
||||||
rev: 23.11.0
|
rev: 23.12.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: black
|
- id: black
|
||||||
args: ["--line-length", "120"] # Adjust the max line length value as needed.
|
args: ["--line-length", "120"] # Adjust the max line length value as needed.
|
||||||
|
@@ -210,4 +210,4 @@ Periodically you should update conda and the required Python packages. With the
|
|||||||
Thanks To Our Contributors ✨🔗
|
Thanks To Our Contributors ✨🔗
|
||||||
==========================
|
==========================
|
||||||
.. image:: https://contrib.rocks/image?repo=gprMax/gprMax
|
.. image:: https://contrib.rocks/image?repo=gprMax/gprMax
|
||||||
:target: https://github.com/gprMax/gprMax/graphs/contributors
|
:target: https://github.com/gprMax/gprMax/graphs/contributors
|
||||||
|
@@ -767,11 +767,11 @@ For example, to specify the normalised first derivative of a Gaussian waveform w
|
|||||||
|
|
||||||
Allows you to specify an ASCII file that contains amplitude values that specify custom waveform(s) that can be used with sources in the model.
|
Allows you to specify an ASCII file that contains amplitude values that specify custom waveform(s) that can be used with sources in the model.
|
||||||
|
|
||||||
The first row of each column must begin with a identifier string that will be used as the name of each waveform. Subsequent rows should contain amplitude values for the custom waveform you want to use. You can import multiple different waveforms (as columns of amplitude data) in a single file.
|
The first row of each column must begin with a identifier string that will be used as the name of each waveform. Subsequent rows should contain amplitude values for the custom waveform you want to use. You can import multiple different waveforms (as columns of amplitude data) in a single file.
|
||||||
|
|
||||||
Ideally, there should be the same number of amplitude values as number of iterations in your model. If there are less amplitude values than the number of iterations in the model, the end of the sequence of amplitude values will be padded with zero values up to the number of iterations. If extra amplitude values are specified than needed then they are ignored.
|
Ideally, there should be the same number of amplitude values as number of iterations in your model. If there are less amplitude values than the number of iterations in the model, the end of the sequence of amplitude values will be padded with zero values up to the number of iterations. If extra amplitude values are specified than needed then they are ignored.
|
||||||
|
|
||||||
Optionally, in the first column of the file you may specify your own time vector of values (which must use the identifier ``time``) to use with the amplitude values of the waveform.
|
Optionally, in the first column of the file you may specify your own time vector of values (which must use the identifier ``time``) to use with the amplitude values of the waveform.
|
||||||
|
|
||||||
The amplitude values will be interpolated using either the aforementioned user specified time vector, or if none was supplied, a vector of time values corresponding to the simulation time step and number of iterations will be used. Key parameters used for the interpolation can be specified in the command.
|
The amplitude values will be interpolated using either the aforementioned user specified time vector, or if none was supplied, a vector of time values corresponding to the simulation time step and number of iterations will be used. Key parameters used for the interpolation can be specified in the command.
|
||||||
|
|
||||||
|
@@ -21,11 +21,11 @@ import logging
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
import gprMax.config as config
|
import gprMax.config as config
|
||||||
|
from gprMax.cmds_geometry.cmds_geometry import UserObjectGeometry, rotate_2point_object
|
||||||
from gprMax.fractals import FractalVolume
|
from gprMax.fractals import FractalVolume
|
||||||
from gprMax.materials import ListMaterial
|
from gprMax.materials import ListMaterial
|
||||||
|
|
||||||
from ..cython.geometry_primitives import build_voxels_from_array, build_voxels_from_array_mask
|
from ..cython.geometry_primitives import build_voxels_from_array, build_voxels_from_array_mask
|
||||||
from gprMax.cmds_geometry.cmds_geometry import UserObjectGeometry, rotate_2point_object
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -172,7 +172,7 @@ class FractalBox(UserObjectGeometry):
|
|||||||
f"is {dielectricsmoothing}."
|
f"is {dielectricsmoothing}."
|
||||||
)
|
)
|
||||||
grid.fractalvolumes.append(self.volume)
|
grid.fractalvolumes.append(self.volume)
|
||||||
|
|
||||||
def build(self, grid, uip):
|
def build(self, grid, uip):
|
||||||
if self.do_pre_build:
|
if self.do_pre_build:
|
||||||
self.pre_build(grid, uip)
|
self.pre_build(grid, uip)
|
||||||
@@ -218,7 +218,8 @@ class FractalBox(UserObjectGeometry):
|
|||||||
# otherwise a mixing model
|
# otherwise a mixing model
|
||||||
if self.volume.nbins == 1:
|
if self.volume.nbins == 1:
|
||||||
self.volume.fractalvolume = np.ones(
|
self.volume.fractalvolume = np.ones(
|
||||||
(self.volume.nx, self.volume.ny, self.volume.nz), dtype=config.sim_config.dtypes["float_or_double"]
|
(self.volume.nx, self.volume.ny, self.volume.nz),
|
||||||
|
dtype=config.sim_config.dtypes["float_or_double"],
|
||||||
)
|
)
|
||||||
materialnumID = next(x.numID for x in grid.materials if x.ID == self.volume.operatingonID)
|
materialnumID = next(x.numID for x in grid.materials if x.ID == self.volume.operatingonID)
|
||||||
self.volume.fractalvolume *= materialnumID
|
self.volume.fractalvolume *= materialnumID
|
||||||
@@ -253,11 +254,17 @@ class FractalBox(UserObjectGeometry):
|
|||||||
for j in range(surface.ys, surface.yf):
|
for j in range(surface.ys, surface.yf):
|
||||||
for k in range(surface.zs, surface.zf):
|
for k in range(surface.zs, surface.zf):
|
||||||
if i < surface.fractalsurface[j - surface.ys, k - surface.zs]:
|
if i < surface.fractalsurface[j - surface.ys, k - surface.zs]:
|
||||||
self.volume.mask[i - self.volume.xs, j - self.volume.ys, k - self.volume.zs] = 1
|
self.volume.mask[
|
||||||
|
i - self.volume.xs, j - self.volume.ys, k - self.volume.zs
|
||||||
|
] = 1
|
||||||
elif surface.filldepth > 0 and i < surface.filldepth:
|
elif surface.filldepth > 0 and i < surface.filldepth:
|
||||||
self.volume.mask[i - self.volume.xs, j - self.volume.ys, k - self.volume.zs] = 2
|
self.volume.mask[
|
||||||
|
i - self.volume.xs, j - self.volume.ys, k - self.volume.zs
|
||||||
|
] = 2
|
||||||
else:
|
else:
|
||||||
self.volume.mask[i - self.volume.xs, j - self.volume.ys, k - self.volume.zs] = 0
|
self.volume.mask[
|
||||||
|
i - self.volume.xs, j - self.volume.ys, k - self.volume.zs
|
||||||
|
] = 0
|
||||||
elif surface.ID == "grass":
|
elif surface.ID == "grass":
|
||||||
g = surface.grass[0]
|
g = surface.grass[0]
|
||||||
# Build the blades of the grass
|
# Build the blades of the grass
|
||||||
@@ -269,7 +276,10 @@ class FractalBox(UserObjectGeometry):
|
|||||||
for i in range(self.volume.xs, surface.fractalrange[1]):
|
for i in range(self.volume.xs, surface.fractalrange[1]):
|
||||||
if (
|
if (
|
||||||
i < surface.fractalsurface[j - surface.ys, k - surface.zs]
|
i < surface.fractalsurface[j - surface.ys, k - surface.zs]
|
||||||
and self.volume.mask[i - self.volume.xs, j - self.volume.ys, k - self.volume.zs] != 1
|
and self.volume.mask[
|
||||||
|
i - self.volume.xs, j - self.volume.ys, k - self.volume.zs
|
||||||
|
]
|
||||||
|
!= 1
|
||||||
):
|
):
|
||||||
y, z = g.calculate_blade_geometry(blade, height)
|
y, z = g.calculate_blade_geometry(blade, height)
|
||||||
# Add y, z coordinates to existing location
|
# Add y, z coordinates to existing location
|
||||||
@@ -304,7 +314,10 @@ class FractalBox(UserObjectGeometry):
|
|||||||
surface.fractalsurface[j - surface.ys, k - surface.zs]
|
surface.fractalsurface[j - surface.ys, k - surface.zs]
|
||||||
- self.volume.originalxf
|
- self.volume.originalxf
|
||||||
)
|
)
|
||||||
and self.volume.mask[i - self.volume.xs, j - self.volume.ys, k - self.volume.zs] == 1
|
and self.volume.mask[
|
||||||
|
i - self.volume.xs, j - self.volume.ys, k - self.volume.zs
|
||||||
|
]
|
||||||
|
== 1
|
||||||
):
|
):
|
||||||
y, z = g.calculate_root_geometry(root, depth)
|
y, z = g.calculate_root_geometry(root, depth)
|
||||||
# Add y, z coordinates to existing location
|
# Add y, z coordinates to existing location
|
||||||
@@ -342,11 +355,17 @@ class FractalBox(UserObjectGeometry):
|
|||||||
for j in range(surface.fractalrange[0], surface.fractalrange[1]):
|
for j in range(surface.fractalrange[0], surface.fractalrange[1]):
|
||||||
for k in range(surface.zs, surface.zf):
|
for k in range(surface.zs, surface.zf):
|
||||||
if j < surface.fractalsurface[i - surface.xs, k - surface.zs]:
|
if j < surface.fractalsurface[i - surface.xs, k - surface.zs]:
|
||||||
self.volume.mask[i - self.volume.xs, j - self.volume.ys, k - self.volume.zs] = 1
|
self.volume.mask[
|
||||||
|
i - self.volume.xs, j - self.volume.ys, k - self.volume.zs
|
||||||
|
] = 1
|
||||||
elif surface.filldepth > 0 and j < surface.filldepth:
|
elif surface.filldepth > 0 and j < surface.filldepth:
|
||||||
self.volume.mask[i - self.volume.xs, j - self.volume.ys, k - self.volume.zs] = 2
|
self.volume.mask[
|
||||||
|
i - self.volume.xs, j - self.volume.ys, k - self.volume.zs
|
||||||
|
] = 2
|
||||||
else:
|
else:
|
||||||
self.volume.mask[i - self.volume.xs, j - self.volume.ys, k - self.volume.zs] = 0
|
self.volume.mask[
|
||||||
|
i - self.volume.xs, j - self.volume.ys, k - self.volume.zs
|
||||||
|
] = 0
|
||||||
elif surface.ID == "grass":
|
elif surface.ID == "grass":
|
||||||
g = surface.grass[0]
|
g = surface.grass[0]
|
||||||
# Build the blades of the grass
|
# Build the blades of the grass
|
||||||
@@ -358,7 +377,10 @@ class FractalBox(UserObjectGeometry):
|
|||||||
for j in range(self.volume.ys, surface.fractalrange[1]):
|
for j in range(self.volume.ys, surface.fractalrange[1]):
|
||||||
if (
|
if (
|
||||||
j < surface.fractalsurface[i - surface.xs, k - surface.zs]
|
j < surface.fractalsurface[i - surface.xs, k - surface.zs]
|
||||||
and self.volume.mask[i - self.volume.xs, j - self.volume.ys, k - self.volume.zs] != 1
|
and self.volume.mask[
|
||||||
|
i - self.volume.xs, j - self.volume.ys, k - self.volume.zs
|
||||||
|
]
|
||||||
|
!= 1
|
||||||
):
|
):
|
||||||
x, z = g.calculate_blade_geometry(blade, height)
|
x, z = g.calculate_blade_geometry(blade, height)
|
||||||
# Add x, z coordinates to existing location
|
# Add x, z coordinates to existing location
|
||||||
@@ -393,7 +415,10 @@ class FractalBox(UserObjectGeometry):
|
|||||||
surface.fractalsurface[i - surface.xs, k - surface.zs]
|
surface.fractalsurface[i - surface.xs, k - surface.zs]
|
||||||
- self.volume.originalyf
|
- self.volume.originalyf
|
||||||
)
|
)
|
||||||
and self.volume.mask[i - self.volume.xs, j - self.volume.ys, k - self.volume.zs] == 1
|
and self.volume.mask[
|
||||||
|
i - self.volume.xs, j - self.volume.ys, k - self.volume.zs
|
||||||
|
]
|
||||||
|
== 1
|
||||||
):
|
):
|
||||||
x, z = g.calculate_root_geometry(root, depth)
|
x, z = g.calculate_root_geometry(root, depth)
|
||||||
# Add x, z coordinates to existing location
|
# Add x, z coordinates to existing location
|
||||||
@@ -431,11 +456,17 @@ class FractalBox(UserObjectGeometry):
|
|||||||
for j in range(surface.ys, surface.yf):
|
for j in range(surface.ys, surface.yf):
|
||||||
for k in range(surface.fractalrange[0], surface.fractalrange[1]):
|
for k in range(surface.fractalrange[0], surface.fractalrange[1]):
|
||||||
if k < surface.fractalsurface[i - surface.xs, j - surface.ys]:
|
if k < surface.fractalsurface[i - surface.xs, j - surface.ys]:
|
||||||
self.volume.mask[i - self.volume.xs, j - self.volume.ys, k - self.volume.zs] = 1
|
self.volume.mask[
|
||||||
|
i - self.volume.xs, j - self.volume.ys, k - self.volume.zs
|
||||||
|
] = 1
|
||||||
elif surface.filldepth > 0 and k < surface.filldepth:
|
elif surface.filldepth > 0 and k < surface.filldepth:
|
||||||
self.volume.mask[i - self.volume.xs, j - self.volume.ys, k - self.volume.zs] = 2
|
self.volume.mask[
|
||||||
|
i - self.volume.xs, j - self.volume.ys, k - self.volume.zs
|
||||||
|
] = 2
|
||||||
else:
|
else:
|
||||||
self.volume.mask[i - self.volume.xs, j - self.volume.ys, k - self.volume.zs] = 0
|
self.volume.mask[
|
||||||
|
i - self.volume.xs, j - self.volume.ys, k - self.volume.zs
|
||||||
|
] = 0
|
||||||
elif surface.ID == "grass":
|
elif surface.ID == "grass":
|
||||||
g = surface.grass[0]
|
g = surface.grass[0]
|
||||||
# Build the blades of the grass
|
# Build the blades of the grass
|
||||||
@@ -447,7 +478,10 @@ class FractalBox(UserObjectGeometry):
|
|||||||
for k in range(self.volume.zs, surface.fractalrange[1]):
|
for k in range(self.volume.zs, surface.fractalrange[1]):
|
||||||
if (
|
if (
|
||||||
k < surface.fractalsurface[i - surface.xs, j - surface.ys]
|
k < surface.fractalsurface[i - surface.xs, j - surface.ys]
|
||||||
and self.volume.mask[i - self.volume.xs, j - self.volume.ys, k - self.volume.zs] != 1
|
and self.volume.mask[
|
||||||
|
i - self.volume.xs, j - self.volume.ys, k - self.volume.zs
|
||||||
|
]
|
||||||
|
!= 1
|
||||||
):
|
):
|
||||||
x, y = g.calculate_blade_geometry(blade, height)
|
x, y = g.calculate_blade_geometry(blade, height)
|
||||||
# Add x, y coordinates to existing location
|
# Add x, y coordinates to existing location
|
||||||
@@ -482,7 +516,10 @@ class FractalBox(UserObjectGeometry):
|
|||||||
surface.fractalsurface[i - surface.xs, j - surface.ys]
|
surface.fractalsurface[i - surface.xs, j - surface.ys]
|
||||||
- self.volume.originalzf
|
- self.volume.originalzf
|
||||||
)
|
)
|
||||||
and self.volume.mask[i - self.volume.xs, j - self.volume.ys, k - self.volume.zs] == 1
|
and self.volume.mask[
|
||||||
|
i - self.volume.xs, j - self.volume.ys, k - self.volume.zs
|
||||||
|
]
|
||||||
|
== 1
|
||||||
):
|
):
|
||||||
x, y = g.calculate_root_geometry(root, depth)
|
x, y = g.calculate_root_geometry(root, depth)
|
||||||
# Add x, y coordinates to existing location
|
# Add x, y coordinates to existing location
|
||||||
@@ -553,4 +590,4 @@ class FractalBox(UserObjectGeometry):
|
|||||||
grid.rigidE,
|
grid.rigidE,
|
||||||
grid.rigidH,
|
grid.rigidH,
|
||||||
grid.ID,
|
grid.ID,
|
||||||
)
|
)
|
||||||
|
@@ -90,9 +90,7 @@ class ModelConfig:
|
|||||||
except:
|
except:
|
||||||
deviceID = 0
|
deviceID = 0
|
||||||
|
|
||||||
self.device = {"dev": sim_config.set_model_device(deviceID),
|
self.device = {"dev": sim_config.set_model_device(deviceID), "deviceID": deviceID, "snapsgpu2cpu": False}
|
||||||
"deviceID": deviceID,
|
|
||||||
"snapsgpu2cpu": False}
|
|
||||||
|
|
||||||
# Total memory usage for all grids in the model. Starts with 50MB overhead.
|
# Total memory usage for all grids in the model. Starts with 50MB overhead.
|
||||||
self.mem_overhead = 65e6
|
self.mem_overhead = 65e6
|
||||||
|
@@ -23,6 +23,7 @@ import sys
|
|||||||
|
|
||||||
import humanize
|
import humanize
|
||||||
from colorama import Fore, Style, init
|
from colorama import Fore, Style, init
|
||||||
|
|
||||||
init()
|
init()
|
||||||
|
|
||||||
import gprMax.config as config
|
import gprMax.config as config
|
||||||
@@ -87,10 +88,10 @@ class Context:
|
|||||||
del solver, model
|
del solver, model
|
||||||
|
|
||||||
if not config.sim_config.args.geometry_fixed:
|
if not config.sim_config.args.geometry_fixed:
|
||||||
# Manual garbage collection required to stop memory leak on GPUs
|
# Manual garbage collection required to stop memory leak on GPUs
|
||||||
# when using pycuda
|
# when using pycuda
|
||||||
del G
|
del G
|
||||||
|
|
||||||
gc.collect()
|
gc.collect()
|
||||||
|
|
||||||
self.tsimend = timer()
|
self.tsimend = timer()
|
||||||
@@ -141,9 +142,11 @@ class MPIContext(Context):
|
|||||||
model_config = config.ModelConfig()
|
model_config = config.ModelConfig()
|
||||||
# Set GPU deviceID according to worker rank
|
# Set GPU deviceID according to worker rank
|
||||||
if config.sim_config.general["solver"] == "cuda":
|
if config.sim_config.general["solver"] == "cuda":
|
||||||
model_config.device = {"dev": config.sim_config.devices["devs"][self.rank - 1],
|
model_config.device = {
|
||||||
"deviceID": self.rank - 1,
|
"dev": config.sim_config.devices["devs"][self.rank - 1],
|
||||||
"snapsgpu2cpu": False}
|
"deviceID": self.rank - 1,
|
||||||
|
"snapsgpu2cpu": False,
|
||||||
|
}
|
||||||
config.model_configs = model_config
|
config.model_configs = model_config
|
||||||
|
|
||||||
G = create_G()
|
G = create_G()
|
||||||
@@ -156,7 +159,7 @@ class MPIContext(Context):
|
|||||||
del solver, model
|
del solver, model
|
||||||
|
|
||||||
# Manual garbage collection required to stop memory leak on GPUs when
|
# Manual garbage collection required to stop memory leak on GPUs when
|
||||||
# using pycuda
|
# using pycuda
|
||||||
del G
|
del G
|
||||||
gc.collect()
|
gc.collect()
|
||||||
|
|
||||||
@@ -178,7 +181,7 @@ class MPIContext(Context):
|
|||||||
|
|
||||||
s = f"\n--- Input file: {config.sim_config.input_file_path}"
|
s = f"\n--- Input file: {config.sim_config.input_file_path}"
|
||||||
logger.basic(Fore.GREEN + f"{s} {'-' * (get_terminal_width() - 1 - len(s))}\n" + Style.RESET_ALL)
|
logger.basic(Fore.GREEN + f"{s} {'-' * (get_terminal_width() - 1 - len(s))}\n" + Style.RESET_ALL)
|
||||||
|
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
|
|
||||||
# Contruct MPIExecutor
|
# Contruct MPIExecutor
|
||||||
|
@@ -96,9 +96,7 @@ class GeometryView:
|
|||||||
def set_filename(self):
|
def set_filename(self):
|
||||||
"""Constructs filename from user-supplied name and model run number."""
|
"""Constructs filename from user-supplied name and model run number."""
|
||||||
parts = config.get_model_config().output_file_path.parts
|
parts = config.get_model_config().output_file_path.parts
|
||||||
self.filename = Path(*parts[:-1],
|
self.filename = Path(*parts[:-1], self.filenamebase + config.get_model_config().appendmodelnumber)
|
||||||
self.filenamebase +
|
|
||||||
config.get_model_config().appendmodelnumber)
|
|
||||||
|
|
||||||
|
|
||||||
class GeometryViewLines(GeometryView):
|
class GeometryViewLines(GeometryView):
|
||||||
|
@@ -58,7 +58,7 @@ class ModelBuildRun:
|
|||||||
|
|
||||||
# Set number of OpenMP threads to physical threads at this point to be
|
# Set number of OpenMP threads to physical threads at this point to be
|
||||||
# used with threaded model building methods, e.g. fractals. Can be
|
# used with threaded model building methods, e.g. fractals. Can be
|
||||||
# changed by the user via #num_threads command in input file or via API
|
# changed by the user via #num_threads command in input file or via API
|
||||||
# later for use with CPU solver.
|
# later for use with CPU solver.
|
||||||
config.get_model_config().ompthreads = set_omp_threads(config.get_model_config().ompthreads)
|
config.get_model_config().ompthreads = set_omp_threads(config.get_model_config().ompthreads)
|
||||||
|
|
||||||
@@ -309,14 +309,18 @@ class ModelBuildRun:
|
|||||||
if config.sim_config.general["solver"] == "opencl":
|
if config.sim_config.general["solver"] == "opencl":
|
||||||
solvername = "OpenCL"
|
solvername = "OpenCL"
|
||||||
platformname = " on " + " ".join(config.get_model_config().device["dev"].platform.name.split())
|
platformname = " on " + " ".join(config.get_model_config().device["dev"].platform.name.split())
|
||||||
devicename = (f'Device {config.get_model_config().device["deviceID"]}: '
|
devicename = (
|
||||||
f'{" ".join(config.get_model_config().device["dev"].name.split())}')
|
f'Device {config.get_model_config().device["deviceID"]}: '
|
||||||
|
f'{" ".join(config.get_model_config().device["dev"].name.split())}'
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
solvername = "CUDA"
|
solvername = "CUDA"
|
||||||
platformname = ""
|
platformname = ""
|
||||||
devicename = (f'Device {config.get_model_config().device["deviceID"]}: '
|
devicename = (
|
||||||
f'{" ".join(config.get_model_config().device["dev"].name().split())}')
|
f'Device {config.get_model_config().device["deviceID"]}: '
|
||||||
|
f'{" ".join(config.get_model_config().device["dev"].name().split())}'
|
||||||
|
)
|
||||||
|
|
||||||
logger.basic(
|
logger.basic(
|
||||||
f"\nModel {config.model_num + 1}/{config.sim_config.model_end} "
|
f"\nModel {config.model_num + 1}/{config.sim_config.model_end} "
|
||||||
f"solving on {config.sim_config.hostinfo['hostname']} "
|
f"solving on {config.sim_config.hostinfo['hostname']} "
|
||||||
|
@@ -18,11 +18,11 @@
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from gprMax.cmds_geometry.cmds_geometry import UserObjectGeometry
|
|
||||||
from gprMax.cmds_geometry.fractal_box import FractalBox
|
|
||||||
from gprMax.cmds_geometry.add_grass import AddGrass
|
from gprMax.cmds_geometry.add_grass import AddGrass
|
||||||
from gprMax.cmds_geometry.add_surface_roughness import AddSurfaceRoughness
|
from gprMax.cmds_geometry.add_surface_roughness import AddSurfaceRoughness
|
||||||
from gprMax.cmds_geometry.add_surface_water import AddSurfaceWater
|
from gprMax.cmds_geometry.add_surface_water import AddSurfaceWater
|
||||||
|
from gprMax.cmds_geometry.cmds_geometry import UserObjectGeometry
|
||||||
|
from gprMax.cmds_geometry.fractal_box import FractalBox
|
||||||
from gprMax.cmds_multiuse import UserObjectMulti
|
from gprMax.cmds_multiuse import UserObjectMulti
|
||||||
from gprMax.cmds_singleuse import Discretisation, Domain, TimeWindow, UserObjectSingle
|
from gprMax.cmds_singleuse import Discretisation, Domain, TimeWindow, UserObjectSingle
|
||||||
from gprMax.materials import create_built_in_materials
|
from gprMax.materials import create_built_in_materials
|
||||||
@@ -57,10 +57,10 @@ class Scene:
|
|||||||
else:
|
else:
|
||||||
logger.exception("This object is unknown to gprMax")
|
logger.exception("This object is unknown to gprMax")
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
def build_obj(self, obj, grid):
|
def build_obj(self, obj, grid):
|
||||||
"""Builds objects.
|
"""Builds objects.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
obj: user object
|
obj: user object
|
||||||
grid: FDTDGrid class describing a grid in a model.
|
grid: FDTDGrid class describing a grid in a model.
|
||||||
@@ -71,9 +71,10 @@ class Scene:
|
|||||||
except ValueError:
|
except ValueError:
|
||||||
logger.exception("Error creating user input object")
|
logger.exception("Error creating user input object")
|
||||||
raise
|
raise
|
||||||
|
|
||||||
def process_subgrid_cmds(self):
|
def process_subgrid_cmds(self):
|
||||||
"""Process all commands in any sub-grids."""
|
"""Process all commands in any sub-grids."""
|
||||||
|
|
||||||
def func(obj):
|
def func(obj):
|
||||||
if isinstance(obj, SubGridUserBase):
|
if isinstance(obj, SubGridUserBase):
|
||||||
return True
|
return True
|
||||||
@@ -99,13 +100,12 @@ class Scene:
|
|||||||
self.build_obj(obj, grid)
|
self.build_obj(obj, grid)
|
||||||
|
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def process_geocmds(self, commands, grid):
|
def process_geocmds(self, commands, grid):
|
||||||
# Check for fractal boxes and modifications and pre-process them first
|
# Check for fractal boxes and modifications and pre-process them first
|
||||||
proc_cmds = []
|
proc_cmds = []
|
||||||
for obj in commands:
|
for obj in commands:
|
||||||
if isinstance(obj, (FractalBox, AddGrass,
|
if isinstance(obj, (FractalBox, AddGrass, AddSurfaceRoughness, AddSurfaceWater)):
|
||||||
AddSurfaceRoughness, AddSurfaceWater)):
|
|
||||||
self.build_obj(obj, grid)
|
self.build_obj(obj, grid)
|
||||||
if isinstance(obj, (FractalBox)):
|
if isinstance(obj, (FractalBox)):
|
||||||
proc_cmds.append(obj)
|
proc_cmds.append(obj)
|
||||||
|
@@ -183,4 +183,4 @@ def fft_power(waveform, dt):
|
|||||||
|
|
||||||
def timer():
|
def timer():
|
||||||
"""Time in fractional seconds."""
|
"""Time in fractional seconds."""
|
||||||
return timer_fn()
|
return timer_fn()
|
||||||
|
在新工单中引用
屏蔽一个用户