New: fillet control
This commit is contained in:
parent
517145446b
commit
2df2cd0b8f
1
.gitignore
vendored
1
.gitignore
vendored
@ -13,3 +13,4 @@ logs/
|
|||||||
*.synctex.gz
|
*.synctex.gz
|
||||||
*.toc
|
*.toc
|
||||||
*.png
|
*.png
|
||||||
|
*.out
|
||||||
|
35
run.py
35
run.py
@ -23,23 +23,24 @@ def createTasks():
|
|||||||
"faceCenteredCubic"
|
"faceCenteredCubic"
|
||||||
]
|
]
|
||||||
directions = [
|
directions = [
|
||||||
#[1, 0, 0],
|
[1, 0, 0],
|
||||||
#[0, 0, 1],
|
[0, 0, 1],
|
||||||
[1, 1, 1]
|
[1, 1, 1]
|
||||||
]
|
]
|
||||||
|
fillet = 0
|
||||||
|
|
||||||
Task = namedtuple("Task", ["structure", "coeff", "direction", "saveto"])
|
Task = namedtuple("Task", ["structure", "coeff", "fillet", "direction", "saveto"])
|
||||||
tasks = []
|
tasks = []
|
||||||
|
|
||||||
for structure in structures:
|
for structure in structures:
|
||||||
if structure == "simpleCubic":
|
if structure == "simpleCubic":
|
||||||
theta = [] #[0.01, 0.28] #[c * 0.01 for c in range(1, 29 + 1)]
|
theta = [c * 0.01 for c in range(1, 28 + 1)]
|
||||||
|
|
||||||
elif structure == "faceCenteredCubic":
|
elif structure == "faceCenteredCubic":
|
||||||
theta = [0.01, 0.13] #[c * 0.01 for c in range(1, 13 + 1)]
|
theta = [c * 0.01 for c in range(1, 13 + 1)]
|
||||||
|
|
||||||
elif structure == "bodyCenteredCubic":
|
elif structure == "bodyCenteredCubic":
|
||||||
theta = [0.01, 0.13, 0.14, 0.18] #[c * 0.01 for c in range(1, 18 + 1)]
|
theta = [c * 0.01 for c in range(1, 18 + 1)]
|
||||||
|
|
||||||
for coeff in theta:
|
for coeff in theta:
|
||||||
for direction in directions:
|
for direction in directions:
|
||||||
@ -49,7 +50,7 @@ def createTasks():
|
|||||||
if not os.path.exists(saveto):
|
if not os.path.exists(saveto):
|
||||||
os.makedirs(saveto)
|
os.makedirs(saveto)
|
||||||
|
|
||||||
t = Task(structure, coeff, direction, saveto)
|
t = Task(structure, coeff, fillet, direction, saveto)
|
||||||
tasks.append(t)
|
tasks.append(t)
|
||||||
|
|
||||||
return tasks
|
return tasks
|
||||||
@ -58,19 +59,26 @@ def createTasks():
|
|||||||
def createMesh(tasks):
|
def createMesh(tasks):
|
||||||
scriptpath = os.path.join(ROOT, "samples/__init__.py")
|
scriptpath = os.path.join(ROOT, "samples/__init__.py")
|
||||||
port = 2810
|
port = 2810
|
||||||
|
errors = 0
|
||||||
|
|
||||||
for task in tasks:
|
for task in tasks:
|
||||||
logging.info("-" * 80)
|
logging.info("-" * 80)
|
||||||
logging.info("""createMesh:
|
logging.info("""createMesh:
|
||||||
task:\t{} / {}""".format(tasks.index(task) + 1, len(tasks)))
|
task:\t{} / {}""".format(tasks.index(task) + 1, len(tasks)))
|
||||||
|
start_time = time.monotonic()
|
||||||
|
|
||||||
returncode = salome_utils.runExecute(port, scriptpath, task.structure, task.coeff, "".join([str(coord) for coord in task.direction]), os.path.join(task.saveto, "mesh.unv"))
|
returncode = salome_utils.runExecute(port, scriptpath, task.structure, task.coeff, task.fillet, "".join([str(coord) for coord in task.direction]), os.path.join(task.saveto, "mesh.unv"))
|
||||||
|
|
||||||
logging.info("Return code:\t{}".format(returncode))
|
end_time = time.monotonic()
|
||||||
#logging.info("-" * 80)
|
logging.info("createMesh: elapsed time: {}".format(timedelta(seconds=end_time - start_time)))
|
||||||
|
logging.info("salome: return code:\t{}".format(returncode))
|
||||||
|
|
||||||
if returncode == 1:
|
if returncode == 1:
|
||||||
break
|
#break
|
||||||
|
errors += 1
|
||||||
|
pass
|
||||||
|
|
||||||
|
return errors
|
||||||
|
|
||||||
|
|
||||||
def calculate(tasks):
|
def calculate(tasks):
|
||||||
@ -181,11 +189,12 @@ if __name__ == "__main__":
|
|||||||
start_time = time.monotonic()
|
start_time = time.monotonic()
|
||||||
#logging.info("Started at {}".format(timedelta(seconds=start_time)))
|
#logging.info("Started at {}".format(timedelta(seconds=start_time)))
|
||||||
|
|
||||||
createMesh(tasks)
|
errors = createMesh(tasks)
|
||||||
|
|
||||||
end_time = time.monotonic()
|
end_time = time.monotonic()
|
||||||
logging.info("-" * 80)
|
logging.info("-" * 80)
|
||||||
logging.info("Elapsed time: {}".format(timedelta(seconds=end_time - start_time)))
|
logging.info("Elapsed time:\t{}".format(timedelta(seconds=end_time - start_time)))
|
||||||
|
logging.info("Errors:\t{}".format(errors))
|
||||||
|
|
||||||
if args.calc:
|
if args.calc:
|
||||||
start_time = time.monotonic()
|
start_time = time.monotonic()
|
||||||
|
@ -18,7 +18,7 @@ from bodyCenteredCubic import bodyCenteredCubic
|
|||||||
from src import geometry_utils
|
from src import geometry_utils
|
||||||
from src import mesh_utils
|
from src import mesh_utils
|
||||||
|
|
||||||
def genMesh(stype, theta, flowdirection, saveto):
|
def genMesh(stype, theta, fillet, flowdirection, saveto):
|
||||||
_G = globals()
|
_G = globals()
|
||||||
|
|
||||||
structure = _G.get(stype)
|
structure = _G.get(stype)
|
||||||
@ -26,9 +26,7 @@ def genMesh(stype, theta, flowdirection, saveto):
|
|||||||
if structure:
|
if structure:
|
||||||
salome.salome_init()
|
salome.salome_init()
|
||||||
|
|
||||||
#grains, cubic, rhombohedron = structure(theta)
|
grains, geometry1, geometry2 = structure(theta, fillet)
|
||||||
#fd = namedtuple("fd", ["x", "y", "z"])
|
|
||||||
grains, geometry1, geometry2 = structure(theta)
|
|
||||||
geometry = geometry1
|
geometry = geometry1
|
||||||
|
|
||||||
if flowdirection == [1, 1, 1]:
|
if flowdirection == [1, 1, 1]:
|
||||||
@ -38,35 +36,20 @@ def genMesh(stype, theta, flowdirection, saveto):
|
|||||||
|
|
||||||
# initial angle
|
# initial angle
|
||||||
angle = math.pi / 6
|
angle = math.pi / 6
|
||||||
#vec = Quaternion(0, norm[0], norm[1], norm[2])
|
|
||||||
#ax = Quaternion(
|
|
||||||
# math.cos(angle * 0.5),
|
|
||||||
# math.sin(angle * 0.5) * flowdirection[0],
|
|
||||||
# math.sin(angle * 0.5) * flowdirection[1],
|
|
||||||
# math.sin(angle * 0.5) * flowdirection[2])
|
|
||||||
#qvec = (ax * vec * ax.inverse).vector
|
|
||||||
#normvec = [qvec[0], qvec[1], qvec[2]]
|
|
||||||
v1 = Quaternion(axis = norm, angle = math.pi / 2).rotate(flowdirection)
|
v1 = Quaternion(axis = norm, angle = math.pi / 2).rotate(flowdirection)
|
||||||
normvec = Quaternion(axis = flowdirection, angle = angle).rotate(v1)
|
normvec = Quaternion(axis = flowdirection, angle = angle).rotate(v1)
|
||||||
direction = [1, 1, 1]
|
direction = [1, 1, 1]
|
||||||
#direction = fd([1, 1, 1], [1, -1, 1], [1, -1, -1])
|
|
||||||
|
|
||||||
#else:
|
|
||||||
# geometry = cubic
|
|
||||||
|
|
||||||
if flowdirection == [1, 0, 0]:
|
if flowdirection == [1, 0, 0]:
|
||||||
normvec = [0, 0, 1]
|
normvec = [0, 0, 1]
|
||||||
bcount = 4
|
bcount = 4
|
||||||
direction = [1, 1, 0]
|
direction = [1, 1, 0]
|
||||||
#direction = fd([1, 1, 0], [1, -1, 0], [0, 0, 1])
|
|
||||||
|
|
||||||
if flowdirection == [0, 0, 1]:
|
if flowdirection == [0, 0, 1]:
|
||||||
normvec = [1, 1, 0]
|
normvec = [1, 1, 0]
|
||||||
bcount = 4
|
bcount = 4
|
||||||
direction = [0, 0, 1]
|
direction = [0, 0, 1]
|
||||||
#direction = fd([0, 0, 1], [1, -1, 0], [1, 1, 0])
|
|
||||||
|
|
||||||
#boundary = geometry_utils.boundaryCreate(geometry, direction, grains)
|
|
||||||
boundary = geometry_utils.createBoundary(geometry, bcount, direction, normvec, grains)
|
boundary = geometry_utils.createBoundary(geometry, bcount, direction, normvec, grains)
|
||||||
|
|
||||||
fineness = 1
|
fineness = 1
|
||||||
@ -78,22 +61,14 @@ def genMesh(stype, theta, flowdirection, saveto):
|
|||||||
mesh = mesh_utils.meshCreate(geometry, boundary, fineness, viscousLayers)
|
mesh = mesh_utils.meshCreate(geometry, boundary, fineness, viscousLayers)
|
||||||
mesh_utils.meshCompute(mesh)
|
mesh_utils.meshCompute(mesh)
|
||||||
|
|
||||||
#path = os.path.join(saveto,
|
mesh_utils.meshExport(mesh, saveto)
|
||||||
# stype,
|
|
||||||
# "theta-%s" % theta,
|
|
||||||
# "direction-{}{}{}".format(flowdirection[0], flowdirection[1], flowdirection[2]))
|
|
||||||
|
|
||||||
#if not os.path.exists(path):
|
|
||||||
# logging.info("Creating directory: {}".format(path))
|
|
||||||
# os.makedirs(path)
|
|
||||||
|
|
||||||
mesh_utils.meshExport(mesh, saveto) # os.path.join(path, "mesh.unv"))
|
|
||||||
|
|
||||||
salome.salome_close()
|
salome.salome_close()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
raise Exception("Unknown sample function")
|
raise Exception("Unknown sample function")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
||||||
logging.basicConfig(
|
logging.basicConfig(
|
||||||
@ -104,29 +79,18 @@ if __name__ == "__main__":
|
|||||||
logging.FileHandler("{}/cubic.log".format(LOG))
|
logging.FileHandler("{}/cubic.log".format(LOG))
|
||||||
])
|
])
|
||||||
|
|
||||||
#fancyline = "--------------------------------------------------------------------------------"
|
|
||||||
#logging.info(fancyline)
|
|
||||||
|
|
||||||
stype = str(sys.argv[1])
|
stype = str(sys.argv[1])
|
||||||
theta = float(sys.argv[2])
|
theta = float(sys.argv[2])
|
||||||
|
fillet = True if int(sys.argv[3]) == 1 else False
|
||||||
#ignore = "[], "
|
flowdirection = [int(coord) for coord in sys.argv[4]]
|
||||||
flowdirection = [int(coord) for coord in sys.argv[3]]
|
saveto = str(sys.argv[5])
|
||||||
|
|
||||||
#for sym in str(sys.argv[3]):
|
|
||||||
# if sym not in list(ignore):
|
|
||||||
# flowdirection.append(int(sym))
|
|
||||||
|
|
||||||
saveto = str(sys.argv[4])
|
|
||||||
|
|
||||||
logging.info("""genMesh:
|
logging.info("""genMesh:
|
||||||
structure type:\t{}
|
structure type:\t{}
|
||||||
coefficient:\t{}
|
coefficient:\t{}
|
||||||
|
fillet:\t{}
|
||||||
flow direction:\t{}
|
flow direction:\t{}
|
||||||
export path:\t{}""".format(stype, theta, flowdirection, saveto))
|
export path:\t{}""".format(stype, theta, fillet, flowdirection, saveto))
|
||||||
|
|
||||||
#print(flowdirection)
|
genMesh(stype, theta, fillet, flowdirection, saveto)
|
||||||
|
|
||||||
genMesh(stype, theta, flowdirection, saveto)
|
|
||||||
|
|
||||||
#logging.info(fancyline)
|
|
||||||
|
@ -10,7 +10,7 @@ import SALOMEDS
|
|||||||
|
|
||||||
geompy = geomBuilder.New()
|
geompy = geomBuilder.New()
|
||||||
|
|
||||||
def bodyCenteredCubic(alpha):
|
def bodyCenteredCubic(alpha, fillet = False):
|
||||||
O = geompy.MakeVertex(0, 0, 0)
|
O = geompy.MakeVertex(0, 0, 0)
|
||||||
OX = geompy.MakeVectorDXDYDZ(1, 0, 0)
|
OX = geompy.MakeVectorDXDYDZ(1, 0, 0)
|
||||||
OY = geompy.MakeVectorDXDYDZ(0, 1, 0)
|
OY = geompy.MakeVectorDXDYDZ(0, 1, 0)
|
||||||
@ -149,7 +149,10 @@ def bodyCenteredCubic(alpha):
|
|||||||
grains = geompy.ExtractShapes(Up_Down, geompy.ShapeType["SOLID"], True)
|
grains = geompy.ExtractShapes(Up_Down, geompy.ShapeType["SOLID"], True)
|
||||||
grains += geompy.ExtractShapes(Middle, geompy.ShapeType["SOLID"], True)
|
grains += geompy.ExtractShapes(Middle, geompy.ShapeType["SOLID"], True)
|
||||||
grains = geompy.MakeFuseList(grains, False, False)
|
grains = geompy.MakeFuseList(grains, False, False)
|
||||||
|
geometry1 = Pore_1a
|
||||||
|
geometry2 = Pore_3c
|
||||||
|
|
||||||
|
if fillet:
|
||||||
R = r0 / (1 - alpha)
|
R = r0 / (1 - alpha)
|
||||||
C1 = 0.8
|
C1 = 0.8
|
||||||
C2 = 0.01
|
C2 = 0.01
|
||||||
@ -159,15 +162,11 @@ def bodyCenteredCubic(alpha):
|
|||||||
Cf = C1 + (C2 - C1) / (alpha2 - alpha1) * (alpha - alpha1)
|
Cf = C1 + (C2 - C1) / (alpha2 - alpha1) * (alpha - alpha1)
|
||||||
R_fillet = Cf * (R - r0)
|
R_fillet = Cf * (R - r0)
|
||||||
|
|
||||||
#grains = geompy.MakeFilletAll(grains, R_fillet)
|
|
||||||
#geometry1 = geompy.MakeCutList(Pore_1a, [grains], True)
|
|
||||||
#geometry2 = geompy.MakeCutList(Pore_3c, [grains], True)
|
|
||||||
|
|
||||||
# Scaling up
|
# Scaling up
|
||||||
scale = 100
|
scale = 100
|
||||||
grains = geompy.MakeScaleTransform(grains, O, scale)
|
grains = geompy.MakeScaleTransform(grains, O, scale)
|
||||||
geometry1 = geompy.MakeScaleTransform(Pore_1a, O, scale)
|
geometry1 = geompy.MakeScaleTransform(geometry1, O, scale)
|
||||||
geometry2 = geompy.MakeScaleTransform(Pore_3c, O, scale)
|
geometry2 = geompy.MakeScaleTransform(geometry2, O, scale)
|
||||||
|
|
||||||
#
|
#
|
||||||
grains = geompy.MakeFilletAll(grains, R_fillet * scale)
|
grains = geompy.MakeFilletAll(grains, R_fillet * scale)
|
||||||
@ -184,4 +183,4 @@ def bodyCenteredCubic(alpha):
|
|||||||
geompy.addToStudy(geometry1, "geometry1")
|
geompy.addToStudy(geometry1, "geometry1")
|
||||||
geompy.addToStudy(geometry2, "geometry2")
|
geompy.addToStudy(geometry2, "geometry2")
|
||||||
|
|
||||||
return grains, Pore_1a, Pore_3c
|
return grains, geometry1, geometry2
|
||||||
|
@ -10,7 +10,7 @@ import SALOMEDS
|
|||||||
|
|
||||||
geompy = geomBuilder.New()
|
geompy = geomBuilder.New()
|
||||||
|
|
||||||
def faceCenteredCubic(alpha):
|
def faceCenteredCubic(alpha, fillet = False):
|
||||||
O = geompy.MakeVertex(0, 0, 0)
|
O = geompy.MakeVertex(0, 0, 0)
|
||||||
OX = geompy.MakeVectorDXDYDZ(1, 0, 0)
|
OX = geompy.MakeVectorDXDYDZ(1, 0, 0)
|
||||||
OY = geompy.MakeVectorDXDYDZ(0, 1, 0)
|
OY = geompy.MakeVectorDXDYDZ(0, 1, 0)
|
||||||
@ -144,7 +144,10 @@ def faceCenteredCubic(alpha):
|
|||||||
grains = geompy.ExtractShapes(Up_Down, geompy.ShapeType["SOLID"], True)
|
grains = geompy.ExtractShapes(Up_Down, geompy.ShapeType["SOLID"], True)
|
||||||
grains += geompy.ExtractShapes(Middle_Up, geompy.ShapeType["SOLID"], True)
|
grains += geompy.ExtractShapes(Middle_Up, geompy.ShapeType["SOLID"], True)
|
||||||
grains = geompy.MakeFuseList(grains, False, False)
|
grains = geompy.MakeFuseList(grains, False, False)
|
||||||
|
geometry1 = Common
|
||||||
|
geometry2 = Cut_8
|
||||||
|
|
||||||
|
if fillet:
|
||||||
R = r0 / (1 - alpha)
|
R = r0 / (1 - alpha)
|
||||||
C1 = 0.8
|
C1 = 0.8
|
||||||
C2 = 0.01
|
C2 = 0.01
|
||||||
@ -153,16 +156,12 @@ def faceCenteredCubic(alpha):
|
|||||||
|
|
||||||
Cf = C1 + (C2 - C1) / (alpha2 - alpha1) * (alpha - alpha1)
|
Cf = C1 + (C2 - C1) / (alpha2 - alpha1) * (alpha - alpha1)
|
||||||
R_fillet = Cf * (R - r0)
|
R_fillet = Cf * (R - r0)
|
||||||
print(R_fillet)
|
|
||||||
#grains = geompy.MakeFilletAll(grains, R_fillet)
|
|
||||||
#geometry1 = geompy.MakeCutList(Common, [grains], True)
|
|
||||||
#geometry2 = geompy.MakeCutList(Cut_8, [grains], True)
|
|
||||||
|
|
||||||
# Scaling up
|
# Scaling up
|
||||||
scale = 100
|
scale = 100
|
||||||
grains = geompy.MakeScaleTransform(grains, O, scale)
|
grains = geompy.MakeScaleTransform(grains, O, scale)
|
||||||
geometry1 = geompy.MakeScaleTransform(Common, O, scale)
|
geometry1 = geompy.MakeScaleTransform(geometry1, O, scale)
|
||||||
geometry2 = geompy.MakeScaleTransform(Cut_8, O, scale)
|
geometry2 = geompy.MakeScaleTransform(geometry2, O, scale)
|
||||||
|
|
||||||
#
|
#
|
||||||
grains = geompy.MakeFilletAll(grains, R_fillet * scale)
|
grains = geompy.MakeFilletAll(grains, R_fillet * scale)
|
||||||
|
@ -10,7 +10,7 @@ import SALOMEDS
|
|||||||
|
|
||||||
geompy = geomBuilder.New()
|
geompy = geomBuilder.New()
|
||||||
|
|
||||||
def simpleCubic(alpha):
|
def simpleCubic(alpha, fillet = False):
|
||||||
O = geompy.MakeVertex(0, 0, 0)
|
O = geompy.MakeVertex(0, 0, 0)
|
||||||
OX = geompy.MakeVectorDXDYDZ(1, 0, 0)
|
OX = geompy.MakeVectorDXDYDZ(1, 0, 0)
|
||||||
OY = geompy.MakeVectorDXDYDZ(0, 1, 0)
|
OY = geompy.MakeVectorDXDYDZ(0, 1, 0)
|
||||||
@ -113,10 +113,13 @@ def simpleCubic(alpha):
|
|||||||
# Preparation
|
# Preparation
|
||||||
grains = geompy.ExtractShapes(Multi_Translation_3, geompy.ShapeType["SOLID"], True)
|
grains = geompy.ExtractShapes(Multi_Translation_3, geompy.ShapeType["SOLID"], True)
|
||||||
grains = geompy.MakeFuseList(grains, False, False)
|
grains = geompy.MakeFuseList(grains, False, False)
|
||||||
|
geometry1 = Cut_1
|
||||||
|
geometry2 = Cut_4
|
||||||
|
|
||||||
|
if fillet:
|
||||||
R = r0 / (1 - alpha)
|
R = r0 / (1 - alpha)
|
||||||
C1 = 0.8
|
C1 = 0.8
|
||||||
C2 = 0.4
|
C2 = 0.01
|
||||||
alpha1 = 0.01
|
alpha1 = 0.01
|
||||||
alpha2 = 0.28
|
alpha2 = 0.28
|
||||||
|
|
||||||
@ -126,8 +129,8 @@ def simpleCubic(alpha):
|
|||||||
# Scaling up
|
# Scaling up
|
||||||
scale = 100
|
scale = 100
|
||||||
grains = geompy.MakeScaleTransform(grains, O, scale)
|
grains = geompy.MakeScaleTransform(grains, O, scale)
|
||||||
geometry1 = geompy.MakeScaleTransform(Cut_1, O, scale)
|
geometry1 = geompy.MakeScaleTransform(geometry1, O, scale)
|
||||||
geometry2 = geompy.MakeScaleTransform(Cut_4, O, scale)
|
geometry2 = geompy.MakeScaleTransform(geometry2, O, scale)
|
||||||
|
|
||||||
#
|
#
|
||||||
grains = geompy.MakeFilletAll(grains, R_fillet * scale)
|
grains = geompy.MakeFilletAll(grains, R_fillet * scale)
|
||||||
|
Loading…
Reference in New Issue
Block a user