From 07b1a7cdb0770dd01957b00d5ceca0a65536355f Mon Sep 17 00:00:00 2001 From: Bernd Hahnebach Date: Mon, 12 Mar 2018 15:09:38 +0100 Subject: [PATCH] FEM: vtk result import, workaround for broken stats calculation --- src/Mod/Fem/feminout/importToolsFem.py | 9 +++++++-- src/Mod/Fem/feminout/importVTKResults.py | 12 ++++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/Mod/Fem/feminout/importToolsFem.py b/src/Mod/Fem/feminout/importToolsFem.py index c0b5aca3cf..7efe97ffd9 100644 --- a/src/Mod/Fem/feminout/importToolsFem.py +++ b/src/Mod/Fem/feminout/importToolsFem.py @@ -396,9 +396,14 @@ def fill_femresult_mechanical(results, result_set, span): temp_min, temp_avg, temp_max, mflow_min, mflow_avg, mflow_max, npress_min, npress_avg, npress_max] - # do not forget to adapt the def get_stats in FemResultTools module as well as the TestFem module # stat_types = ["U1", "U2", "U3", "Uabs", "Sabs", "MaxPrin", "MidPrin", "MinPrin", "MaxShear", "Peeq", "Temp", "MFlow", "NPress"] - # TODO: a dictionary would be far robust than a list, but needs adapten in VTK too because of VTK result import + # len(stat_types) == 13*3 == 39 + # do not forget to adapt the def get_stats in the following code: + # - module femresult/resulttools.py + # - module femtest/testccxtools.py + # - C++ App/FemVTKTools.cpp + # - module feminout/importVTKResults.py (workaround fix in importVtkFCResult for broken function in App/FemVTKTools.cpp) + # TODO: all stats stuff should be reimplemented, ma be a dictionary would be far more robust than a list return results diff --git a/src/Mod/Fem/feminout/importVTKResults.py b/src/Mod/Fem/feminout/importVTKResults.py index d0954b2651..2e525a773e 100644 --- a/src/Mod/Fem/feminout/importVTKResults.py +++ b/src/Mod/Fem/feminout/importVTKResults.py @@ -90,8 +90,11 @@ def importVTK(filename, analysis=None, result_name_prefix=None): from . import importToolsFem result_obj.DisplacementLengths = importToolsFem.calculate_disp_abs(result_obj.DisplacementVectors) - if analysis: - analysis_object.addObject(result_obj) + # workaround for wrong stats calculation fix in App/VTKtools.cpp + while len(result_obj.Stats) < 39: + tmpstats = result_obj.Stats + tmpstats.append(0.0) + result_obj.Stats = tmpstats ''' seems unused at the moment filenamebase = '.'.join(filename.split('.')[:-1]) # pattern: filebase_timestamp.vtk @@ -102,3 +105,8 @@ def importVTK(filename, analysis=None, result_name_prefix=None): time_step = 0.0 # Stats has been setup in C++ function FemVTKTools importCfdResult() ''' + + if analysis: + analysis_object.addObject(result_obj) + result_obj.touch() + FreeCAD.ActiveDocument.recompute()