Skip to content

Commit

Permalink
FEM: ccx writer, improve new lines and comments
Browse files Browse the repository at this point in the history
  • Loading branch information
berndhahnebach committed Apr 22, 2020
1 parent 538cb9a commit 683e78c
Showing 1 changed file with 53 additions and 8 deletions.
61 changes: 53 additions & 8 deletions src/Mod/Fem/femsolver/calculix/writer.py
Expand Up @@ -421,9 +421,11 @@ def write_element_sets_material_and_femelement_type(self, f):
def write_node_sets_constraints_fixed(self, f):
if not self.fixed_objects:
return
# written in all analysis types
# write for all analysis types

# get nodes
self.get_constraints_fixed_nodes()

# write nodes to file
f.write("\n***********************************************************\n")
f.write("** Node sets for fixed constraint\n")
Expand All @@ -450,9 +452,11 @@ def write_node_sets_constraints_fixed(self, f):
def write_node_sets_constraints_displacement(self, f):
if not self.displacement_objects:
return
# written in all analysis types
# write for all analysis types

# get nodes
self.get_constraints_displacement_nodes()

# write nodes to file
f.write("\n***********************************************************\n")
f.write("** Node sets for prescribed displacement constraint\n")
Expand All @@ -468,9 +472,11 @@ def write_node_sets_constraints_displacement(self, f):
def write_node_sets_constraints_planerotation(self, f):
if not self.planerotation_objects:
return
# written in all analysis types
# write for all analysis types

# get nodes
self.get_constraints_planerotation_nodes()

# write nodes to file
if not self.femnodes_mesh:
self.femnodes_mesh = self.femmesh.Nodes
Expand Down Expand Up @@ -518,9 +524,11 @@ def write_node_sets_constraints_planerotation(self, f):
def write_surfaces_constraints_contact(self, f):
if not self.contact_objects:
return
# written in all analysis types
# write for all analysis types

# get faces
self.get_constraints_contact_faces()

# write faces to file
f.write("\n***********************************************************\n")
f.write("** Surfaces for contact constraint\n")
Expand All @@ -541,9 +549,11 @@ def write_surfaces_constraints_contact(self, f):
def write_surfaces_constraints_tie(self, f):
if not self.tie_objects:
return
# written in all analysis types
# write for all analysis types

# get faces
self.get_constraints_tie_faces()

# write faces to file
f.write("\n***********************************************************\n")
f.write("** Surfaces for tie constraint\n")
Expand All @@ -564,9 +574,11 @@ def write_surfaces_constraints_tie(self, f):
def write_node_sets_constraints_transform(self, f):
if not self.transform_objects:
return
# written in all analysis types
# write for all analysis types

# get nodes
self.get_constraints_transform_nodes()

# write nodes to file
f.write("\n***********************************************************\n")
f.write("** Node sets for transform constraint\n")
Expand All @@ -587,8 +599,10 @@ def write_node_sets_constraints_temperature(self, f):
return
if not self.analysis_type == "thermomech":
return
# get nodes

# get nodes
self.get_constraints_temperature_nodes()

# write nodes to file
f.write("\n***********************************************************\n")
f.write("** Node sets for temperature constraints\n")
Expand Down Expand Up @@ -698,7 +712,8 @@ def write_constraints_initialtemperature(self, f):
return
if not self.analysis_type == "thermomech":
return
# get nodes

# write constraint to file
f.write("\n***********************************************************\n")
f.write("** Initial temperature constraint\n")
f.write("** written by {} function\n".format(sys._getframe().f_code.co_name))
Expand Down Expand Up @@ -908,6 +923,9 @@ def write_step_begin(self, f):
def write_constraints_fixed(self, f):
if not self.fixed_objects:
return
# write for all analysis types

# write constraint to file
f.write("\n***********************************************************\n")
f.write("** Fixed Constraints\n")
f.write("** written by {} function\n".format(sys._getframe().f_code.co_name))
Expand Down Expand Up @@ -946,6 +964,9 @@ def write_constraints_fixed(self, f):
def write_constraints_displacement(self, f):
if not self.displacement_objects:
return
# write for all analysis types

# write constraint to file
f.write("\n***********************************************************\n")
f.write("** Displacement constraint applied\n")
f.write("** written by {} function\n".format(sys._getframe().f_code.co_name))
Expand Down Expand Up @@ -986,6 +1007,9 @@ def write_constraints_displacement(self, f):
def write_constraints_contact(self, f):
if not self.contact_objects:
return
# write for all analysis types

# write constraint to file
f.write("\n***********************************************************\n")
f.write("** Contact Constraints\n")
f.write("** written by {} function\n".format(sys._getframe().f_code.co_name))
Expand Down Expand Up @@ -1013,6 +1037,9 @@ def write_constraints_contact(self, f):
def write_constraints_tie(self, f):
if not self.tie_objects:
return
# write for all analysis types

# write constraint to file

This comment has been minimized.

Copy link
@vocx-fc

vocx-fc Apr 22, 2020

Contributor

@berndhahnebach Do you really need to add these comments? The method is called write, and the string literally has the text ...constraints written by {} function. And the function itself is called write_constraints_....

So it seems self-explanatory what is happening. Adding a comment to every line isn't going to make it more readable. The names of the variables and functions are much more important for that.

f.write("\n***********************************************************\n")
f.write("** Tie Constraints\n")
f.write("** written by {} function\n".format(sys._getframe().f_code.co_name))
Expand All @@ -1032,6 +1059,9 @@ def write_constraints_tie(self, f):
def write_constraints_planerotation(self, f):
if not self.planerotation_objects:
return
# write for all analysis types

# write constraint to file
f.write("\n***********************************************************\n")
f.write("** PlaneRotation Constraints\n")
f.write("** written by {} function\n".format(sys._getframe().f_code.co_name))
Expand All @@ -1045,6 +1075,9 @@ def write_constraints_planerotation(self, f):
def write_constraints_transform(self, f):
if not self.transform_objects:
return
# write for all analysis types

# write constraint to file
f.write("\n***********************************************************\n")
f.write("** Transform Constraints\n")
f.write("** written by {} function\n".format(sys._getframe().f_code.co_name))
Expand All @@ -1065,6 +1098,8 @@ def write_constraints_selfweight(self, f):
return
if not (self.analysis_type == "static" or self.analysis_type == "thermomech"):
return

# write constraint to file
f.write("\n***********************************************************\n")
f.write("** Self weight Constraint\n")
f.write("** written by {} function\n".format(sys._getframe().f_code.co_name))
Expand Down Expand Up @@ -1095,8 +1130,10 @@ def write_constraints_force(self, f):
return
if not (self.analysis_type == "static" or self.analysis_type == "thermomech"):
return

# check shape type of reference shape and get node loads
self.get_constraints_force_nodeloads()

# write node loads to file
f.write("\n***********************************************************\n")
f.write("** Node loads Constraints\n")
Expand Down Expand Up @@ -1127,8 +1164,10 @@ def write_constraints_pressure(self, f):
return
if not (self.analysis_type == "static" or self.analysis_type == "thermomech"):
return

# get the faces and face numbers
self.get_constraints_pressure_faces()

# write face loads to file
f.write("\n***********************************************************\n")
f.write("** Element + CalculiX face + load in [MPa]\n")
Expand Down Expand Up @@ -1161,6 +1200,8 @@ def write_constraints_temperature(self, f):
return
if not self.analysis_type == "thermomech":
return

# write constraint to file
f.write("\n***********************************************************\n")
f.write("** Fixed temperature constraint applied\n")
f.write("** written by {} function\n".format(sys._getframe().f_code.co_name))
Expand All @@ -1185,6 +1226,8 @@ def write_constraints_heatflux(self, f):
return
if not self.analysis_type == "thermomech":
return

# write constraint to file
f.write("\n***********************************************************\n")
f.write("** Heatflux constraints\n")
f.write("** written by {} function\n".format(sys._getframe().f_code.co_name))
Expand Down Expand Up @@ -1228,6 +1271,8 @@ def write_constraints_fluidsection(self, f):
return
if not self.analysis_type == "thermomech":
return

# write constraint to file
f.write("\n***********************************************************\n")
f.write("** FluidSection constraints\n")
f.write("** written by {} function\n".format(sys._getframe().f_code.co_name))
Expand Down

0 comments on commit 683e78c

Please sign in to comment.