New: db models

Mod: replace default mesh parameters
This commit is contained in:
L-Nafaryus 2021-07-12 18:01:15 +05:00
parent 7f75e9c790
commit 5a490a98d2
5 changed files with 71 additions and 50 deletions

19
anisotropy/db.py Normal file
View File

@ -0,0 +1,19 @@
from peewee import *
class BaseModel(Model):
class Meta:
database = db
class Structure(BaseModel):
name = TextField()
direction = TextField()
theta = FloatField()
class Mesh(BaseModel):
maxSize = FloatField()
minSize = FloatField()
chordalErrorEnabled = BooleanField()
chordalError = FloatField()
calculationTime = TimeField()
structure = ForeignKeyField(Structure, backref = "mesh")

View File

@ -11,8 +11,8 @@ name = "anisotropy"
format = "%(levelname)s: %(message)s" format = "%(levelname)s: %(message)s"
[base] [base]
simple = true simple = false
bodyCentered = true bodyCentered = false
faceCentered = true faceCentered = true
### ###
@ -50,7 +50,7 @@ directions = [
fillet = true fillet = true
[bodyCentered.mesh] [bodyCentered.mesh]
viscousLayers = false viscousLayers = true
thickness = [0.005, 0.0005] thickness = [0.005, 0.0005]
[bodyCentered.mesh.submesh.strips] [bodyCentered.mesh.submesh.strips]
@ -71,7 +71,7 @@ directions = [
fillet = true fillet = true
[faceCentered.mesh] [faceCentered.mesh]
viscousLayers = false viscousLayers = true
thickness = [0.001, 0.0005] thickness = [0.001, 0.0005]
[faceCentered.mesh.submesh.strips] [faceCentered.mesh.submesh.strips]

View File

@ -1,3 +1,5 @@
numpy numpy
pyquaternion pyquaternion
toml toml
peewee
pandas

View File

@ -27,52 +27,7 @@ from salomepl.faceCentered import faceCentered
from salomepl.bodyCentered import bodyCentered from salomepl.bodyCentered import bodyCentered
from salomepl.geometry import getGeom from salomepl.geometry import getGeom
from salomepl.mesh import Mesh, Fineness, ExtrusionMethod from salomepl.mesh import Mesh, Fineness, ExtrusionMethod, defaultParameters
def defaultParameters(**configParameters):
maxSize = 0.5
minSize = 0.05
fineness = Fineness.Custom.value
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 = False
thickness = 0.005
numberOfLayers = 1
stretchFactor = 1
isFacesToIgnore = True
facesToIgnore = ["inlet", "outlet"]
faces = []
extrusionMethod = ExtrusionMethod.SURF_OFFSET_SMOOTH
p = locals()
del p["configParameters"]
if configParameters:
for k, v in p.items():
if configParameters.get(k) is not None:
p[k] = configParameters[k]
# Overwrite special values
if k == "fineness":
p["fineness"] = Fineness.__dict__[p["fineness"]].value
if k == "extrusionMethod":
p["extrusionMethod"] = ExtrusionMethod.__dict__[p["extrusionMethod"]]
return p
def genmesh(config): def genmesh(config):

View File

@ -20,6 +20,51 @@ class ExtrusionMethod(object):
def getSmesh(): def getSmesh():
return smesh return smesh
def defaultParameters(**configParameters):
maxSize = 0.5
minSize = 0.05
fineness = Fineness.Custom.value
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 = False
thickness = 0.005
numberOfLayers = 1
stretchFactor = 1
isFacesToIgnore = True
facesToIgnore = ["inlet", "outlet"]
faces = []
extrusionMethod = ExtrusionMethod.SURF_OFFSET_SMOOTH
p = locals()
del p["configParameters"]
if configParameters:
for k, v in p.items():
if configParameters.get(k) is not None:
p[k] = configParameters[k]
# Overwrite special values
if k == "fineness":
p["fineness"] = Fineness.__dict__[p["fineness"]].value
if k == "extrusionMethod":
p["extrusionMethod"] = ExtrusionMethod.__dict__[p["extrusionMethod"]]
return p
def updateParams(old, new: dict): def updateParams(old, new: dict):
old.SetMaxSize(new.get("maxSize") if new.get("maxSize") else old.GetMaxSize()) old.SetMaxSize(new.get("maxSize") if new.get("maxSize") else old.GetMaxSize())
old.SetMinSize(new.get("minSize") if new.get("minSize") else old.GetMinSize()) old.SetMinSize(new.get("minSize") if new.get("minSize") else old.GetMinSize())