Fix: missed viscosity value

Fix: postProcess incorrect log path
Mod: flake8 poetry deps
This commit is contained in:
L-Nafaryus 2021-12-25 13:35:23 +05:00
parent 9d4aac4652
commit 11b612a99f
No known key found for this signature in database
GPG Key ID: C76D8DCD2727DBB7
6 changed files with 64 additions and 10 deletions

View File

@ -16,10 +16,9 @@ class PostProcess(object):
self.path = path.abspath(dirpath)
def flowRate(self, patch: str):
# TODO: fix wrong log path
func = "patchFlowRate(patch={})".format(patch)
filepath = path.join(self.path, "postProcessing", func, "0", "surfaceFieldValue.dat")
postProcess(func, cwd = self.path)
postProcess(func, cwd = self.path, logpath = self.path)
surfaceFieldValue = datReader(filepath)
return surfaceFieldValue["sum(phi)"][-1]

View File

@ -217,12 +217,13 @@ class UltimateRunner(object):
def computeFlow(self):
params = self.config.params
flowParams = self.database.getFlowOnephase(
query = (
params["label"],
params["direction"],
params["alpha"],
self.exec_id
)
flowParams = self.database.getFlowOnephase(*query)
logger.info("Computing flow for {} with direction = {} and alpha = {}".format(
params["label"], params["direction"], params["alpha"]
@ -233,10 +234,12 @@ class UltimateRunner(object):
with self.database:
flowParams.save()
with self.database:
self.flow = OnePhaseFlow(
direction = params["direction"],
**flowParams.select().dicts().get(),
**self.database.getFlowOnephase(*query, to_dict = True),
path = self.casepath()
)

View File

@ -97,7 +97,7 @@ class Database(SqliteDatabase):
return table
def getFlowOnephase(self, label = None, direction = None, alpha = None, execution = None, **kwargs):
def getFlowOnephase(self, label = None, direction = None, alpha = None, execution = None, to_dict = False, **kwargs):
execution = execution or self.getLatest()
query = (
models.FlowOnephase
@ -114,6 +114,10 @@ class Database(SqliteDatabase):
)
with self:
table = query.get() if query.exists() else None
if to_dict:
table = query.dicts().get() if query.exists() else None
else:
table = query.get() if query.exists() else None
return table

View File

@ -51,6 +51,8 @@ class FoamRunner(object):
if self.logpath:
with proc, open(self.logpath, "w") as io:
while True:
output = proc.stdout.read(1)
if output == "" and proc.poll() is not None:
@ -59,7 +61,12 @@ class FoamRunner(object):
if not output == "":
io.write(output)
self.output, self.error = proc.communicate()
error = proc.stderr.read()
if not error == "":
self.error = error
io.write(error)
self.returncode = proc.returncode
if self.logpath and self.error:

45
poetry.lock generated
View File

@ -134,6 +134,19 @@ category = "dev"
optional = true
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
[[package]]
name = "flake8"
version = "4.0.1"
description = "the modular source code checker: pep8 pyflakes and co"
category = "main"
optional = false
python-versions = ">=3.6"
[package.dependencies]
mccabe = ">=0.6.0,<0.7.0"
pycodestyle = ">=2.8.0,<2.9.0"
pyflakes = ">=2.4.0,<2.5.0"
[[package]]
name = "fonttools"
version = "4.28.1"
@ -241,6 +254,14 @@ pyparsing = ">=2.2.1"
python-dateutil = ">=2.7"
setuptools_scm = ">=4"
[[package]]
name = "mccabe"
version = "0.6.1"
description = "McCabe checker, plugin for flake8"
category = "main"
optional = false
python-versions = "*"
[[package]]
name = "numpy"
version = "1.21.4"
@ -346,7 +367,7 @@ python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
name = "pycodestyle"
version = "2.8.0"
description = "Python style guide checker"
category = "dev"
category = "main"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
@ -361,6 +382,14 @@ python-versions = "*"
[package.dependencies]
stdlib-list = "*"
[[package]]
name = "pyflakes"
version = "2.4.0"
description = "passive checker of Python programs"
category = "main"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
[[package]]
name = "pyfoam"
version = "2021.6"
@ -739,7 +768,7 @@ docs = []
[metadata]
lock-version = "1.1"
python-versions = ">=3.9,<3.11"
content-hash = "2c64a48e55f744606cbe36145764db1d47f9c6f48118a961ddc4a8918ef4d78e"
content-hash = "47b4c70e61dfa848eff69c0edcaaf59db6eac989a4635994ee02ec96a9f05754"
[metadata.files]
alabaster = [
@ -842,6 +871,10 @@ docutils = [
{file = "docutils-0.17.1-py2.py3-none-any.whl", hash = "sha256:cf316c8370a737a022b72b56874f6602acf974a37a9fba42ec2876387549fc61"},
{file = "docutils-0.17.1.tar.gz", hash = "sha256:686577d2e4c32380bb50cbb22f575ed742d58168cee37e99117a854bcd88f125"},
]
flake8 = [
{file = "flake8-4.0.1-py2.py3-none-any.whl", hash = "sha256:479b1304f72536a55948cb40a32dce8bb0ffe3501e26eaf292c7e60eb5e0428d"},
{file = "flake8-4.0.1.tar.gz", hash = "sha256:806e034dda44114815e23c16ef92f95c91e4c71100ff52813adf7132a6ad870d"},
]
fonttools = [
{file = "fonttools-4.28.1-py3-none-any.whl", hash = "sha256:68071406009e7ef6a5fdcd85d95975cd6963867bb226f2b786bfffe15d1959ef"},
{file = "fonttools-4.28.1.zip", hash = "sha256:8c8f84131bf04f3b1dcf99b9763cec35c347164ab6ad006e18d2f99fcab05529"},
@ -1020,6 +1053,10 @@ matplotlib = [
{file = "matplotlib-3.5.0-pp37-pypy37_pp73-win_amd64.whl", hash = "sha256:a0ea10faa3bab0714d3a19c7e0921279a68d57552414d6eceaea99f97d7735db"},
{file = "matplotlib-3.5.0.tar.gz", hash = "sha256:38892a254420d95594285077276162a5e9e9c30b6da08bdc2a4d53331ad9a6fa"},
]
mccabe = [
{file = "mccabe-0.6.1-py2.py3-none-any.whl", hash = "sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42"},
{file = "mccabe-0.6.1.tar.gz", hash = "sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f"},
]
numpy = [
{file = "numpy-1.21.4-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:8890b3360f345e8360133bc078d2dacc2843b6ee6059b568781b15b97acbe39f"},
{file = "numpy-1.21.4-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:69077388c5a4b997442b843dbdc3a85b420fb693ec8e33020bb24d647c164fa5"},
@ -1151,6 +1188,10 @@ pydeps = [
{file = "pydeps-1.10.12-py3-none-any.whl", hash = "sha256:32659da82b220a0e4f8f7b2a618d3d590dc6525850df86d10427cc1be0dbe55d"},
{file = "pydeps-1.10.12.tar.gz", hash = "sha256:712a44a211f47b9b5a1ff6e98e2765ed3fbaf926c194ea6081d4893786c576ec"},
]
pyflakes = [
{file = "pyflakes-2.4.0-py2.py3-none-any.whl", hash = "sha256:3bb3a3f256f4b7968c9c788781e4ff07dce46bdf12339dcda61053375426ee2e"},
{file = "pyflakes-2.4.0.tar.gz", hash = "sha256:05a85c2872edf37a4ed30b0cce2f6093e1d0581f8c19d7393122da7e25b2b24c"},
]
pyfoam = [
{file = "PyFoam-2021.6-py2.py3-none-any.whl", hash = "sha256:2f1e3461f03c480060ae6dfba81bbeb5e21d33c64b825666ad4d94cdbd11e674"},
{file = "PyFoam-2021.6.tar.gz", hash = "sha256:e0513d122b09a32427e817f1a8c14d74db1376bf942a13b505dd029f16cab44e"},

View File

@ -37,9 +37,9 @@ dill = "^0.3.4"
[tool.poetry.dev-dependencies]
pytest = "^6.2.5"
flake8 = "^4.0.1"
vulture = "^2.3"
pytest-cov = "^3.0.0"
pycodestyle = "^2.8.0"
pydeps = {version = "^1.10.12", optional = true}
peewee-erd = {version = "^0.1.3", optional = true}
Sphinx = {version = "^4.3.0", optional = true}