diff --git a/src/Mod/Fem/femmesh/meshsetsgetter.py b/src/Mod/Fem/femmesh/meshsetsgetter.py index 7fdf241152..d37d69cd4b 100644 --- a/src/Mod/Fem/femmesh/meshsetsgetter.py +++ b/src/Mod/Fem/femmesh/meshsetsgetter.py @@ -423,51 +423,11 @@ class MeshSetsGetter: femobj["TieMasterFaces"] = result[-1:] def get_constraints_sectionprint_faces(self): - if not self.member.cons_sectionprint: - return - # TODO: use meshtools to get the surfaces - # see constraint contact or constraint tie for femobj in self.member.cons_sectionprint: - # femobj --> dict, FreeCAD document object is femobj["Object"] - sectionprint_obj = femobj["Object"] - if len(sectionprint_obj.References) > 1: - FreeCAD.Console.PrintError( - "Only one reference shape allowed for a section print " - "but {} found: {}\n".format( - len(sectionprint_obj.References), sectionprint_obj.References - ) - ) - for o, elem_tup in sectionprint_obj.References: - for elem in elem_tup: - # there should only be one reference for each section print object - # in the gui this is checked - ref_shape = o.Shape.getElement(elem) - if ref_shape.ShapeType == "Face": - v = self.mesh_object.FemMesh.getccxVolumesByFace(ref_shape) - if len(v) > 0: - femobj["SectionPrintFaces"] = v - # volume elements found - FreeCAD.Console.PrintLog( - "{}, surface {}, {} touching volume elements found\n".format( - sectionprint_obj.Label, sectionprint_obj.Name, len(v) - ) - ) - else: - # no volume elements found, shell elements not allowed - FreeCAD.Console.PrintError( - "{}, surface {}, Error: " - "No volume elements found!\n".format( - sectionprint_obj.Label, sectionprint_obj.Name - ) - ) - else: - # in Gui only Faces can be added - FreeCAD.Console.PrintError( - "Wrong reference shape type for {} " - "Only Faces are allowed, but a {} was found.\n".format( - sectionprint_obj.Name, ref_shape.ShapeType - ) - ) + obj = femobj["Object"] + result = self._get_ccx_elements(obj) + + femobj["SectionPrintFaces"] = result def get_constraints_heatflux_faces(self): for femobj in self.member.cons_heatflux: diff --git a/src/Mod/Fem/femobjects/constraint_sectionprint.py b/src/Mod/Fem/femobjects/constraint_sectionprint.py index df83751c3d..5a7a8d0218 100644 --- a/src/Mod/Fem/femobjects/constraint_sectionprint.py +++ b/src/Mod/Fem/femobjects/constraint_sectionprint.py @@ -57,7 +57,7 @@ class ConstraintSectionPrint(base_fempythonobject.BaseFemPythonObject): name="Variable", group="Constraint Section Print", doc="Set facial variable", - value=["Section Force", "Heat Flux", "Drag Stress"], + value=["Section Force", "Heat Flux", "Drag Stress", "Electric Flux"], ) ) diff --git a/src/Mod/Fem/femsolver/calculix/write_constraint_sectionprint.py b/src/Mod/Fem/femsolver/calculix/write_constraint_sectionprint.py index 029f462f78..c000a97962 100644 --- a/src/Mod/Fem/femsolver/calculix/write_constraint_sectionprint.py +++ b/src/Mod/Fem/femsolver/calculix/write_constraint_sectionprint.py @@ -56,8 +56,14 @@ def get_after_write_constraint(): def write_meshdata_constraint(f, femobj, sectionprint_obj, ccxwriter): f.write(f"*SURFACE, NAME=SECTIONFACE{sectionprint_obj.Name}\n") - for i in femobj["SectionPrintFaces"]: - f.write(f"{i[0]},S{i[1]}\n") + + for refs, surf, is_sub_el in femobj["SectionPrintFaces"]: + if is_sub_el: + for elem, fno in surf: + f.write(f"{elem},S{fno}\n") + else: + for elem in surf: + f.write(f"{elem},S2\n") def write_constraint(f, femobj, sectionprint_obj, ccxwriter): @@ -71,6 +77,8 @@ def write_constraint(f, femobj, sectionprint_obj, ccxwriter): key = "FLUX" elif variable == "Drag Stress": key = "DRAG" + elif variable == "Electric Flux": + key = "FLUX" f.write( "*SECTION PRINT, SURFACE=SECTIONFACE{}, NAME=SECTIONPRINT{}\n".format( diff --git a/src/Mod/Fem/femtaskpanels/task_constraint_sectionprint.py b/src/Mod/Fem/femtaskpanels/task_constraint_sectionprint.py index 414b1236e8..2cf0e4504b 100644 --- a/src/Mod/Fem/femtaskpanels/task_constraint_sectionprint.py +++ b/src/Mod/Fem/femtaskpanels/task_constraint_sectionprint.py @@ -63,7 +63,7 @@ class _TaskPanel(base_femtaskpanel._BaseTaskPanel): # geometry selection widget self.selectionWidget = selection_widgets.GeometryElementsSelection( - obj.References, ["Face"], False, False + obj.References, ["Edge", "Face"], False, False ) # form made from param and selection widget