Mod: db issues + genmesh
This commit is contained in:
parent
3d05f661b3
commit
8f038439ba
@ -216,7 +216,7 @@ class Anisotropy(object):
|
|||||||
))
|
))
|
||||||
|
|
||||||
|
|
||||||
def getParams(structure: str, direction: list, theta: float):
|
def getParams(self, structure: str, direction: list, theta: float):
|
||||||
for entry in self.params:
|
for entry in self.params:
|
||||||
if entry["name"] == structure and \
|
if entry["name"] == structure and \
|
||||||
entry["geometry"]["direction"] == direction and \
|
entry["geometry"]["direction"] == direction and \
|
||||||
@ -256,7 +256,7 @@ class Anisotropy(object):
|
|||||||
Structure.update(**raw)
|
Structure.update(**raw)
|
||||||
.where(
|
.where(
|
||||||
Structure.name == req["name"],
|
Structure.name == req["name"],
|
||||||
Structure.direction == req["direction"],
|
Structure.direction == str(req["direction"]),
|
||||||
Structure.theta == req["theta"]
|
Structure.theta == req["theta"]
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -289,6 +289,9 @@ class Anisotropy(object):
|
|||||||
return tabID
|
return tabID
|
||||||
|
|
||||||
def _updateSubMesh(self, srcs: list, queryMain, meshID) -> None:
|
def _updateSubMesh(self, srcs: list, queryMain, meshID) -> None:
|
||||||
|
if not srcs:
|
||||||
|
return
|
||||||
|
|
||||||
for src in srcs:
|
for src in srcs:
|
||||||
raw = deepcopy(src)
|
raw = deepcopy(src)
|
||||||
|
|
||||||
@ -306,13 +309,16 @@ class Anisotropy(object):
|
|||||||
query = (
|
query = (
|
||||||
SubMesh.update(**raw)
|
SubMesh.update(**raw)
|
||||||
.where(
|
.where(
|
||||||
SubMesh.mesh_id == req["mesh_id"]
|
SubMesh.mesh_id == req["mesh_id"],
|
||||||
SubMesh.name == src["name"]
|
SubMesh.name == src["name"]
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
query.execute()
|
query.execute()
|
||||||
|
|
||||||
def _updateMeshResult(self, src: dict, queryMain, meshID) -> None:
|
def _updateMeshResult(self, src: dict, queryMain, meshID) -> None:
|
||||||
|
if not src:
|
||||||
|
return
|
||||||
|
|
||||||
raw = deepcopy(src)
|
raw = deepcopy(src)
|
||||||
|
|
||||||
with self.db.atomic():
|
with self.db.atomic():
|
||||||
@ -348,20 +354,21 @@ class Anisotropy(object):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
# TODO: empty entries
|
|
||||||
structureID = self._updateStructure(entry, query)
|
structureID = self._updateStructure(entry, query)
|
||||||
meshID = self._updateMesh(entry["mesh"], query, structureID)
|
meshID = self._updateMesh(entry["mesh"], query, structureID)
|
||||||
self._updateSubMesh(entry.get("submesh", []), query, meshID)
|
self._updateSubMesh(entry.get("submesh", []), query, meshID)
|
||||||
self._updateMeshResult(entry.get("meshresults", {}), query, meshID)
|
self._updateMeshResult(entry.get("meshresults", {}), query, meshID)
|
||||||
|
|
||||||
|
# TODO: loadDB (one model), loadsDB (all models)
|
||||||
@timer
|
@timer
|
||||||
def updateFromDB(self):
|
def updateFromDB(self):
|
||||||
squery = Structure.select().order_by(Structure.id)
|
squery = Structure.select().order_by(Structure.id)
|
||||||
mquery = Mesh.select().order_by(Mesh.structure_id)
|
mquery = Mesh.select().order_by(Mesh.structure_id)
|
||||||
|
smquery = SubMesh.select()
|
||||||
|
mrquery = MeshResult.select().order_dy(MeshResult.mesh_id)
|
||||||
self.params = []
|
self.params = []
|
||||||
|
|
||||||
for s, m in zip(squery.dicts(), mquery.dicts()):
|
for s, m, mr in zip(squery.dicts(), mquery.dicts(), mrquery.dicts()):
|
||||||
name = s.pop("name")
|
name = s.pop("name")
|
||||||
path = s.pop("path")
|
path = s.pop("path")
|
||||||
|
|
||||||
@ -369,7 +376,9 @@ class Anisotropy(object):
|
|||||||
name = name,
|
name = name,
|
||||||
path = path,
|
path = path,
|
||||||
geometry = s,
|
geometry = s,
|
||||||
mesh = m
|
mesh = m,
|
||||||
|
submesh = [ d for d in smquery.dicts() if d["mesh_id"] == m["mesh_id"] ],
|
||||||
|
meshresults = mr
|
||||||
))
|
))
|
||||||
|
|
||||||
self.params = sorted(self.params, key = lambda entry: f"{ entry['name'] } { entry['geometry']['direction'] } { entry['geometry']['theta'] }")
|
self.params = sorted(self.params, key = lambda entry: f"{ entry['name'] } { entry['geometry']['direction'] } { entry['geometry']['theta'] }")
|
||||||
@ -379,7 +388,7 @@ class Anisotropy(object):
|
|||||||
scriptpath = os.path.join(self.env["ROOT"], "anisotropy/genmesh.py")
|
scriptpath = os.path.join(self.env["ROOT"], "anisotropy/genmesh.py")
|
||||||
port = 2900
|
port = 2900
|
||||||
|
|
||||||
return salomepl.utils.runSalome(port, scriptpath, env["ROOT"], name, direction, theta)
|
return salomepl.utils.runSalome(port, scriptpath, self.env["ROOT"], name, direction, theta)
|
||||||
|
|
||||||
def computeFlow(self):
|
def computeFlow(self):
|
||||||
pass
|
pass
|
||||||
|
@ -36,9 +36,9 @@ def genmesh(root, name, direction, theta):
|
|||||||
from anisotropy import (
|
from anisotropy import (
|
||||||
Anisotropy,
|
Anisotropy,
|
||||||
logger,
|
logger,
|
||||||
simple,
|
Simple,
|
||||||
bodyCentered,
|
BodyCentered,
|
||||||
faceCentered
|
FaceCentered
|
||||||
)
|
)
|
||||||
|
|
||||||
import salomepl
|
import salomepl
|
||||||
@ -47,6 +47,7 @@ def genmesh(root, name, direction, theta):
|
|||||||
# Model
|
# Model
|
||||||
##
|
##
|
||||||
model = Anisotropy()
|
model = Anisotropy()
|
||||||
|
model.setupDB()
|
||||||
model.updateFromDB()
|
model.updateFromDB()
|
||||||
|
|
||||||
p = model.getParams(name, direction, theta)
|
p = model.getParams(name, direction, theta)
|
||||||
@ -70,8 +71,12 @@ def genmesh(root, name, direction, theta):
|
|||||||
# Shape
|
# Shape
|
||||||
##
|
##
|
||||||
geompy = salomepl.geometry.getGeom()
|
geompy = salomepl.geometry.getGeom()
|
||||||
structure = locals().get(p["name"])
|
structure = dict(
|
||||||
shape, groups = structure(**p["geometry"])
|
simple = Simple,
|
||||||
|
bodyCentered = BodyCentered,
|
||||||
|
faceCentered = FaceCentered
|
||||||
|
)[p["name"]]
|
||||||
|
shape, groups = structure(**p["geometry"]).build()
|
||||||
|
|
||||||
[length, surfaceArea, volume] = geompy.BasicProperties(shape, theTolerance = 1e-06)
|
[length, surfaceArea, volume] = geompy.BasicProperties(shape, theTolerance = 1e-06)
|
||||||
|
|
||||||
@ -98,7 +103,7 @@ def genmesh(root, name, direction, theta):
|
|||||||
|
|
||||||
faces = []
|
faces = []
|
||||||
for group in groups:
|
for group in groups:
|
||||||
if group.GetName() in mconfig["facesToIgnore"]:
|
if group.GetName() in mp["facesToIgnore"]:
|
||||||
faces.append(group)
|
faces.append(group)
|
||||||
|
|
||||||
|
|
||||||
|
@ -21,59 +21,10 @@ class Fineness(enum.Enum):
|
|||||||
VeryFine = 4
|
VeryFine = 4
|
||||||
Custom = 5
|
Custom = 5
|
||||||
|
|
||||||
class ExtrusionMethod(object):
|
|
||||||
pass
|
|
||||||
#SURF_OFFSET_SMOOTH = smeshBuilder.SURF_OFFSET_SMOOTH
|
|
||||||
#FACE_OFFSET = smeshBuilder.FACE_OFFSET
|
|
||||||
#NODE_OFFSET = smeshBuilder.NODE_OFFSET
|
|
||||||
|
|
||||||
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", old.GetMaxSize()))
|
old.SetMaxSize(new.get("maxSize", old.GetMaxSize()))
|
||||||
@ -112,13 +63,20 @@ class Mesh(object):
|
|||||||
|
|
||||||
self.params = updateParams(self.params, kwargs)
|
self.params = updateParams(self.params, kwargs)
|
||||||
|
|
||||||
|
def _extrusionMethod(self, key: str):
|
||||||
|
return dict(
|
||||||
|
SURF_OFFSET_SMOOTH = smeshBuilder.SURF_OFFSET_SMOOTH,
|
||||||
|
FACE_OFFSET = smeshBuilder.FACE_OFFSET,
|
||||||
|
NODE_OFFSET = smeshBuilder.NODE_OFFSET,
|
||||||
|
).get(key, smeshBuilder.SURF_OFFSET_SMOOTH)
|
||||||
|
|
||||||
def ViscousLayers(self,
|
def ViscousLayers(self,
|
||||||
thickness = 1,
|
thickness = 1,
|
||||||
numberOfLayers = 1,
|
numberOfLayers = 1,
|
||||||
stretchFactor = 0,
|
stretchFactor = 0,
|
||||||
faces = [],
|
faces = [],
|
||||||
isFacesToIgnore = True,
|
isFacesToIgnore = True,
|
||||||
extrMethod = None,#ExtrusionMethod.SURF_OFFSET_SMOOTH,
|
extrMethod = "SURF_OFFSET_SMOOTH",
|
||||||
**kwargs
|
**kwargs
|
||||||
):
|
):
|
||||||
|
|
||||||
@ -128,7 +86,7 @@ class Mesh(object):
|
|||||||
stretchFactor,
|
stretchFactor,
|
||||||
faces,
|
faces,
|
||||||
isFacesToIgnore,
|
isFacesToIgnore,
|
||||||
extrMethod
|
self._extrusionMethod(extrMethod)
|
||||||
)
|
)
|
||||||
|
|
||||||
def Triangle(self, subshape, **kwargs):
|
def Triangle(self, subshape, **kwargs):
|
||||||
|
34
simple
34
simple
@ -1,34 +0,0 @@
|
|||||||
runSalome running on localhost
|
|
||||||
Check if port can be used: 2900 - KO: port is busy
|
|
||||||
Searching for a free port for naming service: 2810 - OK
|
|
||||||
Searching Naming Service + found in 0.1 seconds
|
|
||||||
Searching /Registry in Naming Service + found in 0.5 seconds
|
|
||||||
Searching /Kernel/ModulCatalog in Naming Service + found in 0.5 seconds
|
|
||||||
RunStudy
|
|
||||||
Searching /Study in Naming Service + found in 0.5 seconds
|
|
||||||
Searching /Containers/elnafo/FactoryServer in Naming Service ++[1,
|
|
||||||
0,
|
|
||||||
0]
|
|
||||||
0.01
|
|
||||||
found in 1.0 seconds
|
|
||||||
Start SALOME, elapsed time : 2.7 seconds
|
|
||||||
th. 139821375270848 - Trace /volatile/salome/jenkins/workspace/Salome_master_CO7_MPI/SALOME-9.7.0-MPI-CO7/SOURCES/KERNEL/src/ModuleCatalog/SALOME_ModuleCatalog_Server.cxx [98] : Module Catalog Server: Naming Service was found
|
|
||||||
Warning, no type found for resource "localhost", using default value "single_machine"
|
|
||||||
Traceback (most recent call last):
|
|
||||||
File "/home/nafaryus/.vault/projects/anisotropy/anisotropy/genmesh.py", line 155, in <module>
|
|
||||||
genmesh()
|
|
||||||
File "/home/nafaryus/.vault/programs/SALOME/SALOME-9.7.0-MPI/BINARIES-CO7/Python/lib/python3.6/site-packages/click/core.py", line 722, in __call__
|
|
||||||
return self.main(*args, **kwargs)
|
|
||||||
File "/home/nafaryus/.vault/programs/SALOME/SALOME-9.7.0-MPI/BINARIES-CO7/Python/lib/python3.6/site-packages/click/core.py", line 697, in main
|
|
||||||
rv = self.invoke(ctx)
|
|
||||||
File "/home/nafaryus/.vault/programs/SALOME/SALOME-9.7.0-MPI/BINARIES-CO7/Python/lib/python3.6/site-packages/click/core.py", line 895, in invoke
|
|
||||||
return ctx.invoke(self.callback, **ctx.params)
|
|
||||||
File "/home/nafaryus/.vault/programs/SALOME/SALOME-9.7.0-MPI/BINARIES-CO7/Python/lib/python3.6/site-packages/click/core.py", line 535, in invoke
|
|
||||||
return callback(*args, **kwargs)
|
|
||||||
File "/home/nafaryus/.vault/projects/anisotropy/anisotropy/genmesh.py", line 25, in genmesh
|
|
||||||
direction = list(map(lambda num: float(num), direction[1:-1].split(",")))
|
|
||||||
File "/home/nafaryus/.vault/projects/anisotropy/anisotropy/genmesh.py", line 25, in <lambda>
|
|
||||||
direction = list(map(lambda num: float(num), direction[1:-1].split(",")))
|
|
||||||
ValueError: could not convert string to float:
|
|
||||||
ERROR:salomeContext:SystemExit 1 in method _runAppli.
|
|
||||||
th. 140195594066816 - Trace /volatile/salome/jenkins/workspace/Salome_master_CO7_MPI/SALOME-9.7.0-MPI-CO7/SOURCES/KERNEL/src/NamingService/SALOME_NamingService.cxx [1192] : Destroy_Name(): CORBA::SystemException: unable to contact the naming service
|
|
Loading…
Reference in New Issue
Block a user