Commit 91c069d6 authored by Cristian Lalescu's avatar Cristian Lalescu
Browse files

executable script works for FluidResize

parent a12f0a4a
......@@ -24,10 +24,13 @@
from ._fluid_base import _fluid_particle_base
import os
import argparse
import numpy as np
import bfps
from ._fluid_base import _fluid_particle_base
class FluidResize(_fluid_particle_base):
"""This class is meant to resize snapshots of DNS states to new grids.
Typical stuff for DNS of turbulence.
......@@ -109,11 +112,45 @@ class FluidResize(_fluid_particle_base):
parser):
_fluid_particle_base.specific_parser_arguments(self, parser)
parser.add_argument(
'-N',
'-m',
type = int,
dest = 'N',
dest = 'm',
default = 32,
metavar = 'M',
help = 'resize from N to M')
parser.add_argument(
'--src_wd',
type = str,
dest = 'src_work_dir',
required = True)
parser.add_argument(
'--src_iteration',
type = int,
dest = 'src_iteration',
required = True)
return None
def launch(
self,
args = [],
**kwargs):
parser = argparse.ArgumentParser('bfps ' + type(self).__name__)
self.add_parser_arguments(parser)
opt = parser.parse_args(args)
cmd_line_pars = vars(opt)
for k in ['dst_nx', 'dst_ny', 'dst_nz']:
if type(cmd_line_pars[k]) == type(None):
cmd_line_pars[k] = opt.m
self.pars_from_namespace(opt)
src_file = os.path.join(
opt.src_work_dir,
opt.src_simname + '_cvorticity_i{0:0>5x}'.format(opt.src_iteration))
read_file = os.path.join(
self.work_dir,
opt.src_simname + '_cvorticity_i{0:0>5x}'.format(opt.src_iteration))
if not os.path.exists(read_file):
os.symlink(src_file, read_file)
self.set_host_info(bfps.host_info)
self.write_par(iter0 = opt.src_iteration)
self.run(ncpu = opt.ncpu)
return None
......@@ -92,25 +92,21 @@ parser.add_argument(
def double(opt):
old_simname = 'N{0:0>3x}'.format(opt.n)
new_simname = 'N{0:0>3x}'.format(opt.n*2)
c = FluidResize(
work_dir = opt.work_dir,
simname = old_simname + '_double',
dtype = opt.precision)
c.parameters['nx'] = opt.n
c.parameters['ny'] = opt.n
c.parameters['nz'] = opt.n
c.parameters['dst_nx'] = 2*opt.n
c.parameters['dst_ny'] = 2*opt.n
c.parameters['dst_nz'] = 2*opt.n
c.parameters['dst_simname'] = new_simname
c.parameters['src_simname'] = old_simname
c.parameters['niter_todo'] = 0
c.write_src()
c.set_host_info({'type' : 'pc'})
c.write_par()
c.run(ncpu = opt.ncpu,
err_file = 'err_',
out_file = 'out_')
c = FluidResize(dtype = opt.precision)
c.launch(
args = ['--simname', old_simname + '_double',
'--wd', opt.work_dir,
'--nx', '{0}'.format(opt.n),
'--ny', '{0}'.format(opt.n),
'--nz', '{0}'.format(opt.n),
'--dst_nx', '{0}'.format(2*opt.n),
'--dst_ny', '{0}'.format(2*opt.n),
'--dst_nz', '{0}'.format(2*opt.n),
'--dst_simname', new_simname,
'--src_simname', old_simname,
'--src_iteration', '0',
'--src_wd', './',
'--niter_todo', '0'])
return None
def launch(
......
......@@ -6,7 +6,7 @@
(C) code overview @documentation
(C) move stat I/O to cpp lib @design @HDF5
(C) test involving hydrodynamic similarity @tests
(C) tests should use launch instead of bfps.get_parser @design @tests
(C) tests should use launch instead of get_parser @design @tests
(C) use HDF5 io for fields @design @HDF5 +I/O
(D) generalize interpolation comparison test @tests
(D) generate separate lib(s) with extra classes @tests +alternate_algorithms
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment