你已经派生过 gprMax
镜像自地址
https://gitee.com/sunhf/gprMax.git
已同步 2025-08-08 07:24:19 +08:00
add propeties to config
这个提交包含在:
@@ -79,14 +79,11 @@ elif precision == 'double':
|
|||||||
'C_float_or_double': 'double', 'C_complex': 'pycuda::complex<double>'}
|
'C_float_or_double': 'double', 'C_complex': 'pycuda::complex<double>'}
|
||||||
|
|
||||||
|
|
||||||
def create_simulation_config(args):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class ModelConfig():
|
class ModelConfig():
|
||||||
|
|
||||||
def __init__(sim_config, i):
|
def __init__(self, sim_config, i):
|
||||||
self.sim_config = sim.sim_config
|
self.sim_config = sim_config
|
||||||
|
|
||||||
# current model number (indexed from 0)
|
# current model number (indexed from 0)
|
||||||
self.i = i
|
self.i = i
|
||||||
|
|
||||||
@@ -94,18 +91,16 @@ class ModelConfig():
|
|||||||
# 1 indexed
|
# 1 indexed
|
||||||
self.appendmodelnumber = str(self.i) + 1
|
self.appendmodelnumber = str(self.i) + 1
|
||||||
|
|
||||||
inputfilestr_f = '\n--- Model {}/{}, input file: {}'.format()
|
inputfilestr_f = '\n--- Model {}/{}, input file: {}'
|
||||||
self.inputfilestr_f.format(self.i + 1, self.sim_config.model_end, self.sim_config.inputfile.name)
|
self.inputfilestr = inputfilestr_f.format(self.i + 1, self.sim_config.model_end, self.sim_config.inputfile.name)
|
||||||
|
|
||||||
|
|
||||||
# Add the current model run to namespace that can be accessed by
|
# Add the current model run to namespace that can be accessed by
|
||||||
# user in any Python code blocks in input file
|
# user in any Python code blocks in input file
|
||||||
self.usernamespace['current_model_run'] = self.i + 1
|
self.usernamespace['current_model_run'] = self.i + 1
|
||||||
|
|
||||||
|
class SimulationConfig:
|
||||||
|
|
||||||
class SimulationConfig():
|
def __init__(self, args):
|
||||||
|
|
||||||
def __init__(args):
|
|
||||||
"""Adapter for args into Simulation level configuration"""
|
"""Adapter for args into Simulation level configuration"""
|
||||||
|
|
||||||
# adapt the arg properties to link smoothly with MPIRunner(), CPURunner() etc..
|
# adapt the arg properties to link smoothly with MPIRunner(), CPURunner() etc..
|
||||||
@@ -123,16 +118,25 @@ class SimulationConfig():
|
|||||||
# args.geometry_fixed
|
# args.geometry_fixed
|
||||||
# args.write_processed
|
# args.write_processed
|
||||||
|
|
||||||
self.model_start = 0
|
self.args = args
|
||||||
self.model_end = 1
|
self.n_models = args.n
|
||||||
self.n_models = 0
|
|
||||||
self.inputfile = args.inputfile
|
self.inputfile = args.inputfile
|
||||||
self.inputfilepath = os.path.realpath(inputfile.name)
|
self.gpu = args.gpu
|
||||||
self.outputfilepath = os.path.dirname(os.path.abspath(self.inputfilepath))
|
self.mpi = args.mpi
|
||||||
|
self.mpi_no_spawn = args.mpi_no_spawn
|
||||||
|
self.general = {}
|
||||||
|
self.general['messages'] = True
|
||||||
|
self.geometry_fixed = args.geometry_fixed
|
||||||
|
|
||||||
|
self.set_model_start()
|
||||||
|
self.set_model_end()
|
||||||
|
self.set_inputfilepath()
|
||||||
|
self.set_outputfilepath()
|
||||||
|
self.set_single_model()
|
||||||
|
|
||||||
|
|
||||||
def set_single_model(self):
|
def set_single_model(self):
|
||||||
if self.mode_start == 0 and self.model_end == 1:
|
if self.model_start == 1 and self.model_end == 2:
|
||||||
self.single_model = True
|
self.single_model = True
|
||||||
else:
|
else:
|
||||||
self.single_model = False
|
self.single_model = False
|
||||||
@@ -140,23 +144,42 @@ class SimulationConfig():
|
|||||||
# for example
|
# for example
|
||||||
def set_model_start(self):
|
def set_model_start(self):
|
||||||
|
|
||||||
# standard simulation
|
# serial simulation
|
||||||
if not self.args.mpi and not self.args.mpi_no_spawn:
|
if not self.mpi and not self.mpi_no_spawn:
|
||||||
# Set range for number of models to run
|
# Set range for number of models to run
|
||||||
if args.task:
|
if self.args.task:
|
||||||
# Job array feeds args.n number of single tasks
|
# Job array feeds args.n number of single tasks
|
||||||
self.modelstart = args.task
|
self.model_start = self.args.task
|
||||||
elif args.restart:
|
elif self.args.restart:
|
||||||
self.modelstart = args.restart
|
self.model_start = self.args.restart
|
||||||
else:
|
else:
|
||||||
self.modelstart = 1
|
self.model_start = 1
|
||||||
# mpi
|
|
||||||
elif args.mpi:
|
|
||||||
# Set range for number of models to run
|
|
||||||
self.modelstart = args.restart if args.restart else 1 # etc...
|
|
||||||
|
|
||||||
def set_model_end():
|
# mpi simulation
|
||||||
pass
|
elif self.mpi:
|
||||||
|
# Set range for number of models to run
|
||||||
|
self.modelstart = self.args.restart if self.args.restart else 1 # etc...
|
||||||
|
|
||||||
def set_precision():
|
def set_model_end(self):
|
||||||
pass
|
self.model_end = 2 # for now!
|
||||||
|
|
||||||
|
def set_precision(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def set_inputfilepath(self):
|
||||||
|
if self.inputfile:
|
||||||
|
self.inputfilepath = os.path.realpath(inputfile.name)
|
||||||
|
|
||||||
|
def set_outputfilepath(self):
|
||||||
|
if self.inputfile:
|
||||||
|
self.outputfilepath = os.path.dirname(os.path.abspath(self.inputfilepath))
|
||||||
|
|
||||||
|
|
||||||
|
def create_simulation_config(args):
|
||||||
|
|
||||||
|
sc = SimulationConfig(args)
|
||||||
|
return sc
|
||||||
|
|
||||||
|
def create_model_config(sim_config, i):
|
||||||
|
mc = ModelConfig(sim_config, i)
|
||||||
|
return mc
|
||||||
|
在新工单中引用
屏蔽一个用户