Updated config
This commit is contained in:
parent
6ea7db1c34
commit
f1d61d0a4c
3 changed files with 15 additions and 12 deletions
|
@ -5,12 +5,13 @@ parser = argparse.ArgumentParser(
|
||||||
)
|
)
|
||||||
parser.add_argument('var', type=str,
|
parser.add_argument('var', type=str,
|
||||||
help='OpenFoam variable to display')
|
help='OpenFoam variable to display')
|
||||||
parser.add_argument('-c', '--config', type=str,
|
parser.add_argument('-c', '--config', type=Path, default='config.ini',
|
||||||
default='config.ini',
|
help='configuration file (default config.ini)')
|
||||||
help='Configuration file (default config.ini)')
|
parser.add_argument('-l', '--log-level', default='info', type=str,
|
||||||
|
help='log level')
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
if args.var == 'alpha.water':
|
if args.var == 'alpha.water':
|
||||||
import alpha_water
|
import alpha_water
|
||||||
alpha_water.animate(args.config)
|
alpha_water.animate(args.config, args.log_level)
|
||||||
|
|
|
@ -19,19 +19,21 @@ import pandas as pd
|
||||||
mpl.use('agg')
|
mpl.use('agg')
|
||||||
|
|
||||||
import fluidfoam
|
import fluidfoam
|
||||||
#import stl
|
|
||||||
|
|
||||||
def animate(config_path):
|
def animate(config_path, log_level):
|
||||||
tt0 = time()
|
tt0 = time()
|
||||||
|
|
||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
config.read(config_path)
|
config.read(config_path)
|
||||||
|
|
||||||
|
logging.basicConfig(
|
||||||
|
filename=config.get('main', 'log_file', fallback=None),
|
||||||
|
level=log_level
|
||||||
|
)
|
||||||
log = logging.getLogger('alpha_water')
|
log = logging.getLogger('alpha_water')
|
||||||
logging.basicConfig(encoding='utf-8', level=config['main']['logging'])
|
|
||||||
log.info('Starting')
|
log.info('Starting')
|
||||||
|
|
||||||
root = Path(config['main']['root']).expanduser()
|
root = Path(config.get('main', 'root')).expanduser()
|
||||||
|
|
||||||
t = []
|
t = []
|
||||||
|
|
||||||
|
@ -61,13 +63,13 @@ def animate(config_path):
|
||||||
alpha_water['y'] = mesh[2]
|
alpha_water['y'] = mesh[2]
|
||||||
|
|
||||||
with pd.HDFStore(
|
with pd.HDFStore(
|
||||||
config['data']['path'],
|
config.get('data', 'path'),
|
||||||
mode='r',
|
mode='r',
|
||||||
) as hdf:
|
) as hdf:
|
||||||
bathy = hdf.get('bathy')
|
bathy = hdf.get('bathy')
|
||||||
rubble = hdf.get('rubble')
|
rubble = hdf.get('rubble')
|
||||||
blocs = {}
|
blocs = {}
|
||||||
for bloc in config['data']['blocs'].split(','):
|
for bloc in config.get('data', 'blocs', fallback='').split(','):
|
||||||
blocs[bloc] = hdf.get(bloc)
|
blocs[bloc] = hdf.get(bloc)
|
||||||
|
|
||||||
log.info('Starting plot')
|
log.info('Starting plot')
|
||||||
|
@ -132,6 +134,6 @@ def animate(config_path):
|
||||||
blit=True,
|
blit=True,
|
||||||
repeat=True
|
repeat=True
|
||||||
)
|
)
|
||||||
ani.save(config['main']['out'])
|
ani.save(config.get('main', 'out'))
|
||||||
|
|
||||||
log.info('Program ended successfully')
|
log.info('Program ended successfully')
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[main]
|
[main]
|
||||||
logging = INFO
|
|
||||||
root = /home/masterccce/OpenFOAM/work/artha
|
root = /home/masterccce/OpenFOAM/work/artha
|
||||||
out = out/anim.mp4
|
out = out/anim.mp4
|
||||||
|
#log_file = openfoam.log
|
||||||
|
|
||||||
[data]
|
[data]
|
||||||
path = ../bathymetry/3_pd/data.hdf
|
path = ../bathymetry/3_pd/data.hdf
|
||||||
|
|
Reference in a new issue