FEM: frd reader, move span calculation into fill result

This commit is contained in:
Bernd Hahnebach
2019-01-29 23:51:16 +01:00
committed by Yorik van Havre
parent 546cadebb8
commit 36c7d8740f
3 changed files with 15 additions and 12 deletions

View File

@@ -75,16 +75,6 @@ def importFrd(filename, analysis=None, result_name_prefix=None):
result_mesh_object = ObjectsFem.makeMeshResult(FreeCAD.ActiveDocument, 'Result_mesh')
result_mesh_object.FemMesh = mesh
positions = []
for k, v in m['Nodes'].items():
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)
number_of_increments = len(m['Results'])
FreeCAD.Console.PrintLog('Increments: ' + str(number_of_increments) + '\n')
if len(m['Results']) > 0:

View File

@@ -210,7 +210,7 @@ def make_femmesh(mesh_data):
return mesh
def fill_femresult_mechanical(results, result_set, span):
def fill_femresult_mechanical(results, result_set):
''' fills a FreeCAD FEM mechanical result object with result data
'''
if 'number' in result_set:
@@ -229,6 +229,7 @@ def fill_femresult_mechanical(results, result_set, span):
x_max, y_max, z_max = map(max, zip(*displacement))
if eigenmode_number > 0:
span = get_span(results.Mesh.FemMesh.Nodes.items())
max_disp = max(x_max, y_max, z_max)
# Allow for max displacement to be 0.1% of the span
# FIXME - add to Preferences
@@ -459,3 +460,15 @@ def calculate_disp_abs(displacements):
for d in displacements:
disp_abs.append(sqrt(pow(d[0], 2) + pow(d[1], 2) + pow(d[2], 2)))
return disp_abs
def get_span(node_items):
positions = [] # list of node vectors
for k, v in node_items:
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)
return span

View File

@@ -97,7 +97,7 @@ def import_z88_disp(filename, analysis=None, result_name_prefix=None):
res_obj = ObjectsFem.makeResultMechanical(FreeCAD.ActiveDocument, results_name)
res_obj.Mesh = result_mesh_object
res_obj = importToolsFem.fill_femresult_mechanical(res_obj, result_set, 0)
res_obj = importToolsFem.fill_femresult_mechanical(res_obj, result_set)
if analysis:
analysis_object.addObject(res_obj)