Moved blockMesh to module
This commit is contained in:
parent
77838e186b
commit
2d9ac27812
2 changed files with 24 additions and 16 deletions
|
@ -15,6 +15,7 @@ import urllib.error
|
||||||
|
|
||||||
from .grafana import Silencer
|
from .grafana import Silencer
|
||||||
from .stl import copy_stl
|
from .stl import copy_stl
|
||||||
|
from .blockmesh import blockmesh
|
||||||
|
|
||||||
|
|
||||||
_t0 = time()
|
_t0 = time()
|
||||||
|
@ -74,22 +75,7 @@ if config.getboolean('stl', 'copy', fallback=False):
|
||||||
|
|
||||||
if config.getboolean('blockMesh', 'enable', fallback=False):
|
if config.getboolean('blockMesh', 'enable', fallback=False):
|
||||||
log.info('Running blockMesh')
|
log.info('Running blockMesh')
|
||||||
blockmesh_log = logging.getLogger('blockMesh')
|
blockmesh(case_dir)
|
||||||
proc = sp.Popen(
|
|
||||||
('blockMesh'),
|
|
||||||
cwd=case_dir,
|
|
||||||
stdout=sp.PIPE,
|
|
||||||
stderr=sp.PIPE,
|
|
||||||
text=True,
|
|
||||||
)
|
|
||||||
for line in proc.stdout:
|
|
||||||
blockmesh_log.info(line[:-1])
|
|
||||||
for line in proc.stderr:
|
|
||||||
blockmesh_log.error(line[:-1])
|
|
||||||
code = proc.wait()
|
|
||||||
if code != 0:
|
|
||||||
log.error('blockMesh failed')
|
|
||||||
sys.exit(code)
|
|
||||||
log.info(f'blockMesh finished successfully')
|
log.info(f'blockMesh finished successfully')
|
||||||
|
|
||||||
if config.getboolean('snappyHexMesh', 'enable', fallback=False):
|
if config.getboolean('snappyHexMesh', 'enable', fallback=False):
|
||||||
|
|
22
openfoam/run/blockmesh.py
Normal file
22
openfoam/run/blockmesh.py
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
import subprocess as sp
|
||||||
|
import logging
|
||||||
|
|
||||||
|
def blockmesh(case_dir):
|
||||||
|
blockmesh_log = logging.getLogger('blockMesh')
|
||||||
|
proc = sp.Popen(
|
||||||
|
('blockMesh'),
|
||||||
|
cwd=case_dir,
|
||||||
|
stdout=sp.PIPE,
|
||||||
|
stderr=sp.PIPE,
|
||||||
|
text=True,
|
||||||
|
)
|
||||||
|
for line in proc.stdout:
|
||||||
|
blockmesh_log.info(line[:-1])
|
||||||
|
for line in proc.stderr:
|
||||||
|
blockmesh_log.error(line[:-1])
|
||||||
|
code = proc.wait()
|
||||||
|
if code != 0:
|
||||||
|
log.error('blockMesh failed')
|
||||||
|
sys.exit(code)
|
||||||
|
|
||||||
|
|
Reference in a new issue