本文整理汇总了Python中FemMeshTools.make_femmesh方法的典型用法代码示例。如果您正苦于以下问题:Python FemMeshTools.make_femmesh方法的具体用法?Python FemMeshTools.make_femmesh怎么用?Python FemMeshTools.make_femmesh使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FemMeshTools
的用法示例。
在下文中一共展示了FemMeshTools.make_femmesh方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: import_inp
# 需要导入模块: import FemMeshTools [as 别名]
# 或者: from FemMeshTools import make_femmesh [as 别名]
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
示例2: import_z88_mesh
# 需要导入模块: import FemMeshTools [as 别名]
# 或者: from FemMeshTools import make_femmesh [as 别名]
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
示例3: importFrd
# 需要导入模块: import FemMeshTools [as 别名]
# 或者: from FemMeshTools import make_femmesh [as 别名]
def importFrd(filename, analysis=None):
m = readResult(filename)
mesh_object = None
if(len(m['Nodes']) > 0):
if analysis is None:
analysis_name = os.path.splitext(os.path.basename(filename))[0]
import FemAnalysis
analysis_object = FemAnalysis.makeFemAnalysis('Analysis')
analysis_object.Label = analysis_name
else:
analysis_object = analysis # see if statement few lines later, if not analysis -> no FemMesh object is created !
if 'Nodes' in m:
positions = []
for k, v in m['Nodes'].iteritems():
positions.append(v)
p_x_max, p_y_max, p_z_max = map(max, zip(*positions))
p_x_min, p_y_min, p_z_min = map(min, zip(*positions))
x_span = abs(p_x_max - p_x_min)
y_span = abs(p_y_max - p_y_min)
z_span = abs(p_z_max - p_z_min)
span = max(x_span, y_span, z_span)
if (not analysis):
import FemMeshTools
mesh = FemMeshTools.make_femmesh(m)
if len(m['Nodes']) > 0:
mesh_object = FreeCAD.ActiveDocument.addObject('Fem::FemMeshObject', 'ResultMesh')
mesh_object.FemMesh = mesh
analysis_object.Member = analysis_object.Member + [mesh_object]
for result_set in m['Results']:
eigenmode_number = result_set['number']
if eigenmode_number > 0:
results_name = 'Mode_' + str(eigenmode_number) + '_results'
else:
results_name = 'Results'
results = FreeCAD.ActiveDocument.addObject('Fem::FemResultObject', results_name)
for m in analysis_object.Member:
if m.isDerivedFrom("Fem::FemMeshObject"):
results.Mesh = m
break
disp = result_set['disp']
l = len(disp)
displacement = []
for k, v in disp.iteritems():
displacement.append(v)
x_max, y_max, z_max = map(max, zip(*displacement))
if eigenmode_number > 0:
max_disp = max(x_max, y_max, z_max)
# Allow for max displacement to be 0.1% of the span
# FIXME - add to Preferences
max_allowed_disp = 0.001 * span
scale = max_allowed_disp / max_disp
else:
scale = 1.0
if len(disp) > 0:
results.DisplacementVectors = map((lambda x: x * scale), disp.values())
results.NodeNumbers = disp.keys()
if(mesh_object):
results.Mesh = mesh_object
stress = result_set['stress']
if len(stress) > 0:
mstress = []
for i in stress.values():
mstress.append(calculate_von_mises(i))
if eigenmode_number > 0:
results.StressValues = map((lambda x: x * scale), mstress)
results.Eigenmode = eigenmode_number
else:
results.StressValues = mstress
if (results.NodeNumbers != 0 and results.NodeNumbers != stress.keys()):
print("Inconsistent FEM results: element number for Stress doesn't equal element number for Displacement {} != {}"
.format(results.NodeNumbers, len(results.StressValues)))
results.NodeNumbers = stress.keys()
x_min, y_min, z_min = map(min, zip(*displacement))
sum_list = map(sum, zip(*displacement))
x_avg, y_avg, z_avg = [i / l for i in sum_list]
s_max = max(results.StressValues)
s_min = min(results.StressValues)
s_avg = sum(results.StressValues) / l
disp_abs = []
for d in displacement:
disp_abs.append(sqrt(pow(d[0], 2) + pow(d[1], 2) + pow(d[2], 2)))
results.DisplacementLengths = disp_abs
a_max = max(disp_abs)
a_min = min(disp_abs)
a_avg = sum(disp_abs) / l
#.........这里部分代码省略.........
示例4: importFrd
# 需要导入模块: import FemMeshTools [as 别名]
# 或者: from FemMeshTools import make_femmesh [as 别名]
def importFrd(filename, analysis=None, result_name_prefix=None):
if result_name_prefix is None:
result_name_prefix = ""
m = readResult(filename)
mesh_object = None
if len(m["Nodes"]) > 0:
if analysis is None:
analysis_name = os.path.splitext(os.path.basename(filename))[0]
import FemAnalysis
analysis_object = FemAnalysis.makeFemAnalysis("Analysis")
analysis_object.Label = analysis_name
else:
analysis_object = (
analysis
) # see if statement few lines later, if not analysis -> no FemMesh object is created !
if "Nodes" in m:
positions = []
for k, v in m["Nodes"].iteritems():
positions.append(v)
p_x_max, p_y_max, p_z_max = map(max, zip(*positions))
p_x_min, p_y_min, p_z_min = map(min, zip(*positions))
x_span = abs(p_x_max - p_x_min)
y_span = abs(p_y_max - p_y_min)
z_span = abs(p_z_max - p_z_min)
span = max(x_span, y_span, z_span)
if not analysis:
import FemMeshTools
mesh = FemMeshTools.make_femmesh(m)
if len(m["Nodes"]) > 0:
mesh_object = FreeCAD.ActiveDocument.addObject("Fem::FemMeshObject", "ResultMesh")
mesh_object.FemMesh = mesh
analysis_object.Member = analysis_object.Member + [mesh_object]
number_of_increments = len(m["Results"])
for result_set in m["Results"]:
eigenmode_number = result_set["number"]
step_time = result_set["time"]
step_time = round(step_time, 2)
if eigenmode_number > 0:
results_name = result_name_prefix + "mode_" + str(eigenmode_number) + "_results"
elif number_of_increments > 1:
results_name = result_name_prefix + "time_" + str(step_time) + "_results"
else:
results_name = result_name_prefix + "results"
results = FreeCAD.ActiveDocument.addObject("Fem::FemResultObject", results_name)
for m in analysis_object.Member:
if m.isDerivedFrom("Fem::FemMeshObject"):
results.Mesh = m
break
disp = result_set["disp"]
no_of_values = len(disp)
displacement = []
for k, v in disp.iteritems():
displacement.append(v)
x_max, y_max, z_max = map(max, zip(*displacement))
if eigenmode_number > 0:
max_disp = max(x_max, y_max, z_max)
# Allow for max displacement to be 0.1% of the span
# FIXME - add to Preferences
max_allowed_disp = 0.001 * span
scale = max_allowed_disp / max_disp
else:
scale = 1.0
if len(disp) > 0:
results.DisplacementVectors = map((lambda x: x * scale), disp.values())
results.NodeNumbers = disp.keys()
if mesh_object:
results.Mesh = mesh_object
# Read temperatures if they exist
try:
Temperature = result_set["temp"]
if len(Temperature) > 0:
if len(Temperature.values()) != len(disp.values()):
Temp = []
Temp_extra_nodes = Temperature.values()
nodes = len(disp.values())
for i in range(nodes):
Temp_value = Temp_extra_nodes[i]
Temp.append(Temp_value)
results.Temperature = map((lambda x: x), Temp)
else:
results.Temperature = map((lambda x: x), Temperature.values())
results.Time = step_time
except:
pass
stress = result_set["stress"]
if len(stress) > 0:
mstress = []
prinstress1 = []
#.........这里部分代码省略.........