Refactored some code to make it cleaner/better.

这个提交包含在:
Sai-Suraj-27
2023-06-23 18:42:17 +05:30
父节点 88d59fdbc4
当前提交 e9416e34c8
共有 7 个文件被更改,包括 13 次插入17 次删除

查看文件

@@ -390,7 +390,7 @@ class HertzianDipole(UserObjectMulti):
# Check if there is a waveformID in the waveforms list
if not any(x.ID == waveform_id for x in grid.waveforms):
if all(x.ID == waveform_id for x in grid.waveforms):
logger.exception(f'{self.params_str()} there is no waveform ' +
f'with the identifier {waveform_id}.')
raise ValueError
@@ -526,7 +526,7 @@ class MagneticDipole(UserObjectMulti):
# Check if there is a waveformID in the waveforms list
if not any(x.ID == waveform_id for x in grid.waveforms):
if all(x.ID == waveform_id for x in grid.waveforms):
logger.exception(f'{self.params_str()} there is no waveform ' +
f'with the identifier {waveform_id}.')
raise ValueError

查看文件

@@ -72,7 +72,7 @@ class ModelConfig:
# N.B. This will happen if the requested snapshots are too large to
# fit on the memory of the GPU. If True this will slow
# performance significantly.
if sim_config.general['solver'] == 'cuda' or sim_config.general['solver'] == 'opencl':
if sim_config.general['solver'] in ['cuda', 'opencl']:
if sim_config.general['solver'] == 'cuda':
devs = sim_config.args.gpu
elif sim_config.general['solver'] == 'opencl':

查看文件

@@ -53,7 +53,6 @@ class Context:
results: dict that can contain useful results/data from simulation.
"""
results = {}
self.tsimstart = timer()
self.print_logo_copyright()
print_host_info(config.sim_config.hostinfo)
@@ -88,7 +87,7 @@ class Context:
self.tsimend = timer()
self.print_sim_time_taken()
return results
return {}
def print_logo_copyright(self):
"""Prints gprMax logo, version, and copyright/licencing information."""

查看文件

@@ -214,10 +214,9 @@ def run_main(args):
# MPI running with (OpenMP/CUDA/OpenCL)
if config.sim_config.args.mpi:
context = MPIContext()
results = context.run()
# Standard running (OpenMP/CUDA/OpenCL)
else:
context = Context()
results = context.run()
results = context.run()
return results

查看文件

@@ -414,7 +414,7 @@ def dispersion_analysis(G):
# Find maximum significant frequency
if G.waveforms:
for waveform in G.waveforms:
if waveform.type == 'sine' or waveform.type == 'contsine':
if waveform.type in ['sine', 'contsine']:
results['maxfreq'].append(4 * waveform.freq)
elif waveform.type == 'impulse':

查看文件

@@ -278,12 +278,11 @@ def check_cmd_names(processedlines, checkessential=True):
lindex += 1
if checkessential:
if (countessentialcmds < len(essentialcmds)):
logger.exception('Your input file is missing essential commands ' +
'required to run a model. Essential commands are: ' +
', '.join(essentialcmds))
raise SyntaxError
if checkessential and countessentialcmds < len(essentialcmds):
logger.exception('Your input file is missing essential commands ' +
'required to run a model. Essential commands are: ' +
', '.join(essentialcmds))
raise SyntaxError
return singlecmds, multiplecmds, geometry

查看文件

@@ -1056,7 +1056,6 @@ class OpenCLUpdates:
self.grid.Hx_dev,
self.grid.Hy_dev,
self.grid.Hz_dev)
event.wait()
# If there are any dispersive materials do 1st part of dispersive update
# (it is split into two parts as it requires present and updated electric field values).
@@ -1076,7 +1075,8 @@ class OpenCLUpdates:
self.grid.Hx_dev,
self.grid.Hy_dev,
self.grid.Hz_dev)
event.wait()
event.wait()
def update_electric_pml(self):
"""Updates electric field components with the PML correction."""
@@ -1158,7 +1158,6 @@ class OpenCLUpdates:
# if iteration == self.grid.iterations - 1:
# return self.drv.mem_get_info()[1] - self.drv.mem_get_info()[0]
logger.debug('Look at memory estimate for pyopencl')
pass
def calculate_solve_time(self):
"""Calculates solving time for model."""