Mod: simplification
This commit is contained in:
parent
f0d9d8b4fc
commit
a4d72a779a
@ -66,8 +66,6 @@ def bodyCenteredCubic(theta = 0.01, fillet = False, direction = [1, 0, 0]):
|
||||
vecflow = geompy.GetNormal(inletface)
|
||||
cubic = geompy.MakePrismVecH(inletface, vecflow, zh)
|
||||
|
||||
else:
|
||||
raise Exception("The direction is not implemented")
|
||||
|
||||
inletface = geompy.MakeScaleTransform(inletface, oo, scale)
|
||||
cubic = geompy.MakeScaleTransform(cubic, oo, scale)
|
||||
@ -284,3 +282,15 @@ def bodyCenteredHexagonalPrism(theta = 0.01, fillet = False, direction = [1, 1,
|
||||
groups.append(wall)
|
||||
|
||||
return shape, groups
|
||||
|
||||
|
||||
def bodyCentered(theta, fillet, direction):
|
||||
if direction in [[1, 0, 0], [0, 0, 1]]:
|
||||
return bodyCenteredCubic(theta, fillet, direction)
|
||||
|
||||
elif direction == [1, 1, 1]:
|
||||
return bodyCenteredHexagonalPrism(theta, fillet, direction)
|
||||
|
||||
else:
|
||||
raise Exception("This direction is not implemented")
|
||||
|
||||
|
@ -66,8 +66,6 @@ def faceCenteredCubic(theta = 0.01, fillet = False, direction = [1, 0, 0]):
|
||||
vecflow = geompy.GetNormal(inletface)
|
||||
cubic = geompy.MakePrismVecH(inletface, vecflow, 2 * zh)
|
||||
|
||||
else:
|
||||
raise Exception("The direction is not implemented")
|
||||
|
||||
inletface = geompy.MakeScaleTransform(inletface, oo, scale)
|
||||
cubic = geompy.MakeScaleTransform(cubic, oo, scale)
|
||||
@ -281,3 +279,15 @@ def faceCenteredHexagonalPrism(theta = 0.01, fillet = False, direction = [1, 1,
|
||||
groups.append(wall)
|
||||
|
||||
return shape, groups
|
||||
|
||||
|
||||
def faceCentered(theta, fillet, direction):
|
||||
if direction in [[1, 0, 0], [0, 0, 1]]:
|
||||
return faceCenteredCubic(theta, fillet, direction)
|
||||
|
||||
elif direction == [1, 1, 1]:
|
||||
return faceCenteredHexagonalPrism(theta, fillet, direction)
|
||||
|
||||
else:
|
||||
raise Exception("This direction is not implemented")
|
||||
|
||||
|
@ -33,9 +33,9 @@ logging.basicConfig(
|
||||
)
|
||||
logger = logging.getLogger(config.logger.name)
|
||||
|
||||
from salomepl.simple import simpleCubic, simpleHexagonalPrism
|
||||
from salomepl.faceCentered import faceCenteredCubic, faceCenteredHexagonalPrism
|
||||
from salomepl.bodyCentered import bodyCenteredCubic, bodyCenteredHexagonalPrism
|
||||
from salomepl.simple import simple
|
||||
from salomepl.faceCentered import faceCentered
|
||||
from salomepl.bodyCentered import bodyCentered
|
||||
|
||||
from salomepl.geometry import getGeom
|
||||
from salomepl.mesh import smeshBuilder, meshCreate, meshCompute, meshStats, meshExport
|
||||
@ -61,54 +61,14 @@ def genmesh(stype, theta, fillet, direction, export):
|
||||
flow direction:\t{}
|
||||
export path:\t{}""".format(stype, theta, fillet, direction, export))
|
||||
|
||||
params = (theta, fillet, direction)
|
||||
|
||||
salome.salome_init()
|
||||
|
||||
###
|
||||
# Structure and mesh configurations
|
||||
##
|
||||
if stype == "simple":
|
||||
if direction in [[1, 0, 0], [0, 0, 1]]:
|
||||
structure = simpleCubic
|
||||
|
||||
elif direction == [1, 1, 1]:
|
||||
structure = simpleHexagonalPrism
|
||||
|
||||
#fineness = config.simple.fineness
|
||||
#parameters = config.simple.parameters
|
||||
#viscousLayers = config.simple.viscousLayers
|
||||
meshParameters = config.simple.mesh
|
||||
|
||||
elif stype == "faceCentered":
|
||||
if direction in [[1, 0, 0], [0, 0, 1]]:
|
||||
structure = faceCenteredCubic
|
||||
|
||||
elif direction == [1, 1, 1]:
|
||||
structure = faceCenteredHexagonalPrism
|
||||
|
||||
#fineness = config.faceCentered.fineness
|
||||
#parameters = config.faceCentered.parameters
|
||||
#viscousLayers = config.faceCentered.viscousLayers
|
||||
meshParameters = config.faceCentered.mesh
|
||||
|
||||
elif stype == "bodyCentered":
|
||||
if direction in [[1, 0, 0], [0, 0, 1]]:
|
||||
structure = bodyCenteredCubic
|
||||
|
||||
elif direction == [1, 1, 1]:
|
||||
structure = bodyCenteredHexagonalPrism
|
||||
|
||||
#fineness = config.bodyCentered.fineness
|
||||
#parameters = config.bodyCentered.parameters
|
||||
#viscousLayers = config.bodyCentered.viscousLayers
|
||||
meshParameters = config.bodyCentered.mesh
|
||||
|
||||
###
|
||||
# Shape
|
||||
##
|
||||
geompy = getGeom()
|
||||
shape, groups = structure(*params)
|
||||
structure = globals().get(stype)
|
||||
shape, groups = structure(theta, fillet, direction)
|
||||
[length, surfaceArea, volume] = geompy.BasicProperties(shape, theTolerance = 1e-06)
|
||||
|
||||
logger.info("""shape:
|
||||
@ -124,6 +84,7 @@ def genmesh(stype, theta, fillet, direction, export):
|
||||
if group.GetName() in ["inlet", "outlet"]:
|
||||
facesToIgnore.append(group)
|
||||
|
||||
meshParameters = getattr(config, stype).mesh
|
||||
meshParameters.facesToIgnore = facesToIgnore
|
||||
meshParameters.extrusionMethod = smeshBuilder.SURF_OFFSET_SMOOTH
|
||||
|
||||
|
@ -3,236 +3,7 @@ from salome.geom import geomBuilder
|
||||
|
||||
geompy = geomBuilder.New()
|
||||
|
||||
import math
|
||||
from pyquaternion import Quaternion
|
||||
import numpy as np
|
||||
|
||||
|
||||
def getGeom():
|
||||
return geompy
|
||||
|
||||
|
||||
def createGroup(gobj, planelist, grains, name):
|
||||
gr = geompy.CreateGroup(gobj, geompy.ShapeType["FACE"], name)
|
||||
|
||||
grcomp = geompy.MakeCompound(planelist)
|
||||
#grcut = geompy.MakeCutList(grcomp, [grains], False)
|
||||
|
||||
gip = geompy.GetInPlace(gobj, grcomp, True)
|
||||
faces = geompy.SubShapeAll(gip, geompy.ShapeType["FACE"])
|
||||
geompy.UnionList(gr, faces)
|
||||
|
||||
return gr
|
||||
|
||||
|
||||
def createBoundary(gobj, bcount, dvec, norm, grains):
|
||||
ang = lambda n, count: 2 * np.pi * n / count
|
||||
limit = bcount if np.mod(bcount, 2) else int(bcount / 2)
|
||||
|
||||
vecs = [ Quaternion(axis = dvec, angle = ang(n, bcount)).rotate(norm) for n in range(limit) ]
|
||||
|
||||
logging.info("""createBoundary:
|
||||
flow direction:\t{}
|
||||
side boundaries:\t{}
|
||||
normal direction:\t{}
|
||||
angles:\t{}
|
||||
side directions:\t{}""".format(dvec, bcount, norm,
|
||||
[ ang(n, bcount) / (2 * np.pi) * 360 for n in range(limit) ],
|
||||
len(vecs))) #[ v for v in vecs ]))
|
||||
|
||||
#
|
||||
flowvec = geompy.MakeVector(
|
||||
geompy.MakeVertex(0, 0, 0),
|
||||
geompy.MakeVertex(dvec[0], dvec[1], dvec[2]))
|
||||
symvec = []
|
||||
|
||||
for vec in vecs:
|
||||
#vec = qvec.vector
|
||||
symvec.append(geompy.MakeVector(
|
||||
geompy.MakeVertex(0, 0, 0),
|
||||
geompy.MakeVertex(vec[0], vec[1], vec[2])))
|
||||
|
||||
|
||||
#
|
||||
planes = geompy.ExtractShapes(gobj, geompy.ShapeType["FACE"], False)
|
||||
#planes = geompy.MakeCompound(planes)
|
||||
planes = geompy.MakeShell(planes)
|
||||
#planes = geompy.ProcessShape(planes,
|
||||
# [ "FixShape", "FixFaceSize", "DropSmallEdges", "SameParameter" ],
|
||||
# [ "FixShape.Tolerance3d", "FixShape.MaxTolerance3d", "FixFaceSize.Tolerance", "DropSmallEdges.Tolerance3d", "SameParameter.Tolerance3d" ],
|
||||
# [ "1e-7", "1", "0.05", "0.05", "1e-7" ])
|
||||
planes = geompy.MakeCutList(planes, [grains], False)
|
||||
planes = geompy.ExtractShapes(planes, geompy.ShapeType["FACE"], False)
|
||||
#print("planes: ", len(planes))
|
||||
|
||||
inletplanes = []
|
||||
outletplanes = []
|
||||
symetryplanes = [[None, None] for n in range(limit)]
|
||||
|
||||
for plane in planes:
|
||||
nvec = geompy.GetNormal(plane)
|
||||
|
||||
fwang = round(geompy.GetAngle(nvec, flowvec), 0)
|
||||
#print("fwang = ", fwang)
|
||||
|
||||
if fwang == 0:
|
||||
inletplanes.append(plane)
|
||||
|
||||
elif fwang == 180:
|
||||
outletplanes.append(plane)
|
||||
|
||||
for n in range(len(symvec)):
|
||||
sang = round(geompy.GetAngle(nvec, symvec[n]), 0)
|
||||
#print("sang = ", sang)
|
||||
|
||||
if sang == 0:
|
||||
if symetryplanes[n][0] == None:
|
||||
symetryplanes[n][0] = []
|
||||
|
||||
symetryplanes[n][0].append(plane)
|
||||
|
||||
elif sang == 180:
|
||||
if symetryplanes[n][1] == None:
|
||||
symetryplanes[n][1] = []
|
||||
|
||||
symetryplanes[n][1].append(plane)
|
||||
#print("\n")
|
||||
|
||||
symetryplanesinfo = []
|
||||
for n in range(len(symetryplanes)):
|
||||
symetryplanesinfo.append([])
|
||||
for pair in range(len(symetryplanes[n])):
|
||||
symetryplanesinfo[n].append(len(symetryplanes[n][pair]))
|
||||
|
||||
logging.info("""createBoundary:
|
||||
planes:\t{}
|
||||
inlet planes:\t{}
|
||||
outlet planes:\t{}
|
||||
side planes:\t{}""".format(len(planes), len(inletplanes), len(outletplanes), symetryplanesinfo))
|
||||
|
||||
#
|
||||
boundary = {}
|
||||
|
||||
boundary["inlet"] = createGroup(gobj, inletplanes, grains, "inlet")
|
||||
boundary["outlet"] = createGroup(gobj, outletplanes, grains, "outlet")
|
||||
|
||||
for n in range(len(symetryplanes)):
|
||||
name = "symetryPlane{}".format(n + 1)
|
||||
|
||||
boundary[name + "_1"] = createGroup(gobj, symetryplanes[n][0], grains, name + "_1")
|
||||
|
||||
if not symetryplanes[n][1] == None:
|
||||
boundary[name + "_2"] = createGroup(gobj, symetryplanes[n][1], grains, name + "_2")
|
||||
|
||||
# wall
|
||||
allgroup = geompy.CreateGroup(gobj, geompy.ShapeType["FACE"])
|
||||
faces = geompy.SubShapeAllIDs(gobj, geompy.ShapeType["FACE"])
|
||||
geompy.UnionIDs(allgroup, faces)
|
||||
boundary["wall"] = geompy.CutListOfGroups([allgroup], list(boundary.values()), "wall")
|
||||
|
||||
return boundary
|
||||
|
||||
|
||||
def boundaryCreate(gobj, dvec, grains):
|
||||
|
||||
xvec = geompy.MakeVector(
|
||||
geompy.MakeVertex(0, 0, 0),
|
||||
geompy.MakeVertex(dvec.x[0], dvec.x[1], dvec.x[2]))
|
||||
#xvec = rotate(xvec, [0, 0, 0.25 * math.pi])
|
||||
|
||||
#yvec = rotate(xvec, [0.5 * math.pi, 0, 0])
|
||||
#zvec = rotate(xvec, [0, 0.5 * math.pi, 0])
|
||||
|
||||
yvec = geompy.MakeVector(
|
||||
geompy.MakeVertex(0, 0, 0),
|
||||
geompy.MakeVertex(dvec.y[0], dvec.y[1], dvec.y[2]))
|
||||
zvec = geompy.MakeVector(
|
||||
geompy.MakeVertex(0, 0, 0),
|
||||
geompy.MakeVertex(dvec.z[0], dvec.z[1], dvec.z[2]))
|
||||
|
||||
geompy.addToStudy(xvec, "xvec")
|
||||
geompy.addToStudy(yvec, "yvec")
|
||||
geompy.addToStudy(zvec, "zvec")
|
||||
|
||||
logging.info("""boundaryCreate:
|
||||
direction vectors: x = {}
|
||||
y = {}
|
||||
z = {}""".format(dvec.x, dvec.y, dvec.z))
|
||||
|
||||
planes = geompy.ExtractShapes(gobj, geompy.ShapeType["FACE"], False)
|
||||
planes = geompy.MakeCompound(planes)
|
||||
planes = geompy.MakeCutList(planes, [grains], False)
|
||||
planes = geompy.ExtractShapes(planes, geompy.ShapeType["FACE"], False)
|
||||
|
||||
inletplanes = []
|
||||
outletplanes = []
|
||||
#uplanes = []
|
||||
|
||||
fwplanes = []
|
||||
bwplanes = []
|
||||
lplanes = []
|
||||
rplanes = []
|
||||
|
||||
for plane in planes:
|
||||
nvec = geompy.GetNormal(plane)
|
||||
xang = round(geompy.GetAngle(nvec, xvec), 0)
|
||||
yang = round(geompy.GetAngle(nvec, yvec), 0)
|
||||
zang = round(geompy.GetAngle(nvec, zvec), 0)
|
||||
#print(xang, yang, zang, sep="\t")
|
||||
|
||||
if xang == 0:
|
||||
inletplanes.append(plane)
|
||||
|
||||
elif xang == 180:
|
||||
outletplanes.append(plane)
|
||||
|
||||
elif yang == 0:
|
||||
fwplanes.append(plane)
|
||||
|
||||
elif yang == 180:
|
||||
bwplanes.append(plane)
|
||||
|
||||
elif zang == 0:
|
||||
lplanes.append(plane)
|
||||
|
||||
elif zang == 180:
|
||||
rplanes.append(plane)
|
||||
|
||||
logging.info("""boundaryCreate:
|
||||
planes count:\t{}
|
||||
inlet planes:\t{}
|
||||
outlet planes:\t{}
|
||||
forward planes:\t{}
|
||||
backward planes:\t{}
|
||||
left planes:\t{}
|
||||
right planes:\t{}""".format(len(planes), len(inletplanes), len(outletplanes),
|
||||
len(fwplanes), len(bwplanes), len(lplanes), len(rplanes)))
|
||||
|
||||
# Main groups
|
||||
inlet = createGroup(gobj, inletplanes, grains, "inlet")
|
||||
outlet = createGroup(gobj, outletplanes, grains, "outlet")
|
||||
|
||||
symetryPlaneFW = createGroup(gobj, fwplanes, grains, "symetryPlaneFW")
|
||||
symetryPlaneBW = createGroup(gobj, bwplanes, grains, "symetryPlaneBW")
|
||||
symetryPlaneL = createGroup(gobj, lplanes, grains, "symetryPlaneL")
|
||||
symetryPlaneR = createGroup(gobj, rplanes, grains, "symetryPlaneR")
|
||||
|
||||
# wall
|
||||
allgroup = geompy.CreateGroup(gobj, geompy.ShapeType["FACE"])
|
||||
faces = geompy.SubShapeAllIDs(gobj, geompy.ShapeType["FACE"])
|
||||
geompy.UnionIDs(allgroup, faces)
|
||||
wall = geompy.CutListOfGroups([allgroup],
|
||||
[inlet, outlet, symetryPlaneFW, symetryPlaneBW, symetryPlaneL, symetryPlaneR], "wall")
|
||||
|
||||
boundary = {
|
||||
"inlet": inlet,
|
||||
"outlet": outlet,
|
||||
"symetryPlaneFW": symetryPlaneFW,
|
||||
"symetryPlaneBW": symetryPlaneBW,
|
||||
"symetryPlaneL": symetryPlaneL,
|
||||
"symetryPlaneR": symetryPlaneR,
|
||||
"wall": wall
|
||||
}
|
||||
|
||||
return boundary
|
||||
|
||||
|
@ -62,9 +62,7 @@ def simpleCubic(theta = 0.01, fillet = False, direction = [1, 0, 0]):
|
||||
vecflow = geompy.GetNormal(inletface)
|
||||
cubic = geompy.MakePrismVecH(inletface, vecflow, height)
|
||||
|
||||
else:
|
||||
raise Exception("The direction is not implemented")
|
||||
|
||||
|
||||
inletface = geompy.MakeScaleTransform(inletface, oo, scale)
|
||||
cubic = geompy.MakeScaleTransform(cubic, oo, scale)
|
||||
|
||||
@ -261,3 +259,15 @@ def simpleHexagonalPrism(theta = 0.01, fillet = False, direction = [1, 1, 1]):
|
||||
groups.append(wall)
|
||||
|
||||
return shape, groups
|
||||
|
||||
|
||||
def simple(theta, fillet, direction):
|
||||
if direction in [[1, 0, 0], [0, 0, 1]]:
|
||||
return simpleCubic(theta, fillet, direction)
|
||||
|
||||
elif direction == [1, 1, 1]:
|
||||
return simpleHexagonalPrism(theta, fillet, direction)
|
||||
|
||||
else:
|
||||
raise Exception("This direction is not implemented")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user