84 lines
2.7 KiB
Python
Raw Normal View History

2021-02-12 13:05:02 +05:00
import GEOM
from salome.geom import geomBuilder
geompy = geomBuilder.New()
import math
def create(alpha):
2021-02-16 16:20:03 +05:00
# xyz axes
2021-02-12 13:05:02 +05:00
axes = [
geompy.MakeVectorDXDYDZ(1, 0, 0),
geompy.MakeVectorDXDYDZ(0, 1, 0),
geompy.MakeVectorDXDYDZ(0, 0, 1)
]
2021-02-16 16:20:03 +05:00
# Main box
2021-02-12 13:05:02 +05:00
box = geompy.MakeBoxDXDYDZ(2 * math.sqrt(2), 2 * math.sqrt(2), 2)
box = geompy.MakeRotation(box, axes[2], 45 * math.pi / 180.0)
box = geompy.MakeTranslation(box, 2, 0, 0)
2021-02-12 13:05:02 +05:00
vtx = [
geompy.MakeVertex(2, 0, 0),
geompy.MakeVertex(2, 2, 0),
geompy.MakeVertex(2, 2, 2)
]
2021-02-12 13:05:02 +05:00
line = geompy.MakeLineTwoPnt(vtx[1], vtx[2])
2021-02-16 16:20:03 +05:00
# Spheres for cutting
2021-02-12 13:05:02 +05:00
sphere = geompy.MakeSpherePntR(vtx[0], 1 / (1 - alpha))
sphere = geompy.MakeMultiTranslation1D(sphere, axes[1], 2, 3)
cut = geompy.MakeCutList(box, [sphere], True)
2021-02-12 13:05:02 +05:00
sphere2 = geompy.MakeTranslation(sphere, 0, 0, 2)
cut2 = geompy.MakeCutList(cut, [sphere2], True)
2021-02-12 13:05:02 +05:00
sphere3 = geompy.MakeRotation(sphere, line, 90 * math.pi / 180.0)
cut3 = geompy.MakeCutList(cut2, [sphere3], True)
2021-02-12 13:05:02 +05:00
sphere4 = geompy.MakeTranslation(sphere3, 0, 0, 2)
2021-02-16 16:20:03 +05:00
# Main geometry
2021-02-12 13:05:02 +05:00
Pore = geompy.MakeCutList(cut3, [sphere4], True)
geompy.addToStudy(Pore, "PORE")
2021-03-01 16:06:53 +05:00
#
# D /\ B A(1, 1, 0) \vec{n}(1, 1, 0)
# / \ B(3, 3, 0) \vec{n}(1, 1, 0)
# \ / C(3, 1, 0) \vec{n}(-1, 1, 0)
# A \/ C D(1, 3, 0) \vec{n}(-1, 1, 0)
#
2021-02-16 16:20:03 +05:00
# Prepare faces
vtx.append(geompy.MakeVertex(2, 2, 2))
vtx.append(geompy.MakeVertexWithRef(vtx[3], 0, 0, 1))
vec2 = geompy.MakeVector(vtx[3], vtx[4])
plane = geompy.MakePlane(vtx[3], vec2, 5)
common1 = geompy.MakeCommonList([Pore, plane], True)
plane = geompy.MakeTranslation(plane, 0, 0, -2)
common2 = geompy.MakeCommonList([Pore, plane], True)
2021-03-01 16:06:53 +05:00
# TODO: make 4 planes A B C D
Pore = geompy.MakeFillet(Pore, 0.1, geompy.ShapeType["EDGE"], [24, 27, 35])
2021-02-16 16:20:03 +05:00
# Main groups (inlet, outlet, wall)
inlet = geompy.CreateGroup(Pore, geompy.ShapeType["FACE"])
gip = geompy.GetInPlace(Pore, common1, True)
faces = geompy.SubShapeAll(gip, geompy.ShapeType["FACE"])
geompy.UnionList(inlet, faces)
2021-02-16 16:20:03 +05:00
outlet = geompy.CreateGroup(Pore, geompy.ShapeType["FACE"])
gip = geompy.GetInPlace(Pore, common2, True)
faces = geompy.SubShapeAll(gip, geompy.ShapeType["FACE"])
geompy.UnionList(outlet, faces)
2021-02-16 16:20:03 +05:00
PoreGroup = geompy.CreateGroup(Pore, geompy.ShapeType["FACE"])
faces = geompy.SubShapeAllIDs(Pore, geompy.ShapeType["FACE"])
geompy.UnionIDs(PoreGroup, faces)
2021-02-16 16:20:03 +05:00
wall = geompy.CutListOfGroups([PoreGroup], [inlet, outlet])
2021-02-16 16:20:03 +05:00
return Pore, [inlet, outlet, wall]