Mod: minor changes
This commit is contained in:
parent
9e98df1ffd
commit
c2ef046f74
@ -109,7 +109,9 @@ def anisotropy():
|
||||
def compute(path, configFile, nprocs, stage, overwrite):
|
||||
from anisotropy.core.runner import UltimateRunner
|
||||
from anisotropy.core.config import DefaultConfig
|
||||
from anisotropy.database.models import Execution
|
||||
from copy import deepcopy
|
||||
from datetime import datetime
|
||||
|
||||
config = DefaultConfig()
|
||||
|
||||
@ -123,15 +125,19 @@ def compute(path, configFile, nprocs, stage, overwrite):
|
||||
)
|
||||
config.expand()
|
||||
|
||||
baseRunner = UltimateRunner(config = config, exec_id = True)
|
||||
exec_id = Execution(date = datetime.now())
|
||||
exec_id.save()
|
||||
baseRunner = UltimateRunner(config = config, exec_id = exec_id)
|
||||
queue = []
|
||||
|
||||
for case in config.cases:
|
||||
caseConfig = deepcopy(config)
|
||||
caseConfig.cases = [ case ]
|
||||
caseConfig.purge()
|
||||
|
||||
caseRunner = UltimateRunner(config = caseConfig)
|
||||
caseRunner._exec_id = baseRunner._exec_id
|
||||
m_shape = Shape(exec_id = exec_id, **case)
|
||||
m_shape.save()
|
||||
|
||||
caseRunner = UltimateRunner(config = caseConfig, exec_id = exec_id)
|
||||
queue.append(caseRunner)
|
||||
|
||||
baseRunner.parallel(queue)
|
||||
|
@ -54,6 +54,10 @@ class Config(object):
|
||||
with open(path, "w") as io:
|
||||
toml.dump(self.content, io, encoder = toml.TomlNumpyEncoder())
|
||||
|
||||
def purge(self):
|
||||
self.content = {}
|
||||
self.cases = {}
|
||||
|
||||
def expand(self):
|
||||
self.cases = []
|
||||
|
||||
|
@ -13,16 +13,16 @@ from anisotropy.openfoam.presets import CreatePatchDict
|
||||
from anisotropy.solving.onephase import OnePhaseFlow
|
||||
|
||||
class UltimateRunner(object):
|
||||
def __init__(self, config = None, exec_id = False):
|
||||
def __init__(self, config = None, exec_id = None):
|
||||
|
||||
self.config = config or DefaultConfig()
|
||||
|
||||
self.database = Database(self.config["database"])
|
||||
self.database.setup()
|
||||
|
||||
if exec_id:
|
||||
self._exec_id = Execution(date = datetime.now())
|
||||
self._exec_id.save()
|
||||
if not exec_id:
|
||||
self.exec_id = Execution(date = datetime.now())
|
||||
self.exec_id.save()
|
||||
|
||||
self.shape = None
|
||||
self.mesh = None
|
||||
|
@ -51,9 +51,9 @@ class Shape(Model):
|
||||
structure_id = AutoField()
|
||||
exec_id = ForeignKeyField(Execution, backref = "physics")
|
||||
|
||||
type = TextField()
|
||||
direction = ListField()
|
||||
theta = FloatField()
|
||||
label = TextField(null = True)
|
||||
direction = ListField(null = True)
|
||||
theta = FloatField(null = True)
|
||||
|
||||
r0 = FloatField(null = True)
|
||||
L = FloatField(null = True)
|
||||
|
Loading…
Reference in New Issue
Block a user