3 direction for simpleCubic

This commit is contained in:
L-Nafaryus 2021-03-05 00:02:47 +05:00
parent 5b14cc5b81
commit 8eca4d0491
No known key found for this signature in database
GPG Key ID: C76D8DCD2727DBB7
2 changed files with 86 additions and 23 deletions

View File

@ -12,9 +12,9 @@
- [ ] less processes for salome, optimization. - [ ] less processes for salome, optimization.
## 4.03.21 ## 4.03.21
- [ ] 3rd direction - [x] 3rd direction
- [ ] createPatch(Dict) - [ ] createPatch(Dict)
- [ ] views (mesh, ..) - [ ] views (mesh, ..)
- [ ] alpha for simpleCubic [0.01 .. 0.28] - [ ] alpha for simpleCubic [0.01 .. 0.28]
- [ ] translation vector (cyclicAMI) - [ ] translation vector (cyclicAMI)
- [ ] BUG: angle between the direction vector and the normal to inlet is ~1.4e-14

View File

@ -13,8 +13,13 @@ class simpleCubic:
def __init__(self, name = None): def __init__(self, name = None):
self.name = name if type(name) != None else "simpleCubic" self.name = name if type(name) != None else "simpleCubic"
self.geometry = None self.geometry = None
self.geometrybbox = None
self.mesh = None self.mesh = None
self.boundary = None self.boundary = None
self.rombus = None
self.rombusbbox = None
salome.salome_init() salome.salome_init()
def geometryCreate(self, alpha): def geometryCreate(self, alpha):
@ -36,7 +41,7 @@ class simpleCubic:
# #
R_0 = 1 R_0 = 1
R = R_0 / (1 - alpha) R = R_0 / (1 - alpha)
R_fillet = 0.1 R_fillet = 0.05
# xyz axes # xyz axes
axes = [ axes = [
@ -63,17 +68,41 @@ class simpleCubic:
sphere = geompy.MakeMultiTranslation2D(sphere, None, 2, 3, None, 2, 3) sphere = geompy.MakeMultiTranslation2D(sphere, None, 2, 3, None, 2, 3)
sphere = geompy.MakeTranslation(sphere, -2, 0, 0) sphere = geompy.MakeTranslation(sphere, -2, 0, 0)
sphere2 = geompy.MakeTranslation(sphere, 0, 0, 2) sphere2 = geompy.MakeTranslation(sphere, 0, 0, 2)
sphere3 = geompy.MakeTranslation(sphere2, 0, 0, 2)
sphere = geompy.ExtractShapes(sphere, geompy.ShapeType["SOLID"], True) sphere = geompy.ExtractShapes(sphere, geompy.ShapeType["SOLID"], True)
sphere2 = geompy.ExtractShapes(sphere2, geompy.ShapeType["SOLID"], True) sphere2 = geompy.ExtractShapes(sphere2, geompy.ShapeType["SOLID"], True)
sphere3 = geompy.ExtractShapes(sphere3, geompy.ShapeType["SOLID"], True)
sphere = geompy.MakeFuseList(sphere + sphere2, True, True) sphere = geompy.MakeFuseList(sphere + sphere2 + sphere3, True, True)
sphere = geompy.MakeFilletAll(sphere, R_fillet) sphere = geompy.MakeFilletAll(sphere, R_fillet)
self.geometry = geompy.MakeCutList(box, [sphere], True) self.geometry = geompy.MakeCutList(box, [sphere], True)
self.geometrybbox = box
geompy.addToStudy(self.geometry, self.name) geompy.addToStudy(self.geometry, self.name)
# Rombus
h = 2
sk = geompy.Sketcher3D()
sk.addPointsAbsolute(0, 0, h * 2)
sk.addPointsAbsolute(h, 0, h)
sk.addPointsAbsolute(h, h, 0)
sk.addPointsAbsolute(0, h, h)
sk.addPointsAbsolute(0, 0, h * 2)
a3D_Sketcher_1 = sk.wire()
Face_1 = geompy.MakeFaceWires([a3D_Sketcher_1], 1)
Vector_1 = geompy.MakeVectorDXDYDZ(h, h, 0)
rombus = geompy.MakePrismVecH(Face_1, Vector_1, 2 * math.sqrt(2))
geompy.addToStudy(rombus, "romb")
self.rombus = geompy.MakeCutList(rombus, [sphere], True)
self.rombusbbox = rombus
geompy.addToStudy(self.rombus, "rombus")
return self.geometry return self.geometry
def boundaryCreate(self, direction): def boundaryCreate(self, direction):
@ -112,24 +141,45 @@ class simpleCubic:
# #
geompy = geomBuilder.New() geompy = geomBuilder.New()
center = geompy.MakeVertex(2, 2, 1)
rot = [0, 0, 45] rot = [0, 0, 45]
buffergeometry = self.geometry
if direction == "001": if direction == "001":
center = geompy.MakeVertex(2, 2, 1)
norm = geompy.MakeVector(center, norm = geompy.MakeVector(center,
geompy.MakeVertexWithRef(center, 0, 0, 1)) geompy.MakeVertexWithRef(center, 0, 0, 1))
vstep = 1 vstep = 1
hstep = math.sqrt(2) hstep = math.sqrt(2)
elif direction == "100": elif direction == "100":
center = geompy.MakeVertex(2, 2, 1)
norm = geompy.MakeVector(center, norm = geompy.MakeVector(center,
geompy.MakeVertexWithRef(center, geompy.MakeVertexWithRef(center,
math.cos((90 + rot[2]) * math.pi / 180.0), -math.cos((90 + rot[2]) * math.pi / 180.0),
-math.sin((90 + rot[2]) * math.pi / 180.0), 0)) math.sin((90 + rot[2]) * math.pi / 180.0), 0))
vstep = math.sqrt(2) vstep = math.sqrt(2)
hstep = 1 hstep = 1
elif direction == "111":
center = geompy.MakeVertex(2, 2, 2)
norm = geompy.MakeVector(center,
geompy.MakeVertexWithRef(center,
-math.cos((90 + rot[2]) * math.pi / 180.0),
math.sin((90 + rot[2]) * math.pi / 180.0), math.sqrt(2) / 2))
vstep = math.sqrt(2)
hstep = 1
geompy.addToStudy(norm, "normalvector")
def createGroup(shape, name): def createGroup(shape, name):
self.geometry = self.rombus
group = geompy.CreateGroup(self.geometry, group = geompy.CreateGroup(self.geometry,
geompy.ShapeType["FACE"], name) geompy.ShapeType["FACE"], name)
gip = geompy.GetInPlace(self.geometry, shape, True) gip = geompy.GetInPlace(self.geometry, shape, True)
@ -139,29 +189,42 @@ class simpleCubic:
return group return group
# xyz axes # xyz axes
axes = [ #axes = [
geompy.MakeVectorDXDYDZ(1, 0, 0), # geompy.MakeVectorDXDYDZ(1, 0, 0),
geompy.MakeVectorDXDYDZ(0, 1, 0), # geompy.MakeVectorDXDYDZ(0, 1, 0),
geompy.MakeVectorDXDYDZ(0, 0, 1) # geompy.MakeVectorDXDYDZ(0, 0, 1)
] #]
# Bounding 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)
if direction == "111":
box = self.rombusbbox
else:
box = self.geometrybbox
planes = geompy.ExtractShapes(box, geompy.ShapeType["FACE"], True) planes = geompy.ExtractShapes(box, geompy.ShapeType["FACE"], True)
vplanes = [] vplanes = []
hplanes = [] hplanes = []
n = 0
for plane in planes: for plane in planes:
planeNorm = geompy.GetNormal(plane) planeNorm = geompy.GetNormal(plane)
angle = abs(geompy.GetAngle(planeNorm, norm)) n += 1
geompy.addToStudy(planeNorm, "normalplane-{}".format(n))
angle = int(abs(geompy.GetAngle(planeNorm, norm)))
logging.info("angle = {}".format(angle))
if angle == 0 or angle == 180: if angle == 0 or angle == 180:
vplanes.append(plane) vplanes.append(plane)
else: else:
hplanes.append(plane) hplanes.append(plane)
if salome.sg.hasDesktop():
salome.sg.updateObjBrowser()
logging.info(len(vplanes))
logging.info(len(hplanes))
if direction == "001": if direction == "001":
z1 = geompy.GetPosition(vplanes[0])[3] z1 = geompy.GetPosition(vplanes[0])[3]
@ -175,10 +238,10 @@ class simpleCubic:
inletplane = vplanes[1] inletplane = vplanes[1]
outletplane = vplanes[0] outletplane = vplanes[0]
elif direction == "100": elif direction == "100" or direction == "111":
x1 = geompy.GetPosition(vplanes[0])[1] x1 = geompy.GetPosition(vplanes[0])[1]
x2 = geompy.GetPosition(vplanes[1])[1] x2 = geompy.GetPosition(vplanes[1])[1]
logging.info("x1 = {}, x2 = {}".format(x1, x2))
if x1 > x2: if x1 > x2:
inletplane = vplanes[0] inletplane = vplanes[0]
outletplane = vplanes[1] outletplane = vplanes[1]
@ -319,7 +382,7 @@ if __name__ == "__main__":
format="%(levelname)s: %(message)s", format="%(levelname)s: %(message)s",
handlers = [ handlers = [
logging.StreamHandler(), logging.StreamHandler(),
logging.FileHandler("{}/{}.log".format(buildpath, name)) logging.FileHandler(os.path.join(buildpath, "{}.log".format(name)))
]) ])
start_time = time.monotonic() start_time = time.monotonic()