Moved blockMesh to module

This commit is contained in:
Edgar P. Burkhart 2022-01-26 18:08:17 +01:00
parent 77838e186b
commit 2d9ac27812
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227
2 changed files with 24 additions and 16 deletions

View file

@ -15,6 +15,7 @@ import urllib.error
from .grafana import Silencer
from .stl import copy_stl
from .blockmesh import blockmesh
_t0 = time()
@ -74,22 +75,7 @@ if config.getboolean('stl', 'copy', fallback=False):
if config.getboolean('blockMesh', 'enable', fallback=False):
log.info('Running blockMesh')
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)
blockmesh(case_dir)
log.info(f'blockMesh finished successfully')
if config.getboolean('snappyHexMesh', 'enable', fallback=False):

22
openfoam/run/blockmesh.py Normal file
View 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)