本文整理汇总了Python中FemMeshTools类的典型用法代码示例。如果您正苦于以下问题:Python FemMeshTools类的具体用法?Python FemMeshTools怎么用?Python FemMeshTools使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FemMeshTools类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_group_data
def get_group_data(self):
self.group_elements = {}
# TODO solids, faces, edges and vertexes seam not work together in one group, some print or make them work together
# mesh groups and groups of analysis member
if not self.mesh_obj.MeshGroupList:
print (' No mesh group objects.')
else:
print (' Mesh group objects, we need to get the elements.')
for mg in self.mesh_obj.MeshGroupList:
new_group_elements = FemMeshTools.get_mesh_group_elements(mg, self.part_obj)
for ge in new_group_elements:
if ge not in self.group_elements:
self.group_elements[ge] = new_group_elements[ge]
else:
FreeCAD.Console.PrintError(" A group with this name exists already.\n")
if self.analysis:
print(' Group meshing.')
new_group_elements = FemMeshTools.get_analysis_group_elements(self.analysis, self.part_obj)
for ge in new_group_elements:
if ge not in self.group_elements:
self.group_elements[ge] = new_group_elements[ge]
else:
FreeCAD.Console.PrintError(" A group with this name exists already.\n")
else:
print(' No anlysis members for group meshing.')
print(' {}'.format(self.group_elements))
示例2: get_group_data
def get_group_data(self):
if self.analysis:
print(' Group meshing.')
import FemMeshTools
self.group_elements = FemMeshTools.get_analysis_group_elements(self.analysis, self.part_obj)
print(self.group_elements)
else:
print(' NO group meshing.')
self.ele_length_map = self.mesh_obj.CharacteristicLengthMap
self.ele_node_map = {}
if self.ele_length_map:
import FemMeshTools
print(self.ele_length_map)
self.ele_node_map = {}
for e in self.ele_length_map:
if not e.startswith('Solid'):
# Face, Edge, Vertex
ele_shape = self.part_obj.Shape.getElement(e)
else:
# Solid
ele_shape_index = int(e.lstrip('Solid')) - 1
ele_shape = self.part_obj.Shape.Solids[ele_shape_index]
ele_vertexes = FemMeshTools.get_vertexes_by_element(self.part_obj.Shape, ele_shape)
self.ele_node_map[e] = ele_vertexes
print(self.ele_node_map)
示例3: write_z88_elements_properties
def write_z88_elements_properties(self):
element_properties_file_path = self.file_name + 'elp.txt'
elements_data = []
if FemMeshTools.is_edge_femmesh(self.femmesh):
if len(self.beamsection_objects) == 1:
beam_obj = self.beamsection_objects[0]['Object']
width = beam_obj.Width.getValueAs('mm')
height = beam_obj.Height.getValueAs('mm')
area = str(width * height)
elements_data.append('1 ' + str(self.element_count) + ' ' + area + ' 0 0 0 0 0 0 ')
print("Be aware, only trusses are supported for edge meshes!")
else:
print("Multiple beamsections for Z88 not yet supported!")
elif FemMeshTools.is_face_femmesh(self.femmesh):
if len(self.shellthickness_objects) == 1:
thick_obj = self.shellthickness_objects[0]['Object']
thickness = str(thick_obj.Thickness.getValueAs('mm'))
elements_data.append('1 ' + str(self.element_count) + ' ' + thickness + ' 0 0 0 0 0 0 ')
else:
print("Multiple thicknesses for Z88 not yet supported!")
elif FemMeshTools.is_solid_femmesh(self.femmesh):
elements_data.append('1 ' + str(self.element_count) + ' 0 0 0 0 0 0 0')
else:
print("Error!")
f = open(element_properties_file_path, 'w')
f.write(str(len(elements_data)) + '\n')
for e in elements_data:
f.write(e)
f.write('\n')
f.close()
示例4: get_z88_element_type
def get_z88_element_type(femmesh, femelement_table=None):
import FemMeshTools
if not femmesh:
print("Error: No femmesh!")
if not femelement_table:
print("We need to get the femelement_table first!")
femelement_table = FemMeshTools.get_femelement_table(femmesh)
# in some cases lowest key in femelement_table is not [1]
for elem in sorted(femelement_table):
elem_length = len(femelement_table[elem])
print(elem_length)
break # break after the first elem
if FemMeshTools.is_solid_femmesh(femmesh):
if femmesh.TetraCount == femmesh.VolumeCount:
if elem_length == 4:
return 17
elif elem_length == 10:
return 16
else:
print('Tetra with neiter 4 nor 10 nodes')
elif femmesh.HexaCount == femmesh.VolumeCount:
if elem_length == 8:
return 1
elif elem_length == 20:
return 10
else:
print('Hexa with neither 8 nor 20 nodes')
return 0
else:
print('no tetra, no hexa or Mixed Volume Elements')
elif FemMeshTools.is_face_femmesh(femmesh):
if femmesh.TriangleCount == femmesh.FaceCount:
if elem_length == 3:
print('tria3mesh, not supported by z88')
return 0
elif elem_length == 6:
return 24
else:
print('Tria with neither 3 nor 6 nodes')
return 0
elif femmesh.QuadrangleCount == femmesh.FaceCount:
if elem_length == 4:
print('quad4mesh, not supported by z88')
return 0
elif elem_length == 8:
return 23
else:
print('Quad with neiter 4 nor 8 nodes')
return 0
else:
print('no tria, no quad')
return 0
elif FemMeshTools.is_edge_femmesh(femmesh):
print('Edge femmesh will be exported as 3D truss element nr 4')
return 4
else:
print('Neither, edge, face or solid femmesh')
return 0
return 0
示例5: get_group_data
def get_group_data(self):
if self.analysis:
print(' Group meshing.')
self.group_elements = FemMeshTools.get_analysis_group_elements(self.analysis, self.part_obj)
print(' {}'.format(self.group_elements))
else:
print(' NO group meshing.')
self.ele_length_map = {} # { 'ElementString' : element length }
self.ele_node_map = {} # { 'ElementString' : [element nodes] }
if not self.mesh_obj.MeshRegionList:
print (' No Mesh regions.')
else:
print (' Mesh regions, we need to get the elements.')
if self.part_obj.Shape.ShapeType == 'Compound':
# see http://forum.freecadweb.org/viewtopic.php?f=18&t=18780&start=40#p149467 and http://forum.freecadweb.org/viewtopic.php?f=18&t=18780&p=149520#p149520
err = "GMSH could return unexpected meshes for a boolean split tools Compound. It is strongly recommended to extract the shape to mesh from the Compound and use this one."
FreeCAD.Console.PrintError(err + "\n")
for mr_obj in self.mesh_obj.MeshRegionList:
# print(mr_obj.Name)
# print(mr_obj.CharacteristicLength)
# print(Units.Quantity(mr_obj.CharacteristicLength).Value)
if mr_obj.CharacteristicLength:
if mr_obj.References:
for sub in mr_obj.References:
# print(sub[0]) # Part the elements belongs to
# check if the shape of the mesh region is an element of the Part to mesh, if not try to find the element in the shape to mesh
search_ele_in_shape_to_mesh = False
if not self.part_obj.Shape.isSame(sub[0].Shape):
# print(" One element of the meshregion " + mr_obj.Name + " is not an element of the Part to mesh.")
# print(" But we gone try to find it in the Shape to mesh :-)")
search_ele_in_shape_to_mesh = True
for eles in sub[1]:
# print(eles) # element
if search_ele_in_shape_to_mesh:
# we gone try to find the element it in the Shape to mesh and use the found element as eles
ele_shape = FemMeshTools.get_element(sub[0], eles) # the method getElement(element) does not return Solid elements
found_element = FemMeshTools.find_element_in_shape(self.part_obj.Shape, ele_shape)
if found_element:
eles = found_element
else:
FreeCAD.Console.PrintError("One element of the meshregion " + mr_obj.Name + " could not be found in the Part to mesh. It will be ignored.\n")
# print(eles) # element
if eles not in self.ele_length_map:
self.ele_length_map[eles] = Units.Quantity(mr_obj.CharacteristicLength).Value
else:
FreeCAD.Console.PrintError("The element " + eles + " of the meshregion " + mr_obj.Name + " has been added to another mesh region.\n")
else:
FreeCAD.Console.PrintError("The meshregion: " + mr_obj.Name + " is not used to create the mesh because the reference list is empty.\n")
else:
FreeCAD.Console.PrintError("The meshregion: " + mr_obj.Name + " is not used to create the mesh because the CharacteristicLength is 0.0 mm.\n")
for elel in self.ele_length_map:
ele_shape = FemMeshTools.get_element(self.part_obj, elel) # the method getElement(element) does not return Solid elements
ele_vertexes = FemMeshTools.get_vertexes_by_element(self.part_obj.Shape, ele_shape)
self.ele_node_map[elel] = ele_vertexes
print(' {}'.format(self.ele_length_map))
print(' {}'.format(self.ele_node_map))
示例6: get_ccx_elsets_multiple_mat_solid
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)
for mat_data in self.material_objects:
mat_obj = mat_data['Object']
ccx_elset = {}
ccx_elset['ccx_elset'] = mat_data['FEMElements']
ccx_elset['ccx_elset_name'] = get_ccx_elset_solid_name(mat_obj.Name, None, mat_data['ShortName'])
ccx_elset['mat_obj_name'] = mat_obj.Name
ccx_elset['ccx_mat_name'] = mat_obj.Material['Name']
self.ccx_elsets.append(ccx_elset)
示例7: get_ccx_elsets_multiple_mat_single_shell
def get_ccx_elsets_multiple_mat_single_shell(self):
if not self.femelement_table:
self.femelement_table = FemMeshTools.get_femelement_table(self.femmesh)
shellth_obj = self.shellthickness_objects[0]['Object']
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 = {}
ccx_elset['shellthickness_obj'] = shellth_obj
ccx_elset['ccx_elset'] = mat_data['FEMElements']
ccx_elset['ccx_elset_name'] = get_ccx_elset_shell_name(mat_obj.Name, shellth_obj.Name, mat_data['ShortName'])
ccx_elset['mat_obj_name'] = mat_obj.Name
ccx_elset['ccx_mat_name'] = mat_obj.Material['Name']
self.ccx_elsets.append(ccx_elset)
示例8: get_ccx_elsets_multiple_mat_single_beam
def get_ccx_elsets_multiple_mat_single_beam(self):
if not self.femelement_table:
self.femelement_table = FemMeshTools.get_femelement_table(self.femmesh)
beamsec_obj = self.beamsection_objects[0]['Object']
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 = {}
ccx_elset['beamsection_obj'] = beamsec_obj
ccx_elset['ccx_elset'] = mat_data['FEMElements']
ccx_elset['ccx_elset_name'] = get_ccx_elset_beam_name(mat_obj.Name, beamsec_obj.Name, mat_data['ShortName'])
ccx_elset['mat_obj_name'] = mat_obj.Name
ccx_elset['ccx_mat_name'] = mat_obj.Material['Name']
self.ccx_elsets.append(ccx_elset)
示例9: write_constraints_transform
def write_constraints_transform(self, f):
f.write('\n***********************************************************\n')
f.write('** Transform Constaints\n')
f.write('** written by {} function\n'.format(sys._getframe().f_code.co_name))
for trans_object in self.transform_objects:
trans_obj = trans_object['Object']
if trans_obj.TransformType == "Rectangular":
f.write('*TRANSFORM, NSET=Rect' + trans_obj.Name + ', TYPE=R\n')
coords = FemMeshTools.get_rectangular_coords(trans_obj)
f.write(coords + '\n')
elif trans_obj.TransformType == "Cylindrical":
f.write('*TRANSFORM, NSET=Cylin' + trans_obj.Name + ', TYPE=C\n')
coords = FemMeshTools.get_cylindrical_coords(trans_obj)
f.write(coords + '\n')
示例10: get_constraints_displacement_nodes
def get_constraints_displacement_nodes(self):
# get nodes
for femobj in self.displacement_objects: # femobj --> dict, FreeCAD document object is femobj['Object']
femobj['Nodes'] = FemMeshTools.get_femnodes_by_references(self.femmesh, femobj['Object'].References)
# add nodes to constraint_conflict_nodes, needed by constraint plane rotation
for node in femobj['Nodes']:
self.constraint_conflict_nodes.append(node)
示例11: get_ccx_elsets_multiple_mat_solid
def get_ccx_elsets_multiple_mat_solid(self):
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 = {}
ccx_elset['ccx_elset'] = mat_data['FEMElements']
ccx_elset['ccx_elset_name'] = get_ccx_elset_solid_name(mat_obj.Name, None, mat_data['ShortName'])
ccx_elset['mat_obj_name'] = mat_obj.Name
ccx_elset['ccx_mat_name'] = mat_obj.Material['Name']
self.ccx_elsets.append(ccx_elset)
示例12: import_inp
def import_inp(filename):
"create imported objects in FreeCAD, currently only FemMesh"
m = read_inp(filename)
mesh = FemMeshTools.make_femmesh(m)
mesh_name = os.path.splitext(os.path.basename(filename))[0]
mesh_object = FreeCAD.ActiveDocument.addObject('Fem::FemMeshObject', mesh_name)
mesh_object.FemMesh = mesh
示例13: import_z88_mesh
def import_z88_mesh(filename, analysis=None):
'''insert a FreeCAD FEM Mesh object in the ActiveDocument
'''
mesh_data = read_z88_mesh(filename)
mesh_name = os.path.basename(os.path.splitext(filename)[0])
femmesh = FemMeshTools.make_femmesh(mesh_data)
if femmesh:
mesh_object = FreeCAD.ActiveDocument.addObject('Fem::FemMeshObject', mesh_name)
mesh_object.FemMesh = femmesh
示例14: get_ccx_elsets_multiple_mat_multiple_beam
def get_ccx_elsets_multiple_mat_multiple_beam(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.beamsection_objects)
FemMeshTools.get_femelement_sets(self.femmesh, self.femelement_table, self.material_objects)
for beamsec_data in self.beamsection_objects:
beamsec_obj = beamsec_data['Object']
for mat_data in self.material_objects:
mat_obj = mat_data['Object']
ccx_elset = {}
ccx_elset['beamsection_obj'] = beamsec_obj
elemids = []
for elemid in beamsec_data['FEMElements']:
if elemid in mat_data['FEMElements']:
elemids.append(elemid)
ccx_elset['ccx_elset'] = elemids
ccx_elset['ccx_elset_name'] = get_ccx_elset_beam_name(mat_obj.Name, beamsec_obj.Name, mat_data['ShortName'], beamsec_data['ShortName'])
ccx_elset['mat_obj_name'] = mat_obj.Name
ccx_elset['ccx_mat_name'] = mat_obj.Material['Name']
self.ccx_elsets.append(ccx_elset)
示例15: get_constraints_pressure_faces
def get_constraints_pressure_faces(self):
# TODO see comments in get_constraints_force_nodeloads(), it applies here too. Mhh it applies to all constraints ...
'''
# depreciated version
# get the faces and face numbers
for femobj in self.pressure_objects: # femobj --> dict, FreeCAD document object is femobj['Object']
femobj['PressureFaces'] = FemMeshTools.get_pressure_obj_faces_depreciated(self.femmesh, femobj)
# print(femobj['PressureFaces'])
'''
if not self.femnodes_mesh:
self.femnodes_mesh = self.femmesh.Nodes
if not self.femelement_table:
self.femelement_table = FemMeshTools.get_femelement_table(self.femmesh)
if not self.femnodes_ele_table:
self.femnodes_ele_table = FemMeshTools.get_femnodes_ele_table(self.femnodes_mesh, self.femelement_table)
for femobj in self.pressure_objects: # femobj --> dict, FreeCAD document object is femobj['Object']
pressure_faces = FemMeshTools.get_pressure_obj_faces(self.femmesh, self.femelement_table, self.femnodes_ele_table, femobj)
# print(len(pressure_faces))
femobj['PressureFaces'] = [(femobj['Object'].Name + ': face load', pressure_faces)]