diff --git a/openfoam/run/__main__.py b/openfoam/run/__main__.py index 67b9ef2..37a20c3 100644 --- a/openfoam/run/__main__.py +++ b/openfoam/run/__main__.py @@ -14,6 +14,7 @@ import subprocess as sp import urllib.error from .grafana import Silencer +from .stl import copy_stl _t0 = time() @@ -68,13 +69,8 @@ if config.getboolean('stl', 'copy', fallback=False): log.error(f'STL from directory does not exist ({stl_in})') sys.exit(1) - stl_dir = case_dir.joinpath('constant', 'triSurface') - if stl_dir.exists(): - log.info(f'Deleting stl directory ({stl_dir})') - shutil.rmtree(stl_dir) - - log.info(f'Copying stl directory ({stl_in} -> {stl_dir})') - shutil.copytree(stl_in, stl_dir) + log.info(f'Copying stl directory ({stl_in})') + copy_stl(stl_in, case_dir) if config.getboolean('blockMesh', 'enable', fallback=False): log.info('Running blockMesh') diff --git a/openfoam/run/stl.py b/openfoam/run/stl.py new file mode 100644 index 0000000..b932bd4 --- /dev/null +++ b/openfoam/run/stl.py @@ -0,0 +1,13 @@ +import shutil +import logging + +log = logging.getLogger('stl') + +def copy_stl(stl, case): + stl_dir = case.joinpath('constant', 'triSurface') + if stl_dir.exists(): + log.info(f'Deleting stl directory ({stl_dir})') + shutil.rmtree(stl_dir) + + log.info(f'Copying stl directory ({stl} -> {stl_dir})') + shutil.copytree(stl, stl_dir)