FEM: results, fix stats setting

This commit is contained in:
Bernd Hahnebach
2018-11-27 10:40:19 +01:00
committed by Yorik van Havre
parent a159df9fe5
commit 3ced344e20
3 changed files with 8 additions and 5 deletions

View File

@@ -104,7 +104,6 @@ def importFrd(filename, analysis=None, result_name_prefix=None):
results = ObjectsFem.makeResultMechanical(FreeCAD.ActiveDocument, results_name)
results.Mesh = result_mesh_object
results = importToolsFem.fill_femresult_mechanical(results, result_set, span)
results = importToolsFem.fill_femresult_stats(results)
if analysis:
analysis_object.addObject(results)
else:

View File

@@ -327,14 +327,19 @@ def fill_femresult_mechanical(results, result_set, span):
results.NetworkPressure = list(map((lambda x: x), NetworkPressure.values()))
results.Time = step_time
# fill the stats list
fill_femresult_stats(results)
return results
def fill_femresult_stats(results):
''' fills a FreeCAD FEM mechanical result object with stats data
'''
# result stats, set stats values to 0, they may not exist
fills a FreeCAD FEM mechanical result object with stats data
results: FreeCAD FEM result object
'''
FreeCAD.Console.PrintMessage('Calculate stats list for result obj: ' + results.Name + '\n')
no_of_values = 1 # to avoid division by zero
# set stats values to 0, they may not exist in result obj results
x_min = y_min = z_min = x_max = y_max = z_max = x_avg = y_avg = z_avg = 0
a_max = a_min = a_avg = s_max = s_min = s_avg = 0
p1_min = p1_avg = p1_max = p2_min = p2_avg = p2_max = p3_min = p3_avg = p3_max = 0
@@ -408,7 +413,7 @@ def fill_femresult_stats(results):
# - module femtest/testccxtools.py
# TODO: all stats stuff should be reimplemented, ma be a dictionary would be far more robust than a list
print('Recalculated Stats.\n')
FreeCAD.Console.PrintMessage('Stats list for result obj: ' + results.Name + ' calculated\n')
return results

View File

@@ -128,7 +128,6 @@ def importVtkFCResult(filename, resultname, analysis=None, result_name_prefix=No
results_name = result_name_prefix + 'results'
result_obj = ObjectsFem.makeResultMechanical(FreeCAD.ActiveDocument, results_name)
Fem.readResult(filename, result_obj.Name) # readResult always creates a new femmesh named ResultMesh
result_obj = importToolsFem.fill_femresult_stats(result_obj)
# workaround for the DisplacementLengths (They should have been calculated by Fem.readResult)
if not result_obj.DisplacementLengths: