From c2a6303f1732b04918ad1ada34758ad29de70624 Mon Sep 17 00:00:00 2001 From: L-Nafaryus Date: Fri, 23 Jul 2021 15:24:59 +0500 Subject: [PATCH] Mod: pulling default values and fixing configs merge --- anisotropy/anisotropy.py | 16 ++-- anisotropy/default.toml | 170 +++++++++++++++++++++++++++++++++++---- anisotropy/models.py | 4 +- anisotropy/utils.py | 21 +++++ conf/config.toml | 30 ------- 5 files changed, 190 insertions(+), 51 deletions(-) diff --git a/anisotropy/anisotropy.py b/anisotropy/anisotropy.py index 837593d..adff911 100644 --- a/anisotropy/anisotropy.py +++ b/anisotropy/anisotropy.py @@ -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 diff --git a/anisotropy/default.toml b/anisotropy/default.toml index a59831f..cf3b9fb 100644 --- a/anisotropy/default.toml +++ b/anisotropy/default.toml @@ -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] - directions = [ + # 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] - viscousLayers = true - thickness = [0.01, 0.005] + 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] # [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] - directions = [ + # 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] - viscousLayers = true - thickness = [0.005, 0.0005] + 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] # [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] - directions = [ + # 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] - viscousLayers = true - thickness = [0.001, 0.0005] + 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] # [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 + diff --git a/anisotropy/models.py b/anisotropy/models.py index b0be959..9aa9efd 100644 --- a/anisotropy/models.py +++ b/anisotropy/models.py @@ -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): diff --git a/anisotropy/utils.py b/anisotropy/utils.py index 00c47bf..4666bb4 100644 --- a/anisotropy/utils.py +++ b/anisotropy/utils.py @@ -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): diff --git a/conf/config.toml b/conf/config.toml index 97a925f..daa9c4a 100644 --- a/conf/config.toml +++ b/conf/config.toml @@ -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