Added fallback values for openfoam run config
This commit is contained in:
parent
e005717748
commit
0330a0d32d
4 changed files with 31 additions and 15 deletions
|
@ -1 +0,0 @@
|
|||
*.stl
|
|
@ -34,7 +34,7 @@ regions
|
|||
}
|
||||
surfaceToCell
|
||||
{
|
||||
file "./constant/triSurface/rub.stl";
|
||||
file "./constant/triSurface/rubble.stl";
|
||||
outsidePoints ((0 0 0)); // definition of outside
|
||||
includeCut true; // cells cut by surface
|
||||
includeInside true; // cells not on outside of surf
|
||||
|
|
|
@ -4,6 +4,10 @@ work_dir = /home/masterccce/OpenFOAM/work
|
|||
case = artha
|
||||
#log_file = openfoam.log
|
||||
|
||||
[stl]
|
||||
copy = True
|
||||
from = ../bathymetry/2_stl
|
||||
|
||||
[blockMesh]
|
||||
enable = True
|
||||
[snappyHexMesh]
|
||||
|
@ -13,7 +17,7 @@ enable = True
|
|||
[olaFlow]
|
||||
enable = True
|
||||
[parallel]
|
||||
enable = False
|
||||
enable = True
|
||||
threads = 4
|
||||
[reconstructPar]
|
||||
enable = True
|
||||
|
|
|
@ -26,21 +26,21 @@ config = configparser.ConfigParser()
|
|||
config.read(args.config)
|
||||
|
||||
logging.basicConfig(
|
||||
filename=config['main'].get('log_file', None),
|
||||
filename=config.get('main', 'log_file', fallback=None),
|
||||
level=args.log_level
|
||||
)
|
||||
log = logging.getLogger('openfoam')
|
||||
|
||||
log.info('Starting program')
|
||||
|
||||
input_dir = Path(config['main']['input_dir'], config['main']['case'])
|
||||
work_dir = Path(config['main']['work_dir'])
|
||||
input_dir = Path(config.get('main', 'input_dir'), config.get('main', 'case'))
|
||||
work_dir = Path(config.get('main', 'work_dir'))
|
||||
|
||||
if not work_dir.exists():
|
||||
log.error(f'Work directory ({work_dir}) not found')
|
||||
sys.exit(1)
|
||||
|
||||
case_dir = work_dir.joinpath(config['main']['case'])
|
||||
case_dir = work_dir.joinpath(config.get('main', 'case'))
|
||||
if case_dir.exists():
|
||||
log.info(f'Deleting case ({case_dir})')
|
||||
dir_util.remove_tree(str(case_dir))
|
||||
|
@ -51,7 +51,20 @@ dir_util.copy_tree(
|
|||
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')
|
||||
blockmesh_log = logging.getLogger('blockMesh')
|
||||
proc = sp.Popen(
|
||||
|
@ -71,7 +84,7 @@ if config['blockMesh'].getboolean('enable'):
|
|||
sys.exit(code)
|
||||
log.info(f'blockMesh finished successfully')
|
||||
|
||||
if config['snappyHexMesh'].getboolean('enable'):
|
||||
if config.getboolean('snappyHexMesh', 'enable', fallback=False):
|
||||
log.info('Running snappyHexMesh')
|
||||
snappy_log = logging.getLogger('snappyHexMesh')
|
||||
proc = sp.Popen(
|
||||
|
@ -97,7 +110,7 @@ dir_util.copy_tree(
|
|||
str(case_dir.joinpath('0')),
|
||||
)
|
||||
|
||||
if config['setFields'].getboolean('enable'):
|
||||
if config.getboolean('setFields', 'enable', fallback=False):
|
||||
log.info('Running setFields')
|
||||
setfields_log = logging.getLogger('setFields')
|
||||
proc = sp.Popen(
|
||||
|
@ -117,12 +130,12 @@ if config['setFields'].getboolean('enable'):
|
|||
sys.exit(code)
|
||||
log.info(f'setFields finished successfully')
|
||||
|
||||
if config['olaFlow'].getboolean('enable'):
|
||||
if config.getboolean('olaFlow', 'enable', fallback=False):
|
||||
cmd = ('olaFlow')
|
||||
if config['parallel'].getboolean('enable'):
|
||||
if config.getboolean('parallel', 'enable', fallback=False):
|
||||
cmd = (
|
||||
'mpirun',
|
||||
'-np', config['parallel'].getint('threads'),
|
||||
'-np', config.get('parallel', 'threads'),
|
||||
'olaFlow', '-parallel'
|
||||
)
|
||||
decpar_log = logging.getLogger('decomposePar')
|
||||
|
@ -162,8 +175,8 @@ if config['olaFlow'].getboolean('enable'):
|
|||
sys.exit(code)
|
||||
log.info(f'olaFlow finished successfully')
|
||||
|
||||
if config['parallel'].getboolean('enable') \
|
||||
and config['reconstructPar'].getboolean('enable'):
|
||||
if config.getboolean('parallel', 'enable', fallback=False) \
|
||||
and config.getboolean('reconstructPar', 'enable', fallback=False):
|
||||
recpar_log = logging.getLogger('reconstructPar')
|
||||
proc = sp.Popen(
|
||||
('reconstructPar'),
|
||||
|
|
Reference in a new issue