FEM: constraint transform, fix round by improving coordinate calculation

This commit is contained in:
Bernd Hahnebach
2020-06-09 06:44:00 +02:00
parent c915347c90
commit 9a65d4db38
2 changed files with 28 additions and 27 deletions

View File

@@ -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

View File

@@ -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)