Automation for boundaries
This commit is contained in:
parent
e5369321a4
commit
44ce05b86e
@ -12,6 +12,7 @@ class simpleCubic:
|
|||||||
self.geometry = None
|
self.geometry = None
|
||||||
self.mesh = None
|
self.mesh = None
|
||||||
self.boundary = None
|
self.boundary = None
|
||||||
|
salome.salome_init()
|
||||||
|
|
||||||
def geometryCreate(self, alpha):
|
def geometryCreate(self, alpha):
|
||||||
geompy = geomBuilder.New()
|
geompy = geomBuilder.New()
|
||||||
@ -69,18 +70,18 @@ class simpleCubic:
|
|||||||
center = geompy.MakeVertex(2, 2, 1)
|
center = geompy.MakeVertex(2, 2, 1)
|
||||||
rot = [0, 0, 45]
|
rot = [0, 0, 45]
|
||||||
|
|
||||||
if direction == "100":
|
if direction == "001":
|
||||||
norm = geompy.MakeVector(center,
|
norm = geompy.MakeVector(center,
|
||||||
geompy.MakeVertexWithRef(center, 0, 0, 1))
|
geompy.MakeVertexWithRef(center, 0, 0, 1))
|
||||||
vstep = math.sqrt(2)
|
|
||||||
hstep = 1
|
|
||||||
|
|
||||||
elif direction == "001":
|
|
||||||
norm = geompy.MakeVector(center,
|
|
||||||
geompy.MakeVertexWithRef(center, 1, 0, 0))
|
|
||||||
vstep = 1
|
vstep = 1
|
||||||
hstep = math.sqrt(2)
|
hstep = math.sqrt(2)
|
||||||
|
|
||||||
|
elif direction == "100":
|
||||||
|
norm = geompy.MakeVector(center,
|
||||||
|
geompy.MakeVertexWithRef(center, 1, 0, 0))
|
||||||
|
vstep = math.sqrt(2)
|
||||||
|
hstep = 1
|
||||||
|
|
||||||
def createGroup(shape, name):
|
def createGroup(shape, name):
|
||||||
group = geompy.CreateGroup(self.geometry,
|
group = geompy.CreateGroup(self.geometry,
|
||||||
geompy.ShapeType["FACE"], name)
|
geompy.ShapeType["FACE"], name)
|
||||||
@ -97,44 +98,71 @@ class simpleCubic:
|
|||||||
geompy.MakeVectorDXDYDZ(0, 0, 1)
|
geompy.MakeVectorDXDYDZ(0, 0, 1)
|
||||||
]
|
]
|
||||||
|
|
||||||
# Main box
|
# Bounding box
|
||||||
box = geompy.MakeBoxDXDYDZ(2 * math.sqrt(2), 2 * math.sqrt(2), 2)
|
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.MakeRotation(box, axes[2], 45 * math.pi / 180.0)
|
||||||
box = geompy.MakeTranslation(box, 2, 0, 0)
|
box = geompy.MakeTranslation(box, 2, 0, 0)
|
||||||
planes = geompy.ExtractShapes(box,
|
planes = geompy.ExtractShapes(box,
|
||||||
geompy.ShapeType["FACE"], True)
|
geompy.ShapeType["FACE"], True)
|
||||||
planecommon = []
|
|
||||||
|
|
||||||
|
vplanes = []
|
||||||
|
hplanes = []
|
||||||
for plane in planes:
|
for plane in planes:
|
||||||
planecommon.append(geompy.MakeCommonList([self.geometry, plane], True))
|
planeNorm = geompy.GetNormal(plane)
|
||||||
|
angle = geompy.GetAngle(planeNorm, norm)
|
||||||
|
|
||||||
planegroup = geompy.CreateGroup(self.geometry, geompy.ShapeType["FACE"])
|
if angle == 0 or angle == 180:
|
||||||
for planecom in planecommon:
|
vplanes.append(plane)
|
||||||
faces = geompy.SubShapeAllIDs(planecom, geompy.ShapeType["FACE"])
|
|
||||||
geompy.UnionIDs(planegroup, faces)
|
else:
|
||||||
|
hplanes.append(plane)
|
||||||
|
|
||||||
|
zvplane1 = vplanes[0]
|
||||||
|
zvplane2 = vplanes[1]
|
||||||
|
|
||||||
|
if direction == "001":
|
||||||
|
if geompy.GetPosition(zvplane1)[3] > geompy.GetPosition(zvplane1)[3]:
|
||||||
|
inletplane = zvplane1
|
||||||
|
outletplane = zvplane2
|
||||||
|
|
||||||
|
else:
|
||||||
|
inletplane = zvplane2
|
||||||
|
outletplane = zvplane1
|
||||||
|
|
||||||
|
elif direction == "100":
|
||||||
|
if geompy.GetPosition(zvplane1)[1] > geompy.GetPosition(zvplane1)[1]:
|
||||||
|
inletplane = zvplane1
|
||||||
|
outletplane = zvplane2
|
||||||
|
|
||||||
|
else:
|
||||||
|
inletplane = zvplane2
|
||||||
|
outletplane = zvplane1
|
||||||
|
|
||||||
|
|
||||||
# Prepare faces
|
# inlet and outlet
|
||||||
#vtx.append(geompy.MakeVertex(2, 2, 2))
|
common1 = geompy.MakeCommonList([self.geometry, inletplane], True)
|
||||||
#vtx.append(geompy.MakeVertexWithRef(vtx[3], 0, 0, 1))
|
inlet = createGroup(common1, "inlet")
|
||||||
#vec2 = geompy.MakeVector(vtx[3], vtx[4])
|
|
||||||
plane = geompy.MakePlane(center, norm, 5)
|
|
||||||
|
|
||||||
plane2 = geompy.MakeTranslationVectorDistance(plane, norm, vstep)
|
common2 = geompy.MakeCommonList([self.geometry, outletplane], True)
|
||||||
common2 = geompy.MakeCommonList([self.geometry, plane2], True)
|
outlet = createGroup(common2, "outlet")
|
||||||
inlet = createGroup(common2, "inlet")
|
|
||||||
|
|
||||||
plane3 = geompy.MakeTranslationVectorDistance(plane, norm, -vstep)
|
geompy.addToStudy(inletplane, "inletplane")
|
||||||
common3 = geompy.MakeCommonList([self.geometry, plane3], True)
|
geompy.addToStudy(outletplane, "outletplane")
|
||||||
outlet = createGroup(common3, "outlet")
|
|
||||||
|
|
||||||
symetryPlane = geompy.CutListOfGroups([planegroup], [inlet, outlet])
|
# symetryPlane(s)
|
||||||
|
symetryPlane = geompy.CreateGroup(self.geometry, geompy.ShapeType["FACE"], "symetryPlane")
|
||||||
|
|
||||||
PoreGroup = geompy.CreateGroup(self.geometry, geompy.ShapeType["FACE"])
|
for plane in hplanes:
|
||||||
|
common3 = geompy.MakeCommonList([self.geometry, plane], True)
|
||||||
|
gip = geompy.GetInPlace(self.geometry, common3, True)
|
||||||
|
faces = geompy.SubShapeAll(gip, geompy.ShapeType["FACE"])
|
||||||
|
geompy.UnionList(symetryPlane, faces)
|
||||||
|
|
||||||
|
# wall
|
||||||
|
allgroup = geompy.CreateGroup(self.geometry, geompy.ShapeType["FACE"])
|
||||||
faces = geompy.SubShapeAllIDs(self.geometry, geompy.ShapeType["FACE"])
|
faces = geompy.SubShapeAllIDs(self.geometry, geompy.ShapeType["FACE"])
|
||||||
geompy.UnionIDs(PoreGroup, faces)
|
geompy.UnionIDs(allgroup, faces)
|
||||||
|
wall = geompy.CutListOfGroups([allgroup], [inlet, outlet, symetryPlane], "wall")
|
||||||
wall = geompy.CutListOfGroups([PoreGroup], [inlet, outlet, symetryPlane])
|
|
||||||
|
|
||||||
self.boundary = {
|
self.boundary = {
|
||||||
"inlet": inlet,
|
"inlet": inlet,
|
||||||
@ -148,7 +176,6 @@ class simpleCubic:
|
|||||||
def meshCreate(self):
|
def meshCreate(self):
|
||||||
smesh = smeshBuilder.New()
|
smesh = smeshBuilder.New()
|
||||||
|
|
||||||
|
|
||||||
mesh = smesh.Mesh(geomObj)
|
mesh = smesh.Mesh(geomObj)
|
||||||
netgen = mesh.Tetrahedron(algo=smeshBuilder.NETGEN_1D2D3D)
|
netgen = mesh.Tetrahedron(algo=smeshBuilder.NETGEN_1D2D3D)
|
||||||
|
|
||||||
@ -171,9 +198,10 @@ class simpleCubic:
|
|||||||
vlayer = netgen.ViscousLayers(0.025, 2, 1.1, [],
|
vlayer = netgen.ViscousLayers(0.025, 2, 1.1, [],
|
||||||
1, smeshBuilder.NODE_OFFSET)
|
1, smeshBuilder.NODE_OFFSET)
|
||||||
|
|
||||||
mesh.GroupOnGeom(bc[0], 'inlet', SMESH.FACE)
|
mesh.GroupOnGeom(self.boundary["inlet"], "inlet", SMESH.FACE)
|
||||||
mesh.GroupOnGeom(bc[1], 'outlet', SMESH.FACE)
|
mesh.GroupOnGeom(self.boundary["outlet"], "outlet", SMESH.FACE)
|
||||||
mesh.GroupOnGeom(bc[2], 'wall', SMESH.FACE)
|
mesh.GroupOnGeom(self.boundary["symetryPlane"], "symetryPlane", SMESH.FACE)
|
||||||
|
mesh.GroupOnGeom(self.boundary["wall"], "wall", SMESH.FACE)
|
||||||
|
|
||||||
self.mesh = mesh
|
self.mesh = mesh
|
||||||
|
|
||||||
@ -202,7 +230,7 @@ if __name__ == "__main__":
|
|||||||
alpha = float(sys.argv[2])
|
alpha = float(sys.argv[2])
|
||||||
direction = str(sys.argv[3])
|
direction = str(sys.argv[3])
|
||||||
|
|
||||||
salome.salome_init()
|
#salome.salome_init()
|
||||||
sc = simpleCubic("simpleCubic-{}-{}".format(direction, alpha))
|
sc = simpleCubic("simpleCubic-{}-{}".format(direction, alpha))
|
||||||
sc.geometryCreate(alpha)
|
sc.geometryCreate(alpha)
|
||||||
sc.boundaryCreate(direction)
|
sc.boundaryCreate(direction)
|
||||||
|
Loading…
Reference in New Issue
Block a user