Skip to content

Commit

Permalink
FEM: constraint pressure, implement for shell meshes with group datea
Browse files Browse the repository at this point in the history
  • Loading branch information
berndhahnebach committed Apr 18, 2017
1 parent 067f94a commit 2e3d318
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/Mod/Fem/FemInputWriter.py
Expand Up @@ -175,6 +175,6 @@ def get_constraints_pressure_faces(self):
pressure_faces = FemMeshTools.get_pressure_obj_faces(self.femmesh, self.femelement_table, self.femnodes_ele_table, femobj) pressure_faces = FemMeshTools.get_pressure_obj_faces(self.femmesh, self.femelement_table, self.femnodes_ele_table, femobj)
# print(len(pressure_faces)) # print(len(pressure_faces))
femobj['PressureFaces'] = [(femobj['Object'].Name + ': face load', pressure_faces)] femobj['PressureFaces'] = [(femobj['Object'].Name + ': face load', pressure_faces)]
# print(femobj['PressureFaces']) print(femobj['PressureFaces'])


## @} ## @}
7 changes: 6 additions & 1 deletion src/Mod/Fem/FemInputWriterCcx.py
Expand Up @@ -897,7 +897,12 @@ def write_constraints_pressure(self, f):
for ref_shape in femobj['PressureFaces']: for ref_shape in femobj['PressureFaces']:
f.write('** ' + ref_shape[0] + '\n') f.write('** ' + ref_shape[0] + '\n')
for face, fno in ref_shape[1]: for face, fno in ref_shape[1]:
f.write("{},P{},{}\n".format(face, fno, rev * prs_obj.Pressure)) if fno > 0: # solid mesh face
f.write("{},P{},{}\n".format(face, fno, rev * prs_obj.Pressure))
elif fno == 0: # on shell mesh face: fno == 0 --> normal of element face == face normal
f.write("{},P,{}\n".format(face, rev * prs_obj.Pressure))
elif fno == -1: # on shell mesh face: fno == -1 --> normal of element face oposite direction face normal
f.write("{},P,{}\n".format(face, -1 * rev * prs_obj.Pressure))


def write_constraints_temperature(self, f): def write_constraints_temperature(self, f):
f.write('\n***********************************************************\n') f.write('\n***********************************************************\n')
Expand Down
41 changes: 35 additions & 6 deletions src/Mod/Fem/FemMeshTools.py
Expand Up @@ -373,6 +373,20 @@ def get_femnode_set_from_group_data(femmesh, fem_object):
return group_nodes return group_nodes




def get_femelementface_sets_from_group_data(femmesh, fem_object):
# get femfaceelements from femmesh face groupdata for reference shapes of obj.References
obj = fem_object['Object']
group_faces = None
if femmesh.GroupCount:
for g in femmesh.Groups:
grp_name = femmesh.getGroupName(g)
if grp_name.startswith(obj.Name + "_"):
if femmesh.getGroupElementType(g) == "Face":
print("Constraint: " + obj.Name + " --> " + "mesh group: " + grp_name)
group_faces = femmesh.getGroupElements(g) # == ref_shape_femelements
return group_faces


def get_femelement_sets_from_group_data(femmesh, fem_objects): def get_femelement_sets_from_group_data(femmesh, fem_objects):
# get femelements from femmesh groupdata for reference shapes of each obj.References # get femelements from femmesh groupdata for reference shapes of each obj.References
count_femelements = 0 count_femelements = 0
Expand Down Expand Up @@ -537,12 +551,27 @@ def get_pressure_obj_faces_depreciated(femmesh, femobj):




def get_pressure_obj_faces(femmesh, femelement_table, femnodes_ele_table, femobj): def get_pressure_obj_faces(femmesh, femelement_table, femnodes_ele_table, femobj):
# get the nodes if is_solid_femmesh(femmesh):
prs_face_node_set = get_femnodes_by_femobj_with_references(femmesh, femobj) # sorted and duplicates removed # get the nodes
# print('prs_face_node_set: ', prs_face_node_set) prs_face_node_set = get_femnodes_by_femobj_with_references(femmesh, femobj) # sorted and duplicates removed
# fill the bit_pattern_dict and search for the faces # print('prs_face_node_set: ', prs_face_node_set)
bit_pattern_dict = get_bit_pattern_dict(femelement_table, femnodes_ele_table, prs_face_node_set) # fill the bit_pattern_dict and search for the faces
pressure_faces = get_ccxelement_faces_from_binary_search(bit_pattern_dict) bit_pattern_dict = get_bit_pattern_dict(femelement_table, femnodes_ele_table, prs_face_node_set)
pressure_faces = get_ccxelement_faces_from_binary_search(bit_pattern_dict)
elif is_face_femmesh(femmesh):
pressure_faces = []
# normaly we should call get_femelements_by_references and the group check should be integrated there
if femmesh.GroupCount:
meshfaces = get_femelementface_sets_from_group_data(femmesh, femobj)
# print(meshfaces)
for mf in meshfaces:
# pressure_faces.append([mf, 0])
pressure_faces.append([mf, -1])
# 0 if femmeshface normal == reference face normal direction
# -1 if femmeshface normal opposite reference face normal direction
# easy on plane faces, but on a half sphere ... ?!?
else:
print("Pressure on shell mesh at the moment only supported for meshes with appropriate group data.")
return pressure_faces return pressure_faces




Expand Down

0 comments on commit 2e3d318

Please sign in to comment.