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

View File

@ -3,70 +3,212 @@ name = "anisotropy"
format = "%(levelname)s: %(message)s" format = "%(levelname)s: %(message)s"
[base] [base]
simple = false simple = true
bodyCentered = false bodyCentered = true
faceCentered = true faceCentered = true
[[structures]] [[structures]]
name = "simple" name = "simple"
# auto # path: str
[structures.geometry] [structures.geometry]
theta = [0.01, 0.28, 0.01] # auto # from theta: list # theta: float
directions = [ theta = [0.01, 0.28, 0.01] # [min, max, step]
# auto # from directions:list # direction: list
directions = [
[1, 0, 0], [1, 0, 0],
[0, 0, 1], [0, 0, 1],
[1, 1, 1] [1, 1, 1]
] ]
# r0 =
# L =
# radius =
filletsEnabled = true filletsEnabled = true
# auto # fillets: float
[structures.mesh] [structures.mesh]
viscousLayers = true maxSize = 0.5
thickness = [0.01, 0.005] 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] # [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] [structures.submesh.strips]
maxSize = 0.5
minSize = 0.05
fineness = 5
growthRate = 0.2 growthRate = 0.2
nbSegPerEdge = 2 nbSegPerEdge = 2
nbSegPerRadius = 3 nbSegPerRadius = 3
chordalErrorEnabled = true
chordalError = 0.25
secondOrder = false
optimize = true
quadAllowed = false
useSurfaceCurvature = true
fuseEdges = true
checkChartBoundary = false
[[structures]] [[structures]]
name = "bodyCentered" name = "bodyCentered"
# auto # path: str
[structures.geometry] [structures.geometry]
theta = [0.01, 0.17, 0.01] # auto # from theta: list # theta: float
directions = [ theta = [0.01, 0.17, 0.01] # [min, max, step]
# auto # from directions:list # direction: list
directions = [
[1, 0, 0], [1, 0, 0],
[0, 0, 1], [0, 0, 1],
[1, 1, 1] [1, 1, 1]
] ]
# r0 =
# L =
# radius =
filletsEnabled = true filletsEnabled = true
# auto # fillets: float
[structures.mesh] [structures.mesh]
viscousLayers = true maxSize = 0.5
thickness = [0.005, 0.0005] 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] # [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] [structures.submesh.strips]
maxSize = 0.5
minSize = 0.05
fineness = 5
growthRate = 0.2 growthRate = 0.2
nbSegPerEdge = 2 nbSegPerEdge = 2
nbSegPerRadius = 3 nbSegPerRadius = 3
chordalErrorEnabled = true
chordalError = 0.25
secondOrder = false
optimize = true
quadAllowed = false
useSurfaceCurvature = true
fuseEdges = true
checkChartBoundary = false
[[structures]] [[structures]]
name = "faceCentered" name = "faceCentered"
# auto # path: str
[structures.geometry] [structures.geometry]
theta = [0.01, 0.13, 0.01] # auto # from theta: list # theta: float
directions = [ theta = [0.01, 0.18, 0.01] # [min, max, step]
# auto # from directions:list # direction: list
directions = [
[1, 0, 0], [1, 0, 0],
[0, 0, 1], [0, 0, 1],
[1, 1, 1] [1, 1, 1]
] ]
# r0 =
# L =
# radius =
filletsEnabled = true filletsEnabled = true
# auto # fillets: float
[structures.mesh] [structures.mesh]
viscousLayers = true maxSize = 0.5
thickness = [0.001, 0.0005] 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] # [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] [structures.submesh.strips]
maxSize = 0.5
minSize = 0.05
fineness = 5
growthRate = 0.2 growthRate = 0.2
nbSegPerEdge = 2 nbSegPerEdge = 2
nbSegPerRadius = 3 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) numberOfLayers = IntegerField(null = True)
stretchFactor = FloatField(null = True) stretchFactor = FloatField(null = True)
isFacesToIgnore = BooleanField(null = True) isFacesToIgnore = BooleanField(null = True)
#facesToIgnore = ["inlet", "outlet"] facesToIgnore = ListField(null = True)
#faces = [] #faces = []
#extrusionMethod = ExtrusionMethod.SURF_OFFSET_SMOOTH extrusionMethod = TextField(null = True)
class SubMesh(Mesh): class SubMesh(Mesh):

View File

@ -42,6 +42,27 @@ class struct:
def __repr__(self): def __repr__(self):
return str(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: class Logger:
def __init__(self, name, logpath): 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] [base]
simple = false simple = false
bodyCentered = false bodyCentered = false
@ -20,12 +8,6 @@ faceCentered = true
[structures.geometry] [structures.geometry]
theta = [0.01, 0.28, 0.01] theta = [0.01, 0.28, 0.01]
directions = [
[1, 0, 0],
[0, 0, 1],
[1, 1, 1]
]
fillet = true
[structures.mesh] [structures.mesh]
viscousLayers = true viscousLayers = true
@ -41,12 +23,6 @@ faceCentered = true
[structures.geometry] [structures.geometry]
theta = [0.01, 0.17, 0.01] theta = [0.01, 0.17, 0.01]
directions = [
[1, 0, 0],
[0, 0, 1],
[1, 1, 1]
]
fillet = true
[structures.mesh] [structures.mesh]
viscousLayers = true viscousLayers = true
@ -62,12 +38,6 @@ faceCentered = true
[structures.geometry] [structures.geometry]
theta = [0.01, 0.13, 0.01] theta = [0.01, 0.13, 0.01]
directions = [
[1, 0, 0],
[0, 0, 1],
[1, 1, 1]
]
fillet = true
[structures.mesh] [structures.mesh]
viscousLayers = true viscousLayers = true