Mod: computation parameters

Mod: move salome context to cli
This commit is contained in:
L-Nafaryus 2021-08-27 16:46:09 +05:00
parent 9feb150a1c
commit 750bf30e11
4 changed files with 19 additions and 18 deletions

View File

@ -35,8 +35,8 @@ faceCentered = true
minSize = 0.05 minSize = 0.05
fineness = 5 fineness = 5
growthRate = 0.7 growthRate = 0.5
nbSegPerEdge = 0.3 nbSegPerEdge = 2
nbSegPerRadius = 1 nbSegPerRadius = 1
chordalErrorEnabled = true chordalErrorEnabled = true
@ -123,8 +123,8 @@ faceCentered = true
minSize = 0.05 minSize = 0.05
fineness = 5 fineness = 5
growthRate = 0.7 growthRate = 0.5
nbSegPerEdge = 0.3 nbSegPerEdge = 2
nbSegPerRadius = 1 nbSegPerRadius = 1
chordalErrorEnabled = true chordalErrorEnabled = true
@ -191,7 +191,7 @@ faceCentered = true
[structures.structure] [structures.structure]
type = "faceCentered" type = "faceCentered"
# auto # from theta: list # theta: float # 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 # auto # from directions:list # direction: list
directions = [ directions = [
[1, 0, 0], [1, 0, 0],
@ -211,8 +211,8 @@ faceCentered = true
minSize = 0.05 minSize = 0.05
fineness = 5 fineness = 5
growthRate = 0.7 growthRate = 0.5
nbSegPerEdge = 0.3 nbSegPerEdge = 2
nbSegPerRadius = 1 nbSegPerRadius = 1
chordalErrorEnabled = true chordalErrorEnabled = true

View File

@ -91,6 +91,12 @@ def anisotropy():
default = False, default = False,
help = "Overwrite existing entries" help = "Overwrite existing entries"
) )
@click.option(
"-u", "--update", "update",
type = click.BOOL,
default = False,
help = "Update db parameters from config"
)
@click.option( @click.option(
"-p", "--param", "params", "-p", "--param", "params",
metavar = "key=value", metavar = "key=value",
@ -98,7 +104,7 @@ def anisotropy():
cls = KeyValueOption, cls = KeyValueOption,
help = "Overwrite existing parameter (except control variables)" 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.main import Anisotropy, Database, logger
from anisotropy.core.utils import timer, parallel from anisotropy.core.utils import timer, parallel
@ -125,7 +131,7 @@ def compute(stage, nprocs, database, force, params):
model.db.setup() model.db.setup()
def fill_db(): def fill_db():
if model.db.isempty(): if model.db.isempty() or update:
paramsAll = model.loadFromScratch() paramsAll = model.loadFromScratch()
for entry in paramsAll: for entry in paramsAll:
@ -234,12 +240,15 @@ def computemesh(root, type, direction, theta):
]) ])
from anisotropy.core.main import Anisotropy from anisotropy.core.main import Anisotropy
import salome
### ###
model = Anisotropy() model = Anisotropy()
model.load(type, direction, theta) model.load(type, direction, theta)
salome.salome_init()
model.genmesh() model.genmesh()
salome.salome_close()
### ###
# CLI entry # CLI entry

View File

@ -254,15 +254,9 @@ class Anisotropy(object):
Warning: Working only inside Salome Environment Warning: Working only inside Salome Environment
""" """
# ISSUE: double logger output
import salome
p = self.params p = self.params
salome.salome_init()
### ###
# Shape # Shape
## ##
@ -357,8 +351,6 @@ class Anisotropy(object):
) )
self.update() self.update()
salome.salome_close()
def computeFlow(self): def computeFlow(self):
"""Computes a flow on mesh via OpenFOAM """Computes a flow on mesh via OpenFOAM

View File

@ -179,7 +179,7 @@ class BodyCentered(object):
# Groups # Groups
## ##
shape = geompy.MakeCutList(poreCell, [grains]) 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"]) sall = geompy.CreateGroup(shape, geompy.ShapeType["FACE"])
geompy.UnionIDs(sall, geompy.UnionIDs(sall,