FEM: writer base, log improvements

This commit is contained in:
Bernd Hahnebach
2020-01-07 08:29:46 +01:00
parent f190884bd5
commit a53b237602

View File

@@ -30,6 +30,7 @@ import os
import FreeCAD
from femmesh import meshtools
from femtools.femutils import type_of_obj
class FemInputWriter():
@@ -126,9 +127,7 @@ class FemInputWriter():
# get nodes
for femobj in self.fixed_objects:
# femobj --> dict, FreeCAD document object is femobj["Object"]
FreeCAD.Console.PrintMessage(
"Constraint fixed:" + " " + femobj["Object"].Name + "\n"
)
print_obj_info(femobj["Object"])
femobj["Nodes"] = meshtools.get_femnodes_by_femobj_with_references(
self.femmesh,
femobj
@@ -165,9 +164,7 @@ class FemInputWriter():
# get nodes
for femobj in self.displacement_objects:
# femobj --> dict, FreeCAD document object is femobj["Object"]
FreeCAD.Console.PrintMessage(
"Constraint displacement:" + " " + femobj["Object"].Name + "\n"
)
print_obj_info(femobj["Object"])
femobj["Nodes"] = meshtools.get_femnodes_by_femobj_with_references(
self.femmesh,
femobj
@@ -180,9 +177,7 @@ class FemInputWriter():
# get nodes
for femobj in self.planerotation_objects:
# femobj --> dict, FreeCAD document object is femobj["Object"]
FreeCAD.Console.PrintMessage(
"Constraint plane rotation:" + " " + femobj["Object"].Name + "\n"
)
print_obj_info(femobj["Object"])
femobj["Nodes"] = meshtools.get_femnodes_by_femobj_with_references(
self.femmesh,
femobj
@@ -192,9 +187,7 @@ class FemInputWriter():
# get nodes
for femobj in self.transform_objects:
# femobj --> dict, FreeCAD document object is femobj["Object"]
FreeCAD.Console.PrintMessage(
"Constraint transform nodes:" + " " + femobj["Object"].Name + "\n"
)
print_obj_info(femobj["Object"])
femobj["Nodes"] = meshtools.get_femnodes_by_femobj_with_references(
self.femmesh,
femobj
@@ -204,9 +197,7 @@ class FemInputWriter():
# get nodes
for femobj in self.temperature_objects:
# femobj --> dict, FreeCAD document object is femobj["Object"]
FreeCAD.Console.PrintMessage(
"Constraint temperature:" + " " + femobj["Object"].Name + "\n"
)
print_obj_info(femobj["Object"])
femobj["Nodes"] = meshtools.get_femnodes_by_femobj_with_references(
self.femmesh,
femobj
@@ -216,9 +207,7 @@ class FemInputWriter():
# get nodes
for femobj in self.fluidsection_objects:
# femobj --> dict, FreeCAD document object is femobj["Object"]
FreeCAD.Console.PrintMessage(
"Constraint fluid section:" + " " + femobj["Object"].Name + "\n"
)
print_obj_info(femobj["Object"])
femobj["Nodes"] = meshtools.get_femnodes_by_femobj_with_references(
self.femmesh,
femobj
@@ -228,10 +217,7 @@ class FemInputWriter():
# check shape type of reference shape
for femobj in self.force_objects:
# femobj --> dict, FreeCAD document object is femobj["Object"]
frc_obj = femobj["Object"]
FreeCAD.Console.PrintLog(
"Constraint force:" + " " + frc_obj.Name + "\n"
)
print_obj_info(femobj["Object"], log=True)
if femobj["RefShapeType"] == "Vertex":
FreeCAD.Console.PrintLog(
" load on vertices --> The femelement_table "
@@ -269,9 +255,7 @@ class FemInputWriter():
for femobj in self.force_objects:
# femobj --> dict, FreeCAD document object is femobj["Object"]
frc_obj = femobj["Object"]
FreeCAD.Console.PrintMessage(
"Constraint force:" + " " + frc_obj.Name + "\n"
)
print_obj_info(frc_obj)
if frc_obj.Force == 0:
FreeCAD.Console.PrintMessage(" Warning --> Force = 0\n")
if femobj["RefShapeType"] == "Vertex": # point load on vertices
@@ -320,9 +304,7 @@ class FemInputWriter():
for femobj in self.pressure_objects:
# femobj --> dict, FreeCAD document object is femobj["Object"]
FreeCAD.Console.PrintMessage(
"Constraint pressure: " + femobj["Object"].Name + "\n"
)
print_obj_info(femobj["Object"])
pressure_faces = meshtools.get_pressure_obj_faces(
self.femmesh,
self.femelement_table,
@@ -447,4 +429,18 @@ class FemInputWriter():
self.material_objects
)
# helper
def print_obj_info(obj, log=False):
if log is False:
FreeCAD.Console.PrintMessage("{}:\n".format(obj.Label))
FreeCAD.Console.PrintMessage(
" Type: {}, Name: {}\n".format(type_of_obj(obj), obj.Name)
)
else:
FreeCAD.Console.PrintLog("{}:\n".format(obj.Label))
FreeCAD.Console.PrintLog(
" Type: {}, Name: {}\n".format(type_of_obj(obj), obj.Name)
)
## @}