Commit 7b5555e8 authored by Cristian Lalescu's avatar Cristian Lalescu
Browse files

actually use environment parameter

parent 4d85e899
...@@ -133,13 +133,12 @@ class FluidResize(_fluid_particle_base): ...@@ -133,13 +133,12 @@ class FluidResize(_fluid_particle_base):
self, self,
args = [], args = [],
**kwargs): **kwargs):
parser = argparse.ArgumentParser('bfps ' + type(self).__name__) opt = self.prepare_launch(args)
self.add_parser_arguments(parser)
opt = parser.parse_args(args)
cmd_line_pars = vars(opt) cmd_line_pars = vars(opt)
for k in ['dst_nx', 'dst_ny', 'dst_nz']: for k in ['dst_nx', 'dst_ny', 'dst_nz']:
if type(cmd_line_pars[k]) == type(None): if type(cmd_line_pars[k]) == type(None):
cmd_line_pars[k] = opt.m cmd_line_pars[k] = opt.m
self.parameters['niter_todo'] = 0
self.pars_from_namespace(opt) self.pars_from_namespace(opt)
src_file = os.path.join( src_file = os.path.join(
os.path.realpath(opt.src_work_dir), os.path.realpath(opt.src_work_dir),
......
...@@ -30,6 +30,7 @@ import h5py ...@@ -30,6 +30,7 @@ import h5py
import argparse import argparse
import bfps import bfps
from ._code import _code
from ._fluid_base import _fluid_particle_base from ._fluid_base import _fluid_particle_base
class NavierStokes(_fluid_particle_base): class NavierStokes(_fluid_particle_base):
...@@ -976,12 +977,10 @@ class NavierStokes(_fluid_particle_base): ...@@ -976,12 +977,10 @@ class NavierStokes(_fluid_particle_base):
self, self,
args = [], args = [],
**kwargs): **kwargs):
opt = self.prepare_launch(args)
# with the default Lundgren forcing, I can estimate the dissipation # with the default Lundgren forcing, I can estimate the dissipation
# with nondefault forcing, figure out the amplitude for this viscosity # with nondefault forcing, figure out the amplitude for this viscosity
# yourself # yourself
parser = argparse.ArgumentParser('bfps ' + type(self).__name__)
self.add_parser_arguments(parser)
opt = parser.parse_args(args)
self.QR_stats_on = opt.QR_stats self.QR_stats_on = opt.QR_stats
self.parameters['nu'] = (opt.kMeta * 2 / opt.n)**(4./3) self.parameters['nu'] = (opt.kMeta * 2 / opt.n)**(4./3)
self.parameters['dt'] = (opt.dtfactor / opt.n) self.parameters['dt'] = (opt.dtfactor / opt.n)
...@@ -1001,7 +1000,6 @@ class NavierStokes(_fluid_particle_base): ...@@ -1001,7 +1000,6 @@ class NavierStokes(_fluid_particle_base):
self.fill_up_fluid_code() self.fill_up_fluid_code()
self.finalize_code() self.finalize_code()
self.write_src() self.write_src()
self.set_host_info(bfps.host_info)
if not os.path.exists(os.path.join(self.work_dir, self.simname + '.h5')): if not os.path.exists(os.path.join(self.work_dir, self.simname + '.h5')):
self.write_par() self.write_par()
if self.parameters['nparticles'] > 0: if self.parameters['nparticles'] > 0:
......
...@@ -29,7 +29,6 @@ import argparse ...@@ -29,7 +29,6 @@ import argparse
import bfps import bfps
from .NavierStokes import NavierStokes from .NavierStokes import NavierStokes
from .FluidConvert import FluidConvert
from .FluidResize import FluidResize from .FluidResize import FluidResize
def main(): def main():
......
...@@ -166,7 +166,7 @@ class _base(object): ...@@ -166,7 +166,7 @@ class _base(object):
'--environment', '--environment',
type = str, type = str,
dest = 'environment', dest = 'environment',
default = '') default = None)
parser.add_argument( parser.add_argument(
'--wd', '--wd',
type = str, dest = 'work_dir', type = str, dest = 'work_dir',
......
...@@ -28,6 +28,7 @@ import os ...@@ -28,6 +28,7 @@ import os
import sys import sys
import shutil import shutil
import subprocess import subprocess
import argparse
import h5py import h5py
from datetime import datetime from datetime import datetime
import math import math
...@@ -263,4 +264,15 @@ class _code(_base): ...@@ -263,4 +264,15 @@ class _code(_base):
script_file.write('exit 0\n') script_file.write('exit 0\n')
script_file.close() script_file.close()
return None return None
def prepare_launch(
self,
args = [],
**kwargs):
parser = argparse.ArgumentParser('bfps ' + type(self).__name__)
self.add_parser_arguments(parser)
opt = parser.parse_args(args)
self.set_host_info(bfps.host_info)
if type(opt.environment) != type(None):
self.host_info['environment'] = opt.environment
return opt
...@@ -396,9 +396,4 @@ class _fluid_particle_base(_code): ...@@ -396,9 +396,4 @@ class _fluid_particle_base(_code):
nshells = kspace['nshell'].shape[0] nshells = kspace['nshell'].shape[0]
ofile.close() ofile.close()
return None return None
def launch(
self,
args = [],
**kwargs):
return None
Markdown is supported
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