FEM: coverity, Null pointer dereferences
This commit is contained in:
@@ -90,11 +90,13 @@ def run_example(example, solver=None, base_name=None):
|
||||
|
||||
from importlib import import_module
|
||||
module = import_module("femexamples." + example)
|
||||
if hasattr(module, "setup"):
|
||||
if solver is None:
|
||||
doc = getattr(module, "setup")()
|
||||
else:
|
||||
doc = getattr(module, "setup")(solvertype=solver)
|
||||
if not hasattr(module, "setup"):
|
||||
FreeCAD.Console.PrintError("Setup method not found in {}\n".format(example))
|
||||
|
||||
if solver is None:
|
||||
doc = getattr(module, "setup")()
|
||||
else:
|
||||
doc = getattr(module, "setup")(solvertype=solver)
|
||||
|
||||
if base_name is None:
|
||||
base_name = example
|
||||
|
||||
@@ -135,6 +135,7 @@ def read_inp(file_name):
|
||||
continue
|
||||
read_node = False
|
||||
elm_category = []
|
||||
number_of_nodes = 0
|
||||
elm_2nd_line = False
|
||||
|
||||
# reading nodes
|
||||
@@ -194,8 +195,10 @@ def read_inp(file_name):
|
||||
elm_category = elements.seg3
|
||||
number_of_nodes = 3
|
||||
error_seg3 = True # to print "not supported"
|
||||
else:
|
||||
error_not_supported_elemtype = True
|
||||
|
||||
elif elm_category != []:
|
||||
elif elm_category != [] and number_of_nodes > 0:
|
||||
line_list = line.split(",")
|
||||
if elm_2nd_line is False:
|
||||
number = int(line_list[0])
|
||||
@@ -216,6 +219,8 @@ def read_inp(file_name):
|
||||
model_definition = False
|
||||
if error_seg3 is True: # to print "not supported"
|
||||
Console.PrintError("Error: seg3 (3-node beam element type) not supported, yet.\n")
|
||||
elif error_not_supported_elemtype is True:
|
||||
Console.PrintError("Error: {} not supported.\n".format(elm_type))
|
||||
f.close()
|
||||
|
||||
# switch from the CalculiX node numbering to the FreeCAD node numbering
|
||||
|
||||
@@ -430,25 +430,26 @@ def fill_femresult_mechanical(
|
||||
if eigenmode_number > 0:
|
||||
res_obj.Eigenmode = eigenmode_number
|
||||
|
||||
# fill res_obj.Temperature if they exist
|
||||
# TODO, check if it is possible to have Temperature without disp
|
||||
# we would need to set NodeNumbers than
|
||||
if "temp" in result_set:
|
||||
Temperature = result_set["temp"]
|
||||
if len(Temperature) > 0:
|
||||
if len(Temperature.values()) != len(disp.values()):
|
||||
Temp = []
|
||||
Temp_extra_nodes = list(Temperature.values())
|
||||
nodes = len(disp.values())
|
||||
for i in range(nodes):
|
||||
# how is this possible? An example is needed!
|
||||
Console.PrintError("Temperature seams to have exptra nodes.\n")
|
||||
Temp_value = Temp_extra_nodes[i]
|
||||
Temp.append(Temp_value)
|
||||
res_obj.Temperature = list(map((lambda x: x), Temp))
|
||||
else:
|
||||
res_obj.Temperature = list(map((lambda x: x), Temperature.values()))
|
||||
res_obj.Time = step_time
|
||||
# it is assumed Temperature can not exist without disp
|
||||
# TODO really proof this
|
||||
# if temperature can exist without disp:
|
||||
# move them out of disp if conditiona and set NodeNumbers
|
||||
if "temp" in result_set:
|
||||
Temperature = result_set["temp"]
|
||||
if len(Temperature) > 0:
|
||||
if len(Temperature.values()) != len(disp.values()):
|
||||
Temp = []
|
||||
Temp_extra_nodes = list(Temperature.values())
|
||||
nodes = len(disp.values())
|
||||
for i in range(nodes):
|
||||
# how is this possible? An example is needed!
|
||||
Console.PrintError("Temperature seams to have exptra nodes.\n")
|
||||
Temp_value = Temp_extra_nodes[i]
|
||||
Temp.append(Temp_value)
|
||||
res_obj.Temperature = list(map((lambda x: x), Temp))
|
||||
else:
|
||||
res_obj.Temperature = list(map((lambda x: x), Temperature.values()))
|
||||
res_obj.Time = step_time
|
||||
|
||||
# fill res_obj.MassFlow
|
||||
if "mflow" in result_set:
|
||||
|
||||
@@ -1699,6 +1699,7 @@ def get_contact_obj_faces(
|
||||
"or not supported reference shape elements, contact face combination "
|
||||
"(example: multiple element faces per master or slave\n"
|
||||
)
|
||||
return [[], []]
|
||||
|
||||
FreeCAD.Console.PrintLog(" Slave: {}, {}\n".format(slave_ref[0].Name, slave_ref))
|
||||
FreeCAD.Console.PrintLog(" Master: {}, {}\n".format(master_ref[0].Name, master_ref))
|
||||
@@ -1790,6 +1791,7 @@ def get_tie_obj_faces(
|
||||
"or not supported reference shape elements, contact face combination "
|
||||
"(example: multiple element faces per master or slave\n"
|
||||
)
|
||||
return [[], []]
|
||||
|
||||
FreeCAD.Console.PrintLog("Slave: {}, {}\n".format(slave_ref[0].Name, slave_ref))
|
||||
FreeCAD.Console.PrintLog("Master: {}, {}\n".format(master_ref[0].Name, master_ref))
|
||||
|
||||
Reference in New Issue
Block a user