Added fallback values for openfoam run config

This commit is contained in:
Edgar P. Burkhart 2022-01-23 13:16:00 +01:00
parent e005717748
commit 0330a0d32d
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227
4 changed files with 31 additions and 15 deletions

View file

@ -1 +0,0 @@
*.stl

View file

@ -34,7 +34,7 @@ regions
} }
surfaceToCell surfaceToCell
{ {
file "./constant/triSurface/rub.stl"; file "./constant/triSurface/rubble.stl";
outsidePoints ((0 0 0)); // definition of outside outsidePoints ((0 0 0)); // definition of outside
includeCut true; // cells cut by surface includeCut true; // cells cut by surface
includeInside true; // cells not on outside of surf includeInside true; // cells not on outside of surf

View file

@ -4,6 +4,10 @@ work_dir = /home/masterccce/OpenFOAM/work
case = artha case = artha
#log_file = openfoam.log #log_file = openfoam.log
[stl]
copy = True
from = ../bathymetry/2_stl
[blockMesh] [blockMesh]
enable = True enable = True
[snappyHexMesh] [snappyHexMesh]
@ -13,7 +17,7 @@ enable = True
[olaFlow] [olaFlow]
enable = True enable = True
[parallel] [parallel]
enable = False enable = True
threads = 4 threads = 4
[reconstructPar] [reconstructPar]
enable = True enable = True

View file

@ -26,21 +26,21 @@ config = configparser.ConfigParser()
config.read(args.config) config.read(args.config)
logging.basicConfig( logging.basicConfig(
filename=config['main'].get('log_file', None), filename=config.get('main', 'log_file', fallback=None),
level=args.log_level level=args.log_level
) )
log = logging.getLogger('openfoam') log = logging.getLogger('openfoam')
log.info('Starting program') log.info('Starting program')
input_dir = Path(config['main']['input_dir'], config['main']['case']) input_dir = Path(config.get('main', 'input_dir'), config.get('main', 'case'))
work_dir = Path(config['main']['work_dir']) work_dir = Path(config.get('main', 'work_dir'))
if not work_dir.exists(): if not work_dir.exists():
log.error(f'Work directory ({work_dir}) not found') log.error(f'Work directory ({work_dir}) not found')
sys.exit(1) sys.exit(1)
case_dir = work_dir.joinpath(config['main']['case']) case_dir = work_dir.joinpath(config.get('main', 'case'))
if case_dir.exists(): if case_dir.exists():
log.info(f'Deleting case ({case_dir})') log.info(f'Deleting case ({case_dir})')
dir_util.remove_tree(str(case_dir)) dir_util.remove_tree(str(case_dir))
@ -51,7 +51,20 @@ dir_util.copy_tree(
str(case_dir), str(case_dir),
) )
if config['blockMesh'].getboolean('enable'): if config.getboolean('stl', 'copy', fallback=False):
stl_dir = case_dir.joinpath('constant', 'triSurface')
if stl_dir.exists():
log.info(f'Deleting stl directory ({stl_dir})')
dir_util.remove_tree(str(stl_dir))
stl_in = Path(config.get('stl', 'from'))
log.info(f'Copying stl directory ({stl_in} -> {stl_dir})')
dir_util.copy_tree(
str(stl_in),
str(stl_dir),
)
if config.getboolean('blockMesh', 'enable', fallback=False):
log.info('Running blockMesh') log.info('Running blockMesh')
blockmesh_log = logging.getLogger('blockMesh') blockmesh_log = logging.getLogger('blockMesh')
proc = sp.Popen( proc = sp.Popen(
@ -71,7 +84,7 @@ if config['blockMesh'].getboolean('enable'):
sys.exit(code) sys.exit(code)
log.info(f'blockMesh finished successfully') log.info(f'blockMesh finished successfully')
if config['snappyHexMesh'].getboolean('enable'): if config.getboolean('snappyHexMesh', 'enable', fallback=False):
log.info('Running snappyHexMesh') log.info('Running snappyHexMesh')
snappy_log = logging.getLogger('snappyHexMesh') snappy_log = logging.getLogger('snappyHexMesh')
proc = sp.Popen( proc = sp.Popen(
@ -97,7 +110,7 @@ dir_util.copy_tree(
str(case_dir.joinpath('0')), str(case_dir.joinpath('0')),
) )
if config['setFields'].getboolean('enable'): if config.getboolean('setFields', 'enable', fallback=False):
log.info('Running setFields') log.info('Running setFields')
setfields_log = logging.getLogger('setFields') setfields_log = logging.getLogger('setFields')
proc = sp.Popen( proc = sp.Popen(
@ -117,12 +130,12 @@ if config['setFields'].getboolean('enable'):
sys.exit(code) sys.exit(code)
log.info(f'setFields finished successfully') log.info(f'setFields finished successfully')
if config['olaFlow'].getboolean('enable'): if config.getboolean('olaFlow', 'enable', fallback=False):
cmd = ('olaFlow') cmd = ('olaFlow')
if config['parallel'].getboolean('enable'): if config.getboolean('parallel', 'enable', fallback=False):
cmd = ( cmd = (
'mpirun', 'mpirun',
'-np', config['parallel'].getint('threads'), '-np', config.get('parallel', 'threads'),
'olaFlow', '-parallel' 'olaFlow', '-parallel'
) )
decpar_log = logging.getLogger('decomposePar') decpar_log = logging.getLogger('decomposePar')
@ -162,8 +175,8 @@ if config['olaFlow'].getboolean('enable'):
sys.exit(code) sys.exit(code)
log.info(f'olaFlow finished successfully') log.info(f'olaFlow finished successfully')
if config['parallel'].getboolean('enable') \ if config.getboolean('parallel', 'enable', fallback=False) \
and config['reconstructPar'].getboolean('enable'): and config.getboolean('reconstructPar', 'enable', fallback=False):
recpar_log = logging.getLogger('reconstructPar') recpar_log = logging.getLogger('reconstructPar')
proc = sp.Popen( proc = sp.Popen(
('reconstructPar'), ('reconstructPar'),