Mod: -
This commit is contained in:
parent
120c2f260c
commit
085ec5a0e2
@ -23,6 +23,9 @@ import os
|
|||||||
env = dict(
|
env = dict(
|
||||||
ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
|
ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
|
||||||
)
|
)
|
||||||
|
env.update(
|
||||||
|
CLI = os.path.join(env["ROOT"], "anisotropy/core/cli.py")
|
||||||
|
)
|
||||||
env.update(
|
env.update(
|
||||||
BUILD = os.path.join(env["ROOT"], "build"),
|
BUILD = os.path.join(env["ROOT"], "build"),
|
||||||
LOG = os.path.join(env["ROOT"], "logs"),
|
LOG = os.path.join(env["ROOT"], "logs"),
|
||||||
|
@ -43,7 +43,8 @@ import logging
|
|||||||
)
|
)
|
||||||
def compute(path, configFile, nprocs, stage, overwrite):
|
def compute(path, configFile, nprocs, stage, overwrite):
|
||||||
from anisotropy.core.runner import UltimateRunner
|
from anisotropy.core.runner import UltimateRunner
|
||||||
from anisotropy.core.config import Config, DefaultConfig
|
from anisotropy.core.config import DefaultConfig
|
||||||
|
from copy import deepcopy
|
||||||
|
|
||||||
config = DefaultConfig()
|
config = DefaultConfig()
|
||||||
|
|
||||||
@ -57,7 +58,18 @@ def compute(path, configFile, nprocs, stage, overwrite):
|
|||||||
)
|
)
|
||||||
config.expand()
|
config.expand()
|
||||||
|
|
||||||
runner = UltimateRunner()
|
baseRunner = UltimateRunner(config = config, exec_id = True)
|
||||||
|
queue = []
|
||||||
|
|
||||||
|
for case in config.cases:
|
||||||
|
caseConfig = deepcopy(config)
|
||||||
|
caseConfig.cases = [ case ]
|
||||||
|
|
||||||
|
caseRunner = UltimateRunner(config = caseConfig)
|
||||||
|
caseRunner._exec_id = baseRunner._exec_id
|
||||||
|
queue.append(caseRunner)
|
||||||
|
|
||||||
|
baseRunner.parallel(queue)
|
||||||
|
|
||||||
|
|
||||||
class LiteralOption(click.Option):
|
class LiteralOption(click.Option):
|
||||||
|
@ -87,7 +87,9 @@ class DefaultConfig(Config):
|
|||||||
"nprocs": 1,
|
"nprocs": 1,
|
||||||
"stage": "all",
|
"stage": "all",
|
||||||
"overwrite": False,
|
"overwrite": False,
|
||||||
|
"database": "anisotropy.db",
|
||||||
|
"build": "build",
|
||||||
|
"logs": "logs"
|
||||||
},
|
},
|
||||||
"structures": []
|
"structures": []
|
||||||
}
|
}
|
||||||
|
@ -4,19 +4,55 @@
|
|||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
from anisotropy.core.config import DefaultConfig
|
||||||
|
from anisotropy.database import *
|
||||||
|
from anisotropy.salomepl.runner import SalomeRunner
|
||||||
import anisotropy.samples as samples
|
import anisotropy.samples as samples
|
||||||
|
|
||||||
class UltimateRunner(object):
|
class UltimateRunner(object):
|
||||||
def __init__(self):
|
def __init__(self, config = None, exec_id = False):
|
||||||
|
|
||||||
self.database = Database(..)
|
self.config = config or DefaultConfig()
|
||||||
|
|
||||||
|
self.database = Database(self.config["database"])
|
||||||
self.datebase.setup()
|
self.datebase.setup()
|
||||||
|
|
||||||
self._exec = Execution(date = datetime.now())
|
if exec_id:
|
||||||
self._exec.save()
|
self._exec_id = Execution(date = datetime.now())
|
||||||
|
self._exec_id.save()
|
||||||
|
|
||||||
|
def casePath(self):
|
||||||
|
case = self.config.cases[0]
|
||||||
|
|
||||||
|
return os.path.join(
|
||||||
|
self.config["build"],
|
||||||
|
case["label"],
|
||||||
|
"direction-{}".format(str(case["direction"]).replace(" ", "")),
|
||||||
|
"theta-{}".format(case["theta"])
|
||||||
|
)
|
||||||
|
|
||||||
def computeMesh(self):
|
def computeMesh(self):
|
||||||
pass
|
|
||||||
|
case = self.config.cases[0]
|
||||||
|
runner = SalomeRunner()
|
||||||
|
cliArgs = [
|
||||||
|
"computemesh",
|
||||||
|
case["label"],
|
||||||
|
case["direction"],
|
||||||
|
case["theta"],
|
||||||
|
path
|
||||||
|
]
|
||||||
|
|
||||||
|
out, err, returncode = runner.execute(
|
||||||
|
env["CLI"],
|
||||||
|
*cliArgs,
|
||||||
|
timeout = self.config["salome_timeout"],
|
||||||
|
root = env["ROOT"],
|
||||||
|
logpath = self.casePath()
|
||||||
|
)
|
||||||
|
|
||||||
|
return out, err, returncode
|
||||||
|
|
||||||
|
|
||||||
def _computeMesh(self):
|
def _computeMesh(self):
|
||||||
"""Function for Salome
|
"""Function for Salome
|
||||||
@ -24,6 +60,7 @@ class UltimateRunner(object):
|
|||||||
Resolution pipeline:
|
Resolution pipeline:
|
||||||
cli(UR -> computeMesh) -> salomeRunner(salome -> cli) -> computemesh(UR -> _computeMesh)
|
cli(UR -> computeMesh) -> salomeRunner(salome -> cli) -> computemesh(UR -> _computeMesh)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# TODO: add logger configuration here
|
# TODO: add logger configuration here
|
||||||
sample = samples.__dict__[..]
|
sample = samples.__dict__[..]
|
||||||
|
|
||||||
@ -48,3 +85,31 @@ class UltimateRunner(object):
|
|||||||
flow = sample.onephaseflow(..)
|
flow = sample.onephaseflow(..)
|
||||||
flow.build()
|
flow.build()
|
||||||
|
|
||||||
|
|
||||||
|
def pipeline(self, stage: str = None):
|
||||||
|
stage = stage or config["stage"]
|
||||||
|
|
||||||
|
match stage:
|
||||||
|
case "mesh" | "all":
|
||||||
|
with self.database.atomic():
|
||||||
|
Shape.create(self._exec_id, **self.config.cases[0])
|
||||||
|
Mesh.create(self._exec_id)
|
||||||
|
|
||||||
|
self.computeMesh(..)
|
||||||
|
|
||||||
|
case "flow" | "all":
|
||||||
|
with self.database.atomic():
|
||||||
|
Flow.create(self._exec_id)
|
||||||
|
|
||||||
|
self.computeFlow(..)
|
||||||
|
|
||||||
|
case "postProcess" | "all":
|
||||||
|
self.postProcess(..)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def parallel(queue: list, nprocs = None):
|
||||||
|
nprocs = nprocs or config["nprocs"]
|
||||||
|
|
||||||
|
parallel(nprocs, [()] * len(queue), [ runner.pipeline for runner in queue ])
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user