Skip to content

Commit

Permalink
FEM: use group data for multi body material analysis, if available
Browse files Browse the repository at this point in the history
  • Loading branch information
berndhahnebach authored and yorikvanhavre committed Oct 4, 2016
1 parent 8a0b745 commit 56b1530
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/Mod/Fem/FemInputWriterCcx.py
Expand Up @@ -793,9 +793,14 @@ def get_ccx_elsets_multiple_mat_single_shell(self):
self.ccx_elsets.append(ccx_elset)

def get_ccx_elsets_multiple_mat_solid(self):
if not self.femelement_table:
self.femelement_table = FemMeshTools.get_femelement_table(self.femmesh)
FemMeshTools.get_femelement_sets(self.femmesh, self.femelement_table, self.material_objects)
all_found = False
if self.femmesh.GroupCount:
all_found = FemMeshTools.get_femelement_sets_from_group_data(self.femmesh, self.material_objects)
print(all_found)
if all_found is False:
if not self.femelement_table:
self.femelement_table = FemMeshTools.get_femelement_table(self.femmesh)
FemMeshTools.get_femelement_sets(self.femmesh, self.femelement_table, self.material_objects)
for mat_data in self.material_objects:
mat_obj = mat_data['Object']
ccx_elset = {}
Expand Down
29 changes: 29 additions & 0 deletions src/Mod/Fem/FemMeshTools.py
Expand Up @@ -195,6 +195,35 @@ def get_femelement_sets(femmesh, femelement_table, fem_objects): # fem_objects
FreeCAD.Console.PrintError('Error in get_femelement_sets -- > femelements_count_ok() failed!\n')


def get_femelement_sets_from_group_data(femmesh, fem_objects):
# get femelements from femmesh groupdata for reference shapes of each obj.References
print("")
count_femelements = 0
sum_group_elements = []
# we assume the mesh group data fits with the reference shapes, no check is done in this regard !!!
# what happens if a reference shape was changed, but the mesh and the mesh groups were not created new !?!
for fem_object_i, fem_object in enumerate(fem_objects):
obj = fem_object['Object']
fem_object['ShortName'] = get_elset_short_name(obj, fem_object_i) # unique short identifier
if femmesh.GroupCount:
for g in femmesh.Groups:
grp_name = femmesh.getGroupName(g)
if grp_name.startswith(obj.Name + '_'):
if femmesh.getGroupElementType(g) == "Volume":
print("Constraint: " + obj.Name + " --> " + "mesh group: " + grp_name)
group_elements = femmesh.getGroupElements(g) # == ref_shape_femelements
sum_group_elements += group_elements
count_femelements += len(group_elements)
fem_object['FEMElements'] = group_elements
# check if all worked out well
if not femelements_count_ok(femmesh.VolumeCount, count_femelements):
FreeCAD.Console.PrintError('Error in get_femelement_sets_from_group_data -- > femelements_count_ok() failed!\n')
return False
else:
return True
print("")


def get_elset_short_name(obj, i):
if hasattr(obj, "Proxy") and obj.Proxy.Type == 'MechanicalMaterial':
return 'Mat' + str(i)
Expand Down

0 comments on commit 56b1530

Please sign in to comment.