Skip to content

Commit

Permalink
FEM: constraint transform, fix round by improving coordinate calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
berndhahnebach committed Jun 9, 2020
1 parent 7c7275c commit 86a6757
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 27 deletions.
27 changes: 20 additions & 7 deletions src/Mod/Fem/femsolver/calculix/writer.py
Expand Up @@ -658,19 +658,32 @@ def write_constraints_transform(self, f):
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
Expand Down
28 changes: 8 additions & 20 deletions src/Mod/Fem/femtools/geomtools.py
Expand Up @@ -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)


# ************************************************************************************************
Expand All @@ -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)

0 comments on commit 86a6757

Please sign in to comment.