Display principal stresses

About the development of the FEM module/workbench.

Moderator: bernd

ickby
Veteran
Posts: 3116
Joined: Wed Oct 05, 2011 7:36 am

Re: Display principal stresses

Post by ickby »

What I didn't get to work though is setting the strings in the "Glyph" dropdown menu. This should be handled by execute(). I tried to copy the way this is done for the Vectors, but nothing happens.... I've never used Qt before, so am probably missing something obvious here.
You must be a bit carefull here. For vectors/scalars etc. it is done in excecute because only there you are calculating the result data, hence only there you know which fields are available. As far as I can see your arrow types are fixed. Hence you can set them one time in your objects constructor.

Also note that this code only sets the properties in the App part of the object, this has nothing to do with the GUI yet. in your task dialog code you need to set the property values to the dropdown menu manually. For example you can call updateEnumerationList like here to setup the list from the property.
Right now, the filter breaks the pipeline. If you would add another filter behind it, that filter won't see any data.
In VTK you can chain as many fitlers as you like. You just need to make sure they are connected properly. The PCS Filter data structure supports this with the vector "algorithm storage". There you can store as many filters as you like. Than, you set the first one as source and the last one as target in the Filter. All other, that you connected between source and target, are simply stored in the filter vector. That should be enough to make it work.
amstuff
Posts: 11
Joined: Wed Sep 27, 2017 1:15 am

Re: Display principal stresses

Post by amstuff »

Once again thank you very much for your valuable input, @ickby!

I now got almost everything working as intended.

points on my todo list:
  1. Use the principal stress magnitude to select the arrow-shape
    Desired behaviour is: arrows facing each-other for compressional stresses; arrows facing in opposite direction for tensional stresses
    Most of this is already implemented, I just need to figure out how to get to the data.
  2. Use the magnitude for color and scaling
    Once I fix 1., this should be pretty straight-forward
  3. Lots of clean up in the code
ickby
Veteran
Posts: 3116
Joined: Wed Oct 05, 2011 7:36 am

Re: Display principal stresses

Post by ickby »

I now got almost everything working as intended.
Nice!
Use the principal stress magnitude to select the arrow-shape
Desired behaviour is: arrows facing each-other for compressional stresses; arrows facing in opposite direction for tensional stresses
Most of this is already implemented, I just need to figure out how to get to the data.
You should be careful to make nothing domain specific in your code, as this will also be used by other domains like Electro Magnetic B-Fields. So making something which works only for stresses should be avoided. Do you have an idea how to implement the criteria in a general way?
Use the magnitude for color and scaling
Once I fix 1., this should be pretty straight-forward
It would be nice to have here a option for the user. Sometimes you want uniform arrow sizes with just magnitude to color, sometimes you want also magnitude to scale etc. Giving the user flexibility for his analysis would be the best imho.
amstuff
Posts: 11
Joined: Wed Sep 27, 2017 1:15 am

Re: Display principal stresses

Post by amstuff »

ickby wrote: Wed Oct 18, 2017 9:38 am Do you have an idea how to implement the criteria in a general way?
What I'm planning to do is to pass a 4 value (x,y,z,magnitude) vectorfield to vtk and use the magnitude information to choose the glyph-type (the sign of the magnitude being the indicator). If magnitude isn't available or if the checkbox is unticked, I would default to the opposing direction arrow glyph instead.
ickby wrote: Wed Oct 18, 2017 9:38 am
Use the magnitude for color and scaling
Once I fix 1., this should be pretty straight-forward
It would be nice to have here a option for the user. Sometimes you want uniform arrow sizes with just magnitude to color, sometimes you want also magnitude to scale etc. Giving the user flexibility for his analysis would be the best imho.
I fully agree, I will add a checkbox for scaling.
Maybe it's also a good idea to ditch the whole "Display options" dialog, since surface is the only suitable mode and it makes no sense to choose Field/Vector not corresponding to the displayed data.
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Display principal stresses

Post by bernd »

hi amstuff!

any updates here? Your development would be some great improvement worth integrating in the FreeCAD master !

cheers bernd
amstuff
Posts: 11
Joined: Wed Sep 27, 2017 1:15 am

Re: Display principal stresses

Post by amstuff »

Hi bernd,
I have not forgotten about this and will definitely come back to it when i can make the time!
cheers
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Display principal stresses

Post by bernd »

amstuff wrote: Sun Dec 03, 2017 11:06 am I ... will definitely come back to it when i can make the time!
:D
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Display principal stresses

Post by bernd »

This would still be a great improvement for FreeCAD ... How about finishing this?
User avatar
HarryvL
Veteran
Posts: 1332
Joined: Sat Jan 06, 2018 7:38 pm
Location: Netherlands

Re: Display principal stresses

Post by HarryvL »

amstuff wrote: Wed Oct 11, 2017 12:50 am
Note that i changed the sigma matrix in importToolsFem.py's calculate_principal_stresses(i) as i believe it is not consistent with the order of the stresses as implemented in calculate_von_mises(i)

current code of calculate_principal_stresses(i)

Code: Select all

sigma = np.array([[i[0], i[3], i[4]],
                  [i[3], i[1], i[5]],
                  [i[4], i[5], i[2]]])
You are right ! It should be

Code: Select all

sigma = np.array([[i[0], i[3], i[5]],
                  [i[3], i[1], i[4]],
                  [i[5], i[4], i[2]]])
I found out the hard way :shock: : https://forum.freecadweb.org/viewtopic. ... 81#p240358
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Display principal stresses

Post by bernd »

does it mean there is a bug in FreeCAD master here: https://github.com/FreeCAD/FreeCAD/blob ... #L429-L431 ?
Post Reply