From 750bf30e11c5754c0a62775ee7fd5da7513ba7df Mon Sep 17 00:00:00 2001 From: L-Nafaryus Date: Fri, 27 Aug 2021 16:46:09 +0500 Subject: [PATCH] Mod: computation parameters Mod: move salome context to cli --- anisotropy/config/default.toml | 14 +++++++------- anisotropy/core/cli.py | 13 +++++++++++-- anisotropy/core/main.py | 8 -------- anisotropy/samples/bodyCentered.py | 2 +- 4 files changed, 19 insertions(+), 18 deletions(-) diff --git a/anisotropy/config/default.toml b/anisotropy/config/default.toml index de06e31..c40d403 100644 --- a/anisotropy/config/default.toml +++ b/anisotropy/config/default.toml @@ -35,8 +35,8 @@ faceCentered = true minSize = 0.05 fineness = 5 - growthRate = 0.7 - nbSegPerEdge = 0.3 + growthRate = 0.5 + nbSegPerEdge = 2 nbSegPerRadius = 1 chordalErrorEnabled = true @@ -123,8 +123,8 @@ faceCentered = true minSize = 0.05 fineness = 5 - growthRate = 0.7 - nbSegPerEdge = 0.3 + growthRate = 0.5 + nbSegPerEdge = 2 nbSegPerRadius = 1 chordalErrorEnabled = true @@ -191,7 +191,7 @@ faceCentered = true [structures.structure] type = "faceCentered" # auto # from theta: list # theta: float - theta = [0.01, 0.18, 0.01] # [min, max, step] + theta = [0.01, 0.12, 0.01] # [min, max, step] # auto # from directions:list # direction: list directions = [ [1, 0, 0], @@ -211,8 +211,8 @@ faceCentered = true minSize = 0.05 fineness = 5 - growthRate = 0.7 - nbSegPerEdge = 0.3 + growthRate = 0.5 + nbSegPerEdge = 2 nbSegPerRadius = 1 chordalErrorEnabled = true diff --git a/anisotropy/core/cli.py b/anisotropy/core/cli.py index 0ac4271..0f68c30 100644 --- a/anisotropy/core/cli.py +++ b/anisotropy/core/cli.py @@ -91,6 +91,12 @@ def anisotropy(): default = False, help = "Overwrite existing entries" ) +@click.option( + "-u", "--update", "update", + type = click.BOOL, + default = False, + help = "Update db parameters from config" +) @click.option( "-p", "--param", "params", metavar = "key=value", @@ -98,7 +104,7 @@ def anisotropy(): cls = KeyValueOption, help = "Overwrite existing parameter (except control variables)" ) -def compute(stage, nprocs, database, force, params): +def compute(stage, nprocs, database, force, update, params): from anisotropy.core.main import Anisotropy, Database, logger from anisotropy.core.utils import timer, parallel @@ -125,7 +131,7 @@ def compute(stage, nprocs, database, force, params): model.db.setup() def fill_db(): - if model.db.isempty(): + if model.db.isempty() or update: paramsAll = model.loadFromScratch() for entry in paramsAll: @@ -234,12 +240,15 @@ def computemesh(root, type, direction, theta): ]) from anisotropy.core.main import Anisotropy + import salome ### model = Anisotropy() model.load(type, direction, theta) + salome.salome_init() model.genmesh() + salome.salome_close() ### # CLI entry diff --git a/anisotropy/core/main.py b/anisotropy/core/main.py index b137b74..04d2566 100644 --- a/anisotropy/core/main.py +++ b/anisotropy/core/main.py @@ -254,15 +254,9 @@ class Anisotropy(object): Warning: Working only inside Salome Environment """ - # ISSUE: double logger output - - import salome p = self.params - salome.salome_init() - - ### # Shape ## @@ -357,8 +351,6 @@ class Anisotropy(object): ) self.update() - salome.salome_close() - def computeFlow(self): """Computes a flow on mesh via OpenFOAM diff --git a/anisotropy/samples/bodyCentered.py b/anisotropy/samples/bodyCentered.py index 83bd052..2e870ee 100644 --- a/anisotropy/samples/bodyCentered.py +++ b/anisotropy/samples/bodyCentered.py @@ -179,7 +179,7 @@ class BodyCentered(object): # Groups ## shape = geompy.MakeCutList(poreCell, [grains]) - shape = geompy.MakeScaleTransform(shape, oo, 1 / scale, theName = "bodyCenteredCubic") + shape = geompy.MakeScaleTransform(shape, oo, 1 / scale, theName = "bodyCentered") sall = geompy.CreateGroup(shape, geompy.ShapeType["FACE"]) geompy.UnionIDs(sall,