Skip to content

Commit

Permalink
FEM: import tools, move calculate abs disp from import vtk to import …
Browse files Browse the repository at this point in the history
…tools
  • Loading branch information
berndhahnebach authored and wwmayer committed Mar 18, 2017
1 parent 2134e81 commit 9568fa4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 19 deletions.
20 changes: 11 additions & 9 deletions src/Mod/Fem/importToolsFem.py
Expand Up @@ -145,13 +145,8 @@ def fill_femresult_mechanical(results, result_set, span):
scale = 1.0

results.DisplacementVectors = list(map((lambda x: x * scale), disp.values()))

results.NodeNumbers = disp.keys()

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
results.DisplacementLengths = calculate_disp_abs(displacement)

if 'stressv' in result_set:
stressv = result_set['stressv']
Expand Down Expand Up @@ -248,9 +243,9 @@ def fill_femresult_mechanical(results, result_set, span):
x_min, y_min, z_min = map(min, zip(*displacement))
sum_list = map(sum, zip(*displacement))
x_avg, y_avg, z_avg = [i / no_of_values for i in sum_list]
a_max = max(disp_abs)
a_min = min(disp_abs)
a_avg = sum(disp_abs) / no_of_values
a_max = max(results.DisplacementLengths)
a_min = min(results.DisplacementLengths)
a_avg = sum(results.DisplacementLengths) / no_of_values
if results.StressValues:
s_max = max(results.StressValues)
s_min = min(results.StressValues)
Expand Down Expand Up @@ -317,3 +312,10 @@ def calculate_principal_stress(i):
eigvals.reverse()
maxshear = (eigvals[0] - eigvals[2]) / 2.0
return (eigvals[0], eigvals[1], eigvals[2], maxshear)


def calculate_disp_abs(displacements):
disp_abs = []
for d in displacements:
disp_abs.append(sqrt(pow(d[0], 2) + pow(d[1], 2) + pow(d[2], 2)))
return disp_abs
12 changes: 2 additions & 10 deletions src/Mod/Fem/importVTKResults.py
Expand Up @@ -92,7 +92,8 @@ def importVTK(filename, analysis=None, result_name_prefix=None):

# workaround for the DisplacementLengths (They should have been calculated by Fem.readResult)
if not result_obj.DisplacementLengths:
result_obj.DisplacementLengths = calculate_disp_abs(result_obj.DisplacementVectors)
import importToolsFem
result_obj.DisplacementLengths = importToolsFem.calculate_disp_abs(result_obj.DisplacementVectors)

analysis_object.Member = analysis_object.Member + [result_obj]
# FIXME move the ResultMesh in the analysis
Expand All @@ -106,12 +107,3 @@ def importVTK(filename, analysis=None, result_name_prefix=None):
time_step = 0.0
# Stats has been setup in C++ function FemVTKTools importCfdResult()
'''


# helper
def calculate_disp_abs(displacements):
from math import sqrt
disp_abs = []
for d in displacements:
disp_abs.append(sqrt(pow(d[0], 2) + pow(d[1], 2) + pow(d[2], 2)))
return disp_abs

0 comments on commit 9568fa4

Please sign in to comment.