From 9a65d4db38875c68afb359890403219bb0eb32f0 Mon Sep 17 00:00:00 2001 From: Bernd Hahnebach Date: Tue, 9 Jun 2020 06:44:00 +0200 Subject: [PATCH] FEM: constraint transform, fix round by improving coordinate calculation --- src/Mod/Fem/femsolver/calculix/writer.py | 27 +++++++++++++++++------ src/Mod/Fem/femtools/geomtools.py | 28 +++++++----------------- 2 files changed, 28 insertions(+), 27 deletions(-) diff --git a/src/Mod/Fem/femsolver/calculix/writer.py b/src/Mod/Fem/femsolver/calculix/writer.py index 2bdbf260bc..abe4172f31 100644 --- a/src/Mod/Fem/femsolver/calculix/writer.py +++ b/src/Mod/Fem/femsolver/calculix/writer.py @@ -658,19 +658,32 @@ class FemInputWriterCcx(writerbase.FemInputWriter): f.write("\n***********************************************************\n") f.write("** Transform Constraints\n") f.write("** written by {} function\n".format(sys._getframe().f_code.co_name)) - # coords values rounded and converted to strings in the geom tools method - # TODO round and string conversation should happen here for trans_object in self.transform_objects: trans_obj = trans_object["Object"] - f.write("** " + trans_obj.Label + "\n") + trans_name = "" + trans_type = "" if trans_obj.TransformType == "Rectangular": - f.write("*TRANSFORM, NSET=Rect" + trans_obj.Name + ", TYPE=R\n") + trans_name = "Rect" + trans_type = "R" coords = geomtools.get_rectangular_coords(trans_obj) - f.write(coords + "\n") elif trans_obj.TransformType == "Cylindrical": - f.write("*TRANSFORM, NSET=Cylin" + trans_obj.Name + ", TYPE=C\n") + trans_name = "Cylin" + trans_type = "C" coords = geomtools.get_cylindrical_coords(trans_obj) - f.write(coords + "\n") + f.write("** {}\n".format(trans_obj.Label)) + f.write("*TRANSFORM, NSET={}{}, TYPE={}\n".format( + trans_name, + trans_obj.Name, + trans_type, + )) + f.write("{:f},{:f},{:f},{:f},{:f},{:f}\n".format( + coords[0], + coords[1], + coords[2], + coords[3], + coords[4], + coords[5], + )) # ******************************************************************************************** # constraints temperature diff --git a/src/Mod/Fem/femtools/geomtools.py b/src/Mod/Fem/femtools/geomtools.py index 0bb6a63b4d..4c42185476 100644 --- a/src/Mod/Fem/femtools/geomtools.py +++ b/src/Mod/Fem/femtools/geomtools.py @@ -220,13 +220,7 @@ def get_rectangular_coords( a_y = A[1] * cos(z_rot) - A[0] * sin(z_rot) b_x = B[0] * cos(z_rot) + B[1] * sin(z_rot) b_y = B[1] * cos(z_rot) - B[0] * sin(z_rot) - A = [a_x, a_y, a_z] - B = [b_x, b_y, b_z] - # TODO: round and string conversation should happen in the method which uses the return value - A_coords = str(round(A[0], 4)) + "," + str(round(A[1], 4)) + "," + str(round(A[2], 4)) - B_coords = str(round(B[0], 4)) + "," + str(round(B[1], 4)) + "," + str(round(B[2], 4)) - coords = A_coords + "," + B_coords - return coords + return (a_x, a_y, a_z, b_x, b_y, b_z) # ************************************************************************************************ @@ -235,16 +229,10 @@ def get_cylindrical_coords( ): vec = obj.Axis base = obj.BasePoint - Ax = base[0] + 10 * vec[0] - Ay = base[1] + 10 * vec[1] - Az = base[2] + 10 * vec[2] - Bx = base[0] - 10 * vec[0] - By = base[1] - 10 * vec[1] - Bz = base[2] - 10 * vec[2] - A = [Ax, Ay, Az] - B = [Bx, By, Bz] - # TODO: round and string conversation should happen in the method which uses the return value - A_coords = str(round(A[0])) + "," + str(round(A[1])) + "," + str(round(A[2])) - B_coords = str(round(B[0])) + "," + str(round(B[1])) + "," + str(round(B[2])) - coords = A_coords + "," + B_coords - return coords + a_x = base[0] + 10 * vec[0] + a_y = base[1] + 10 * vec[1] + a_z = base[2] + 10 * vec[2] + b_x = base[0] - 10 * vec[0] + b_y = base[1] - 10 * vec[1] + b_z = base[2] - 10 * vec[2] + return (a_x, a_y, a_z, b_x, b_y, b_z)