Navigation Menu

Skip to content

Commit

Permalink
FEM: vtk pipeline, and frd reader, principal stress, revert and improve
Browse files Browse the repository at this point in the history
  • Loading branch information
berndhahnebach committed Jul 14, 2020
1 parent 85a6df1 commit 9b18c2d
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 13 deletions.
15 changes: 12 additions & 3 deletions src/Mod/Fem/App/FemVTKTools.cpp
Expand Up @@ -660,7 +660,9 @@ std::map<std::string, std::string> _getFreeCADMechResultVectorProperties() {
// App::PropertyVectorList will be a list of vectors in vtk
std::map<std::string, std::string> resFCVecProp;
resFCVecProp["DisplacementVectors"] = "Displacement";
// the following three are filled only if there is a reinforced mat object
// https://forum.freecadweb.org/viewtopic.php?f=18&t=33106&start=70#p296317
// https://forum.freecadweb.org/viewtopic.php?f=18&t=33106&p=416006#p412800
resFCVecProp["PS1Vector"] = "Major Principal Stress";
resFCVecProp["PS2Vector"] = "Intermediate Principal Stress";
resFCVecProp["PS3Vector"] = "Minor Principal Stress";
Expand Down Expand Up @@ -690,10 +692,17 @@ std::map<std::string, std::string> _getFreeCADMechResultScalarProperties() {
resFCScalProp["NodeStrainXZ"] = "Strain xz component";
resFCScalProp["NodeStrainYZ"] = "Strain yz component";
resFCScalProp["Peeq"] = "Equivalent Plastic Strain";
// the following three are filled in all cases
// https://forum.freecadweb.org/viewtopic.php?f=18&t=33106&start=70#p296317
// resFCScalProp["PrincipalMax"] = "Major Principal Stress"; // can be plotted in Paraview as THE MAJOR PRINCIPAL STRESS MAGNITUDE
// resFCScalProp["PrincipalMed"] = "Intermediate Principal Stress"; // can be plotted in Paraview as THE INTERMEDIATE PRINCIPAL STRESS MAGNITUDE
// resFCScalProp["PrincipalMin"] = "Minor Principal Stress"; // can be plotted in Paraview as THE MINOR PRINCIPAL STRESS MAGNITUDE
// it might be these can be generated in paraview from stress tensor values as
// THE MAJOR PRINCIPAL STRESS MAGNITUDE, THE INTERMEDIATE PRINCIPAL STRESS MAGNITUDE, THE MINOR PRINCIPAL STRESS MAGNITUDE
// but I do not know how (Bernd), for some help see paraview tutorial on FreeCAD wiki
// thus TODO they might not be exported to external file format (first I need to know how to generate them in paraview)
// but there are needed anyway because the pipline in FreeCAD needs the principal stress values
// https://forum.freecadweb.org/viewtopic.php?f=18&t=33106&p=416006#p412800
resFCScalProp["PrincipalMax"] = "Major Principal Stress";
resFCScalProp["PrincipalMed"] = "Intermediate Principal Stress";
resFCScalProp["PrincipalMin"] = "Minor Principal Stress";
resFCScalProp["vonMises"] = "von Mises Stress";
resFCScalProp["Temperature"] = "Temperature";
resFCScalProp["MohrCoulomb"] = "MohrCoulomb";
Expand Down
27 changes: 21 additions & 6 deletions src/Mod/Fem/feminout/importCcxFrdResults.py
Expand Up @@ -125,9 +125,11 @@ def importFrd(
res_obj.Mesh = result_mesh_object
res_obj = importToolsFem.fill_femresult_mechanical(res_obj, result_set)
if analysis:
# need to be here, becasause later on, the analysis objs are needed
# see fill of principal stresses
analysis.addObject(res_obj)

# complementary result object calculations
# more result object calculations
from femresult import resulttools
from femtools import femutils
if not res_obj.MassFlowRate:
Expand All @@ -138,7 +140,7 @@ def importFrd(
# information 2:
# if the result data has multiple result sets there will be multiple result objs
# they all will use one mesh obj
# on the first res obj fill the mesh obj will be compacted, thus
# on the first res obj fill: the mesh obj will be compacted, thus
# it does not need to be compacted on further result sets
# but NodeNumbers need to be compacted for every result set (res object fill)
# example frd file: https://forum.freecadweb.org/viewtopic.php?t=32649#p274291
Expand All @@ -155,18 +157,31 @@ def importFrd(
res_obj = resulttools.add_disp_apps(res_obj)
# fill vonMises
res_obj = resulttools.add_von_mises(res_obj)
# fill principal stress
# if material reinforced object use add additional values to the res_obj
if res_obj.getParentGroup():
has_reinforced_mat = False
for obj in res_obj.getParentGroup().Group:
if obj.isDerivedFrom("App::MaterialObjectPython") \
and femutils.is_of_type(obj, "Fem::MaterialReinforced"):
if femutils.is_of_type(obj, "Fem::MaterialReinforced"):
has_reinforced_mat = True
Console.PrintLog(
"Reinfoced material object detected, "
"reinforced principal stresses and standard principal "
" stresses will be added.\n"
)
resulttools.add_principal_stress_reinforced(res_obj)
break
if has_reinforced_mat is False:
Console.PrintLog(
"No einfoced material object detected, "
"standard principal stresses will be added.\n"
)
# fill PrincipalMax, PrincipalMed, PrincipalMin, MaxShear
res_obj = resulttools.add_principal_stress_std(res_obj)
else:
Console.PrintLog(
"No Analysis detected, standard principal stresses will be added.\n"
)
# if a pure frd file was opened no analysis and thus no parent group
# fill PrincipalMax, PrincipalMed, PrincipalMin, MaxShear
res_obj = resulttools.add_principal_stress_std(res_obj)
Expand All @@ -184,7 +199,7 @@ def importFrd(
"- just no frd results where requestet in input file "
"(neither 'node file' nor 'el file' in output section')\n"
)
Console.PrintMessage(error_message)
Console.PrintWarning(error_message)

# create a result obj, even if we have no results but a result mesh in frd file
# see error message above for more information
Expand All @@ -210,7 +225,7 @@ def importFrd(
"Problem on frd file import. No nodes found in frd file.\n"
)
# None will be returned
# or would it be better to raise an exception if there are not even nodes in frd file
# or would it be better to raise an exception if there are not even nodes in frd file?

return res_obj

Expand Down
2 changes: 2 additions & 0 deletions src/Mod/Fem/femobjects/result_mechanical.py
Expand Up @@ -114,6 +114,8 @@ def __init__(self, obj):
"Reinforcement ratio z-direction",
True
)
# these three principal vectors are used only if there is a reinforced mat obj
# https://forum.freecadweb.org/viewtopic.php?f=18&t=33106&p=416006#p416006
obj.addProperty(
"App::PropertyVectorList",
"PS1Vector",
Expand Down
16 changes: 12 additions & 4 deletions src/Mod/Fem/femresult/resulttools.py
Expand Up @@ -374,6 +374,10 @@ def add_von_mises(res_obj):


def add_principal_stress_std(res_obj):
# saved into PrincipalMax, PrincipalMed, PrincipalMin
# TODO may be use only one container for principal stresses in result object
# https://forum.freecadweb.org/viewtopic.php?f=18&t=33106&p=416006#p416006
# but which one is better
prinstress1 = []
prinstress2 = []
prinstress3 = []
Expand All @@ -396,7 +400,7 @@ def add_principal_stress_std(res_obj):
res_obj.PrincipalMed = prinstress2
res_obj.PrincipalMin = prinstress3
res_obj.MaxShear = shearstress
FreeCAD.Console.PrintLog("Added principal stress and max shear values.\n")
FreeCAD.Console.PrintLog("Added standard principal stresses and max shear values.\n")
return res_obj


Expand Down Expand Up @@ -455,6 +459,10 @@ def add_principal_stress_reinforced(res_obj):
#
# calculate principal and max Shear and fill them in res_obj
#
# saved into PS1Vector, PS2Vector, PS3Vector
# TODO may be use only one container for principal stresses in result object
# https://forum.freecadweb.org/viewtopic.php?f=18&t=33106&p=416006#p416006
# but which one is better
prinstress1 = []
prinstress2 = []
prinstress3 = []
Expand Down Expand Up @@ -552,9 +560,9 @@ def add_principal_stress_reinforced(res_obj):
res_obj.PS2Vector = ps2v
res_obj.PS3Vector = ps3v

FreeCAD.Console.PrintMessage(
"Added principal stress and max shear values as well as"
"reinforcment rations, Mohr Coloumb values.\n"
FreeCAD.Console.PrintLog(
"Added reinforcement principal stresses and max shear values as well as "
"reinforcment ratios, Mohr Coloumb values.\n"
)
return res_obj

Expand Down

0 comments on commit 9b18c2d

Please sign in to comment.