From cc3e03ab27c5f129317638c031527af1cbbf038b Mon Sep 17 00:00:00 2001 From: L-Nafaryus Date: Thu, 1 Apr 2021 15:48:20 +0500 Subject: [PATCH] Fix: fillet --- run.py | 21 +++++++++++++-------- samples/__init__.py | 9 +++++---- samples/bodyCenteredCubic.py | 23 ++++++++++++++++++++--- samples/faceCenteredCubic.py | 22 +++++++++++++++++++--- samples/simpleCubic.py | 18 +++++++++++++++--- src/geometry_utils.py | 5 +++-- 6 files changed, 75 insertions(+), 23 deletions(-) diff --git a/run.py b/run.py index 2dfd25d..7c4edad 100644 --- a/run.py +++ b/run.py @@ -23,9 +23,9 @@ def createTasks(): "faceCenteredCubic" ] directions = [ - [1, 0, 0], - [0, 0, 1], - #[1, 1, 1] + #[1, 0, 0], + #[0, 0, 1], + [1, 1, 1] ] Task = namedtuple("Task", ["structure", "coeff", "direction", "saveto"]) @@ -33,13 +33,13 @@ def createTasks(): for structure in structures: if structure == "simpleCubic": - theta = [c * 0.01 for c in range(1, 29 + 1)] + theta = [0.01, 0.29] #[c * 0.01 for c in range(1, 29 + 1)] elif structure == "faceCenteredCubic": - theta = [] + theta = [0.01, 0.13] #[c * 0.01 for c in range(1, 13 + 1)] elif structure == "bodyCenteredCubic": - theta = [] + theta = [0.01, 0.13, 0.14, 0.18] #[c * 0.01 for c in range(1, 18 + 1)] for coeff in theta: for direction in directions: @@ -60,10 +60,15 @@ def createMesh(tasks): port = 2810 for task in tasks: + logging.info("-" * 80) + logging.info("""createMesh: + task:\t{} / {}""".format(tasks.index(task) + 1, len(tasks))) + 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")) - logging.info("Return code: {}".format(returncode)) - + logging.info("Return code:\t{}".format(returncode)) + logging.info("-" * 80) + if returncode == 1: break diff --git a/samples/__init__.py b/samples/__init__.py index 498476b..3c6b79a 100644 --- a/samples/__init__.py +++ b/samples/__init__.py @@ -2,6 +2,7 @@ from collections import namedtuple import os, sys import logging from pyquaternion import Quaternion +import math ROOT = "/home/nafaryus/projects/anisotrope-cube" sys.path.append(ROOT) @@ -97,8 +98,8 @@ if __name__ == "__main__": logging.FileHandler("{}/cubic.log".format(LOG)) ]) - fancyline = "--------------------------------------------------------------------------------" - logging.info(fancyline) + #fancyline = "--------------------------------------------------------------------------------" + #logging.info(fancyline) stype = str(sys.argv[1]) theta = float(sys.argv[2]) @@ -112,7 +113,7 @@ if __name__ == "__main__": saveto = str(sys.argv[4]) - logging.info("""Args: + logging.info("""genMesh: structure type:\t{} coefficient:\t{} flow direction:\t{} @@ -122,4 +123,4 @@ if __name__ == "__main__": genMesh(stype, theta, flowdirection, saveto) - logging.info(fancyline) + #logging.info(fancyline) diff --git a/samples/bodyCenteredCubic.py b/samples/bodyCenteredCubic.py index 61041b5..4daa068 100644 --- a/samples/bodyCenteredCubic.py +++ b/samples/bodyCenteredCubic.py @@ -159,8 +159,25 @@ def bodyCenteredCubic(alpha): Cf = C1 + (C2 - C1) / (alpha2 - alpha1) * (alpha - alpha1) R_fillet = Cf * (r0 * math.sqrt(2) - R) - grains = geompy.MakeFilletAll(grains, R_fillet) - geometry1 = geompy.MakeCutList(Pore_1a, [grains], True) - geometry2 = geompy.MakeCutList(Pore_3c, [grains], True) + #grains = geompy.MakeFilletAll(grains, R_fillet) + #geometry1 = geompy.MakeCutList(Pore_1a, [grains], True) + #geometry2 = geompy.MakeCutList(Pore_3c, [grains], True) + + # Scaling up + scale = 100 + grains = geompy.MakeScaleTransform(grains, O, scale) + geometry1 = geompy.MakeScaleTransform(Pore_1a, O, scale) + geometry2 = geompy.MakeScaleTransform(Pore_3c, O, scale) + + # + grains = geompy.MakeFilletAll(grains, R_fillet * scale) + geometry1 = geompy.MakeCutList(geometry1, [grains], True) + geometry2 = geompy.MakeCutList(geometry2, [grains], True) + + # Scaling down + grains = geompy.MakeScaleTransform(grains, O, 1 / scale) + geometry1 = geompy.MakeScaleTransform(geometry1, O, 1 / scale) + geometry2 = geompy.MakeScaleTransform(geometry2, O, 1 / scale) + return grains, Pore_1a, Pore_3c diff --git a/samples/faceCenteredCubic.py b/samples/faceCenteredCubic.py index 808e64a..4f183c7 100644 --- a/samples/faceCenteredCubic.py +++ b/samples/faceCenteredCubic.py @@ -154,8 +154,24 @@ def faceCenteredCubic(alpha): Cf = C1 + (C2 - C1) / (alpha2 - alpha1) * (alpha - alpha1) R_fillet = Cf * (r0 * math.sqrt(2) - R) - grains = geompy.MakeFilletAll(grains, R_fillet) - geometry1 = geompy.MakeCutList(Common, [grains], True) - geometry2 = geompy.MakeCutList(Cut_8, [grains], True) + #grains = geompy.MakeFilletAll(grains, R_fillet) + #geometry1 = geompy.MakeCutList(Common, [grains], True) + #geometry2 = geompy.MakeCutList(Cut_8, [grains], True) + + # Scaling up + scale = 100 + grains = geompy.MakeScaleTransform(grains, O, scale) + geometry1 = geompy.MakeScaleTransform(Common, O, scale) + geometry2 = geompy.MakeScaleTransform(Cut_8, O, scale) + + # + grains = geompy.MakeFilletAll(grains, R_fillet * scale) + geometry1 = geompy.MakeCutList(geometry1, [grains], True) + geometry2 = geompy.MakeCutList(geometry2, [grains], True) + + # Scaling down + grains = geompy.MakeScaleTransform(grains, O, 1 / scale) + geometry1 = geompy.MakeScaleTransform(geometry1, O, 1 / scale) + geometry2 = geompy.MakeScaleTransform(geometry2, O, 1 / scale) return grains, geometry1, geometry2 diff --git a/samples/simpleCubic.py b/samples/simpleCubic.py index da0f755..eb106fa 100644 --- a/samples/simpleCubic.py +++ b/samples/simpleCubic.py @@ -123,8 +123,20 @@ def simpleCubic(alpha): Cf = C1 + (C2 - C1) / (alpha2 - alpha1) * (alpha - alpha1) R_fillet = Cf * (r0 * math.sqrt(2) - R) - grains = geompy.MakeFilletAll(grains, R_fillet) - geometry1 = geompy.MakeCutList(Cut_1, [grains], True) - geometry2 = geompy.MakeCutList(Cut_4, [grains], True) + # Scaling up + scale = 100 + grains = geompy.MakeScaleTransform(grains, O, scale) + geometry1 = geompy.MakeScaleTransform(Cut_1, O, scale) + geometry2 = geompy.MakeScaleTransform(Cut_4, O, scale) + + # + grains = geompy.MakeFilletAll(grains, R_fillet * scale) + geometry1 = geompy.MakeCutList(geometry1, [grains], True) + geometry2 = geompy.MakeCutList(geometry2, [grains], True) + + # Scaling down + grains = geompy.MakeScaleTransform(grains, O, 1 / scale) + geometry1 = geompy.MakeScaleTransform(geometry1, O, 1 / scale) + geometry2 = geompy.MakeScaleTransform(geometry2, O, 1 / scale) return grains, geometry1, geometry2 diff --git a/src/geometry_utils.py b/src/geometry_utils.py index b2c867f..a0ed5e7 100644 --- a/src/geometry_utils.py +++ b/src/geometry_utils.py @@ -89,7 +89,7 @@ def createBoundary(gobj, bcount, dvec, norm, grains): nvec = geompy.GetNormal(plane) fwang = round(geompy.GetAngle(nvec, flowvec), 0) - #print("fwang = ", fwang) + print("fwang = ", fwang) if fwang == 0: inletplanes.append(plane) @@ -99,7 +99,7 @@ def createBoundary(gobj, bcount, dvec, norm, grains): for n in range(len(symvec)): sang = round(geompy.GetAngle(nvec, symvec[n]), 0) - #print("sang = ", sang, "\n") + print("sang = ", sang) if sang == 0: if symetryplanes[n][0] == None: @@ -112,6 +112,7 @@ def createBoundary(gobj, bcount, dvec, norm, grains): symetryplanes[n][1] = [] symetryplanes[n][1].append(plane) + print("\n") logging.info("""createBoundary: planes:\t{}