FEM: calculix writer, use obj name as unique identifier for constraint section print

This commit is contained in:
Bernd Hahnebach
2021-07-06 12:13:23 +02:00
parent 809a4ff153
commit 3fcdef5ca0
2 changed files with 6 additions and 12 deletions

View File

@@ -636,25 +636,21 @@ class FemInputWriterCcx(writerbase.FemInputWriter):
# into get_constraints_sectionprint_faces method
def write_surfacefaces_constraints_sectionprint(self, f):
# get surface nodes and write them to file
obj = 0
for femobj in self.sectionprint_objects:
# femobj --> dict, FreeCAD document object is femobj["Object"]
sectionprint_obj = femobj["Object"]
f.write("** " + sectionprint_obj.Label + "\n")
obj = obj + 1
for o, elem_tup in sectionprint_obj.References:
for elem in elem_tup:
ref_shape = o.Shape.getElement(elem)
if ref_shape.ShapeType == "Face":
name = "SECTIONFACE" + str(obj)
f.write("*SURFACE, NAME=" + name + "\n")
f.write("*SURFACE, NAME=SECTIONFACE{}\n".format(sectionprint_obj.Name))
v = self.mesh_object.FemMesh.getccxVolumesByFace(ref_shape)
if len(v) > 0:
# volume elements found
FreeCAD.Console.PrintLog(
"{}, surface {}, {} touching volume elements found\n"
.format(sectionprint_obj.Label, name, len(v))
.format(sectionprint_obj.Label, sectionprint_obj.Name, len(v))
)
for i in v:
f.write("{},S{}\n".format(i[0], i[1]))
@@ -663,7 +659,7 @@ class FemInputWriterCcx(writerbase.FemInputWriter):
FreeCAD.Console.PrintError(
"{}, surface {}, Error: "
"No volume elements found!\n"
.format(sectionprint_obj.Label, name)
.format(sectionprint_obj.Label, sectionprint_obj.Name)
)
f.write("** Error: empty list\n")
@@ -676,15 +672,13 @@ class FemInputWriterCcx(writerbase.FemInputWriter):
f.write("\n***********************************************************\n")
f.write("** SectionPrint Constraints\n")
f.write("** written by {} function\n".format(sys._getframe().f_code.co_name))
obj = 0
for femobj in self.sectionprint_objects:
# femobj --> dict, FreeCAD document object is femobj["Object"]
obj = obj + 1
sectionprint_obj = femobj["Object"]
f.write("** {}\n".format(sectionprint_obj.Label))
f.write(
"*SECTION PRINT, SURFACE=SECTIONFACE{}, NAME=SECTIONPRINT{}\n"
.format(obj, obj)
.format(sectionprint_obj.Name, sectionprint_obj.Name)
)
f.write("SOF, SOM, SOAREA\n")

View File

@@ -3359,7 +3359,7 @@ Evolumes
** constraints sectionprint surface sets
** written by write_surfaces_constraints_sectionprint function
** ConstraintSectionPrint
*SURFACE, NAME=SECTIONFACE1
*SURFACE, NAME=SECTIONFACEConstraintSectionPrint
811,S4
872,S2
880,S1
@@ -3425,7 +3425,7 @@ ConstraintFixed,3
** SectionPrint Constraints
** written by write_constraints_sectionprint function
** ConstraintSectionPrint
*SECTION PRINT, SURFACE=SECTIONFACE1, NAME=SECTIONPRINT1
*SECTION PRINT, SURFACE=SECTIONFACEConstraintSectionPrint, NAME=SECTIONPRINTConstraintSectionPrint
SOF, SOM, SOAREA
***********************************************************