fix snapshots for python blocks

这个提交包含在:
jasminium
2019-09-05 18:27:01 +01:00
父节点 ffa5107eb3
当前提交 c1766d4a6d
共有 3 个文件被更改,包括 11 次插入11 次删除

查看文件

@@ -688,11 +688,11 @@ class Snapshot(UserObjectMulti):
raise CmdInputError("'{}' time value is not valid".format(self.__str__()))
# Replace with old style snapshots if there are subgrids
if grid.subgrids:
from .snapshot_subgrid import Snapshot as SnapshotSub
s = SnapshotSub(xs, ys, zs, xf, yf, zf, dx, dy, dz, iterations, filename)
else:
s = SnapshotUser(xs, ys, zs, xf, yf, zf, dx, dy, dz, iterations, filename)
#if grid.subgrids:
# from .snapshot_subgrid import Snapshot as SnapshotSub
# s = SnapshotSub(xs, ys, zs, xf, yf, zf, dx, dy, dz, iterations, filename)
#else:
s = SnapshotUser(xs, ys, zs, xf, yf, zf, dx, dy, dz, iterations, filename)
if config.is_messages():
print('Snapshot from {:g}m, {:g}m, {:g}m, to {:g}m, {:g}m, {:g}m, discretisation {:g}m, {:g}m, {:g}m, at {:g} secs with filename {} created.'.format(xs * grid.dx, ys * grid.dy, zs * grid.dz, xf * grid.dx, yf * grid.dy, zf * grid.dz, dx * grid.dx, dy * grid.dy, dz * grid.dz, s.time * grid.dt, s.basefilename))

查看文件

@@ -115,12 +115,11 @@ class ModelConfig():
self.appendmodelnumber = ''
# outputfilepath for specific model
self.output_file_path = Path(*parts[:-2], parts[-1] + self.appendmodelnumber)
self.output_file_path = Path(*parts[:-2], parts[-1] + self.appendmodelnumber).with_suffix('')
self.output_file_path_ext = self.output_file_path.with_suffix('.out')
# make a snapshot directory
stem = parts[-1] + '_snaps' + self.appendmodelnumber
self.snapshot_dir = Path(*parts[:-2], stem)
self.snapshot_dir = '_snaps'
inputfilestr_f = '\n--- Model {}/{}, input file: {}'
self.inputfilestr = inputfilestr_f.format(self.i + 1, self.sim_config.model_end, self.sim_config.input_file_path)

查看文件

@@ -268,13 +268,14 @@ class ModelBuildRun:
if not os.path.exists(snapshotdir):
os.mkdir(snapshotdir)
self.printer.print()
self.printer.print('')
for i, snap in enumerate(G.snapshots):
snap.filename = snapshotdir + snap.basefilename + '.vti'
fn = snapshotdir / Path(self.model_config.output_file_path.stem + '_' + snap.basefilename)
snap.filename = fn.with_suffix('.vti')
pbar = tqdm(total=snap.vtkdatawritesize, leave=True, unit='byte', unit_scale=True, desc='Writing snapshot file {} of {}, {}'.format(i + 1, len(G.snapshots), os.path.split(snap.filename)[1]), ncols=get_terminal_width() - 1, file=sys.stdout, disable=not config.general['progressbars'])
snap.write_vtk_imagedata(pbar, G)
pbar.close()
self.printer.print()
self.printer.print('')
memGPU = ''
if config.cuda['gpus']: