Mod: pulling default values and fixing configs merge

This commit is contained in:
L-Nafaryus 2021-07-23 15:24:59 +05:00
parent 92a232fd3d
commit c2a6303f17
5 changed files with 190 additions and 51 deletions

View File

@ -46,7 +46,7 @@ import os
import toml
from copy import deepcopy
from anisotropy.models import db, Structure, Mesh
from anisotropy.utils import struct
from anisotropy.utils import struct, deepupdate
import salomepl
###
@ -72,8 +72,13 @@ if os.path.exists(env["CONFIG"]):
if config.get(restricted):
config.pop(restricted)
# TODO: dict replacing
#env.update(config)
for m, structure in enumerate(config["structures"]):
for n, estructure in enumerate(env["structures"]):
if estructure["name"] == structure["name"]:
deepupdate(env["structures"][n], config["structures"][m])
config.pop("structures")
deepupdate(env, config)
###
# Logger
@ -242,14 +247,15 @@ class Anisotropy(object):
with self.db.atomic():
stab = Structure.create(**s)
m.update(structure = stab)
m.update(structure_id = stab)
mtab = Mesh.create(**m)
else:
# TODO: not working update; incorrect update (all entries)
with self.db.atomic():
stab = Structure.update(**s)
m.update(structure = stab)
m.update(structure_id = stab)
mtab = Mesh.update(**m)
@timer

View File

@ -3,70 +3,212 @@ name = "anisotropy"
format = "%(levelname)s: %(message)s"
[base]
simple = false
bodyCentered = false
simple = true
bodyCentered = true
faceCentered = true
[[structures]]
name = "simple"
# auto # path: str
[structures.geometry]
theta = [0.01, 0.28, 0.01]
# auto # from theta: list # theta: float
theta = [0.01, 0.28, 0.01] # [min, max, step]
# auto # from directions:list # direction: list
directions = [
[1, 0, 0],
[0, 0, 1],
[1, 1, 1]
]
# r0 =
# L =
# radius =
filletsEnabled = true
# auto # fillets: float
[structures.mesh]
maxSize = 0.5
minSize = 0.05
fineness = 5
growthRate = 0.7
nbSegPerEdge = 0.3
nbSegPerRadius = 1
chordalErrorEnabled = true
chordalError = 0.25
secondOrder = false
optimize = true
quadAllowed = false
useSurfaceCurvature = true
fuseEdges = true
checkChartBoundary = false
viscousLayers = true
thickness = [0.01, 0.005]
thickness = [0.01, 0.005] # [min, max] # step is controlled by theta count
numberOfLayers = 1
stretchFactor = 1
isFacesToIgnore = true
facesToIgnore = ["inlet", "outlet"]
# auto # faces: list
extrusionMethod = "SURF_OFFSET_SMOOTH"
[structures.submesh.strips]
maxSize = 0.5
minSize = 0.05
fineness = 5
growthRate = 0.2
nbSegPerEdge = 2
nbSegPerRadius = 3
chordalErrorEnabled = true
chordalError = 0.25
secondOrder = false
optimize = true
quadAllowed = false
useSurfaceCurvature = true
fuseEdges = true
checkChartBoundary = false
[[structures]]
name = "bodyCentered"
# auto # path: str
[structures.geometry]
theta = [0.01, 0.17, 0.01]
# auto # from theta: list # theta: float
theta = [0.01, 0.17, 0.01] # [min, max, step]
# auto # from directions:list # direction: list
directions = [
[1, 0, 0],
[0, 0, 1],
[1, 1, 1]
]
# r0 =
# L =
# radius =
filletsEnabled = true
# auto # fillets: float
[structures.mesh]
maxSize = 0.5
minSize = 0.05
fineness = 5
growthRate = 0.7
nbSegPerEdge = 0.3
nbSegPerRadius = 1
chordalErrorEnabled = true
chordalError = 0.25
secondOrder = false
optimize = true
quadAllowed = false
useSurfaceCurvature = true
fuseEdges = true
checkChartBoundary = false
viscousLayers = true
thickness = [0.005, 0.0005]
thickness = [0.005, 0.0005] # [min, max] # step is controlled by theta count
numberOfLayers = 1
stretchFactor = 1
isFacesToIgnore = true
facesToIgnore = ["inlet", "outlet"]
# auto # faces: list
extrusionMethod = "SURF_OFFSET_SMOOTH"
[structures.submesh.strips]
maxSize = 0.5
minSize = 0.05
fineness = 5
growthRate = 0.2
nbSegPerEdge = 2
nbSegPerRadius = 3
chordalErrorEnabled = true
chordalError = 0.25
secondOrder = false
optimize = true
quadAllowed = false
useSurfaceCurvature = true
fuseEdges = true
checkChartBoundary = false
[[structures]]
name = "faceCentered"
# auto # path: str
[structures.geometry]
theta = [0.01, 0.13, 0.01]
# auto # from theta: list # theta: float
theta = [0.01, 0.18, 0.01] # [min, max, step]
# auto # from directions:list # direction: list
directions = [
[1, 0, 0],
[0, 0, 1],
[1, 1, 1]
]
# r0 =
# L =
# radius =
filletsEnabled = true
# auto # fillets: float
[structures.mesh]
maxSize = 0.5
minSize = 0.05
fineness = 5
growthRate = 0.7
nbSegPerEdge = 0.3
nbSegPerRadius = 1
chordalErrorEnabled = true
chordalError = 0.25
secondOrder = false
optimize = true
quadAllowed = false
useSurfaceCurvature = true
fuseEdges = true
checkChartBoundary = false
viscousLayers = true
thickness = [0.001, 0.0005]
thickness = [0.001, 0.0005] # [min, max] # step is controlled by theta count
numberOfLayers = 1
stretchFactor = 1
isFacesToIgnore = true
facesToIgnore = ["inlet", "outlet"]
# auto # faces: list
extrusionMethod = "SURF_OFFSET_SMOOTH"
[structures.submesh.strips]
maxSize = 0.5
minSize = 0.05
fineness = 5
growthRate = 0.2
nbSegPerEdge = 2
nbSegPerRadius = 3
chordalErrorEnabled = true
chordalError = 0.25
secondOrder = false
optimize = true
quadAllowed = false
useSurfaceCurvature = true
fuseEdges = true
checkChartBoundary = false

View File

@ -72,9 +72,9 @@ class Mesh(BaseModel):
numberOfLayers = IntegerField(null = True)
stretchFactor = FloatField(null = True)
isFacesToIgnore = BooleanField(null = True)
#facesToIgnore = ["inlet", "outlet"]
facesToIgnore = ListField(null = True)
#faces = []
#extrusionMethod = ExtrusionMethod.SURF_OFFSET_SMOOTH
extrusionMethod = TextField(null = True)
class SubMesh(Mesh):

View File

@ -42,6 +42,27 @@ class struct:
def __repr__(self):
return str(self)
import copy
def deepupdate(target, src):
for k, v in src.items():
#if type(v) == list:
# if not k in target:
# target[k] = copy.deepcopy(v)
# else:
# target[k].extend(v)
if type(v) == dict:
if not k in target:
target[k] = copy.deepcopy(v)
else:
deepupdate(target[k], v)
#elif type(v) == set:
# if not k in target:
# target[k] = v.copy()
# else:
# target[k].update(v.copy())
else:
target[k] = copy.copy(v)
class Logger:
def __init__(self, name, logpath):

View File

@ -1,15 +1,3 @@
###
# Default config for anisotropy
#
# Special values:
# theta = [min, max, step]
# thickness = [min, max]
##
[logger]
name = "anisotropy"
format = "%(levelname)s: %(message)s"
[base]
simple = false
bodyCentered = false
@ -20,12 +8,6 @@ faceCentered = true
[structures.geometry]
theta = [0.01, 0.28, 0.01]
directions = [
[1, 0, 0],
[0, 0, 1],
[1, 1, 1]
]
fillet = true
[structures.mesh]
viscousLayers = true
@ -41,12 +23,6 @@ faceCentered = true
[structures.geometry]
theta = [0.01, 0.17, 0.01]
directions = [
[1, 0, 0],
[0, 0, 1],
[1, 1, 1]
]
fillet = true
[structures.mesh]
viscousLayers = true
@ -62,12 +38,6 @@ faceCentered = true
[structures.geometry]
theta = [0.01, 0.13, 0.01]
directions = [
[1, 0, 0],
[0, 0, 1],
[1, 1, 1]
]
fillet = true
[structures.mesh]
viscousLayers = true