Mod: minor changes

This commit is contained in:
L-Nafaryus 2021-12-06 19:19:34 +05:00
parent 9e98df1ffd
commit c2ef046f74
4 changed files with 21 additions and 11 deletions

View File

@ -109,7 +109,9 @@ def anisotropy():
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 DefaultConfig from anisotropy.core.config import DefaultConfig
from anisotropy.database.models import Execution
from copy import deepcopy from copy import deepcopy
from datetime import datetime
config = DefaultConfig() config = DefaultConfig()
@ -123,15 +125,19 @@ def compute(path, configFile, nprocs, stage, overwrite):
) )
config.expand() 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 = [] queue = []
for case in config.cases: for case in config.cases:
caseConfig = deepcopy(config) caseConfig = deepcopy(config)
caseConfig.cases = [ case ] caseConfig.purge()
caseRunner = UltimateRunner(config = caseConfig) m_shape = Shape(exec_id = exec_id, **case)
caseRunner._exec_id = baseRunner._exec_id m_shape.save()
caseRunner = UltimateRunner(config = caseConfig, exec_id = exec_id)
queue.append(caseRunner) queue.append(caseRunner)
baseRunner.parallel(queue) baseRunner.parallel(queue)

View File

@ -54,6 +54,10 @@ class Config(object):
with open(path, "w") as io: with open(path, "w") as io:
toml.dump(self.content, io, encoder = toml.TomlNumpyEncoder()) toml.dump(self.content, io, encoder = toml.TomlNumpyEncoder())
def purge(self):
self.content = {}
self.cases = {}
def expand(self): def expand(self):
self.cases = [] self.cases = []

View File

@ -13,16 +13,16 @@ from anisotropy.openfoam.presets import CreatePatchDict
from anisotropy.solving.onephase import OnePhaseFlow from anisotropy.solving.onephase import OnePhaseFlow
class UltimateRunner(object): 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.config = config or DefaultConfig()
self.database = Database(self.config["database"]) self.database = Database(self.config["database"])
self.database.setup() self.database.setup()
if exec_id: if not exec_id:
self._exec_id = Execution(date = datetime.now()) self.exec_id = Execution(date = datetime.now())
self._exec_id.save() self.exec_id.save()
self.shape = None self.shape = None
self.mesh = None self.mesh = None

View File

@ -51,9 +51,9 @@ class Shape(Model):
structure_id = AutoField() structure_id = AutoField()
exec_id = ForeignKeyField(Execution, backref = "physics") exec_id = ForeignKeyField(Execution, backref = "physics")
type = TextField() label = TextField(null = True)
direction = ListField() direction = ListField(null = True)
theta = FloatField() theta = FloatField(null = True)
r0 = FloatField(null = True) r0 = FloatField(null = True)
L = FloatField(null = True) L = FloatField(null = True)