FEM: revert 5f8b459 and use a better fix fir frd reading of NaN floats
This commit is contained in:
committed by
Yorik van Havre
parent
a0f3a81139
commit
e2716b2f80
@@ -111,8 +111,7 @@ def importFrd(filename, analysis=None, result_name_prefix=None):
|
||||
error_message = (
|
||||
"We have nodes but no results in frd file, which means we only have a mesh in frd file. "
|
||||
"Usually this happens for analysis type 'NOANALYSIS' or if CalculiX returned no results because "
|
||||
"of nonpositive jacobian determinant in at least one element or if the time step in frd file = 0.0."
|
||||
"If the later an error message should have been printed.\n"
|
||||
"of nonpositive jacobian determinant in at least one element.\n"
|
||||
)
|
||||
FreeCAD.Console.PrintMessage(error_message)
|
||||
if analysis:
|
||||
@@ -158,6 +157,8 @@ def readResult(frd_input):
|
||||
elements_seg3 = {}
|
||||
results = []
|
||||
mode_results = {}
|
||||
mode_results['number'] = float('NaN')
|
||||
mode_results['time'] = float('NaN')
|
||||
mode_disp = {}
|
||||
mode_stress = {}
|
||||
mode_stressv = {}
|
||||
@@ -182,7 +183,6 @@ def readResult(frd_input):
|
||||
input_continues = False
|
||||
mode_eigen_changed = False
|
||||
mode_time_changed = False
|
||||
zero_mode_time = False # result will not be imported
|
||||
|
||||
eigenmode = 0
|
||||
eigentemp = 0
|
||||
@@ -401,10 +401,6 @@ def readResult(frd_input):
|
||||
# we found the new time step line
|
||||
# !!! be careful here, there is timetemp and timestep! TODO: use more differ names
|
||||
timetemp = float(line[13:25])
|
||||
if timetemp == 0:
|
||||
FreeCAD.Console.PrintError('Time step in frd file = 0.0, result will not be imported.\n')
|
||||
# https://forum.freecadweb.org/viewtopic.php?f=18&t=32649&start=10#p274686
|
||||
zero_mode_time = True
|
||||
if timetemp > timestep:
|
||||
timestep = timetemp
|
||||
mode_time_changed = True
|
||||
@@ -565,7 +561,7 @@ def readResult(frd_input):
|
||||
if line[1:5] == "9999":
|
||||
end_of_frd_data_found = True
|
||||
|
||||
if (not zero_mode_time) and (mode_eigen_changed or mode_time_changed or end_of_frd_data_found) and end_of_section_found and not node_element_section:
|
||||
if (mode_eigen_changed or mode_time_changed or end_of_frd_data_found) and end_of_section_found and not node_element_section:
|
||||
|
||||
'''
|
||||
print('\n\n----Append mode_results to results')
|
||||
@@ -581,6 +577,8 @@ def readResult(frd_input):
|
||||
# append mode_results to results and reset mode_result
|
||||
results.append(mode_results)
|
||||
mode_results = {}
|
||||
mode_results['number'] = float('NaN') # https://forum.freecadweb.org/viewtopic.php?f=18&t=32649&start=10#p274686
|
||||
mode_results['time'] = float('NaN')
|
||||
end_of_section_found = False
|
||||
|
||||
# on changed --> write changed values in mode_result --> will be the first to do on an empty mode_result
|
||||
|
||||
@@ -442,12 +442,16 @@ def calculate_principal_stress(i):
|
||||
sigma = np.array([[i[0], i[3], i[5]],
|
||||
[i[3], i[1], i[4]],
|
||||
[i[5], i[4], i[2]]]) # https://forum.freecadweb.org/viewtopic.php?f=18&t=24637&start=10#p240408
|
||||
# compute principal stresses
|
||||
eigvals = list(np.linalg.eigvalsh(sigma))
|
||||
eigvals.sort()
|
||||
eigvals.reverse()
|
||||
maxshear = (eigvals[0] - eigvals[2]) / 2.0
|
||||
return (eigvals[0], eigvals[1], eigvals[2], maxshear)
|
||||
|
||||
try: # it will fail if NaN is inside the array,
|
||||
# compute principal stresses
|
||||
eigvals = list(np.linalg.eigvalsh(sigma))
|
||||
eigvals.sort()
|
||||
eigvals.reverse()
|
||||
maxshear = (eigvals[0] - eigvals[2]) / 2.0
|
||||
return (eigvals[0], eigvals[1], eigvals[2], maxshear)
|
||||
except:
|
||||
return (float('NaN'), float('NaN'), float('NaN'), float('NaN'))
|
||||
|
||||
|
||||
def calculate_disp_abs(displacements):
|
||||
|
||||
Reference in New Issue
Block a user