[2 Bugs] - In Show results window

About the development of the FEM module/workbench.

Moderator: bernd

EkaitzEsteban
Posts: 108
Joined: Wed Sep 12, 2018 1:31 pm

[2 Bugs] - In Show results window

Post by EkaitzEsteban »

Hello,

I found 2 bugs during stress display,

First bug:

Steps for reproduction:

1.- Open 3D cantiveler beam example:
2.- go to Calculix static results
3.- In show results window;
4 - click on Von Misses Stress
4.1 - click on max window
4.2.- click on avg window
4.3.- click on min window

The magnitudes change dinamically as shown in the figure....
bug_results.png
bug_results.png (69.03 KiB) Viewed 2183 times
2nd bug:

Steps for reproduction:

1.- Open 3D cantiveler beam example:
2.- go to Calculix static results
3.- Close results window;
4 - right click on Result mesh object --> show selection
4.1 - properties --> display mode --> Faces wireframe and nodes

all nodes shows different colours, as shown in the figure....
bug_results2.png
bug_results2.png (128.86 KiB) Viewed 2183 times
best regards,
Ekaitz.

OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.13528 (Git)
Build type: Release
Branch: releases/FreeCAD-0-17
Hash: 5c3f7bf8ec51e2c7187789f7edba71a7aa82a88b
Python version: 2.7.14
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.2.0
Locale: Spanish/Spain (es_ES)
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: [2 Bugs] - In Show results window

Post by Kunda1 »

Have you tried with 0.18dev version per the FEM subforum sticky post guidelines?
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: [2 Bugs] - In Show results window

Post by bernd »

first bug:

- We never saw this.
- try in latest dev release
- use no locale (on linux with), but since you are on Windows I do not know how ...

Code: Select all

LC_ALL=C   ./bin/FreeCAD
ahh there was some nasty bug but on Debian only. Try
- FreeCAD Preferences --> FEM --> General --> uncheck "Restore Result dialog settings"
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: [2 Bugs] - In Show results window

Post by bernd »

second bug:

confirmed for :

OS: Debian GNU/Linux buster/sid
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.15557 (Git)
Build type: Unknown
Branch: master
Hash: 9f2904e8ec9fc7075d83713a1ed1b33d7ca8d0b0
Python version: 3.7.2rc1
Qt version: 5.11.2
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: German/Switzerland (de_CH)

it is happening here ...
https://github.com/FreeCAD/FreeCAD/blob ... #L479-L481

it can be repeated with the following code ...

Code: Select all

FreeCAD.open(FreeCAD.ConfigGet("AppHomePath") + 'data/examples/FemCalculixCantilever3D.FCStd')
result = App.ActiveDocument.CalculiX_static_results
mesh = result.Mesh
mesh.ViewObject.Visibility = True
mesh.ViewObject.DisplayMode = "Faces, Wireframe & Nodes"
and

Code: Select all

node_numbers = list(mesh.FemMesh.Nodes.keys())
zero_values = [0] * len(node_numbers)
mesh.ViewObject.setNodeColorByScalars(node_numbers, zero_values)



I do not know yet whats wrong ...
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: [2 Bugs] - In Show results window

Post by bernd »

issue #3769 created for the second one
wmayer
Founder
Posts: 20302
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: [2 Bugs] - In Show results window

Post by wmayer »

EkaitzEsteban
Posts: 108
Joined: Wed Sep 12, 2018 1:31 pm

Re: [2 Bugs] - In Show results window

Post by EkaitzEsteban »

Thank you bernd and wmayer.
wmayer
Founder
Posts: 20302
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: [2 Bugs] - In Show results window

Post by wmayer »

About first bug:
This is caused by mixing decimal separators. In German and apparently Spanish a comma is used while in English it's a dot.

In _ViewProviderFemResultMechanical.py I found the method:

Code: Select all

    def set_result_stats(self, unit, minm, avg, maxm):
        self.form.le_min.setProperty("unit", unit)
        self.form.le_min.setText("{:.6} {}".format(minm, unit))
        self.form.le_avg.setProperty("unit", unit)
        self.form.le_avg.setText("{:.6} {}".format(avg, unit))
        self.form.le_max.setProperty("unit", unit)
        self.form.le_max.setText("{:.6} {}".format(maxm, unit))
I guess that unit is a string and the other values are floats. As a test try this:

Code: Select all

minm=11.6387
unit = "MPa"
"{:.6} {}".format(minm, unit)
The output will be: '11.6387 MPa'

The problem is that the InputField class (it's a Qt widget like a spin box) expects strings in locale specific format. The dot is interpreted as group separator and for easier internal handling it gets removed. So, the string will become: '116387 MPa' which is the same as 116.387 GPa. In the input field it uses the comma as decimal separator and thus shows: 116,387 GPa

You may think that this is a bug in the InputField class but it's not. You can observe a similar behaviour with standard Qt widgets, too. In order to test it the locale settings must use another symbol than a dot as decimal separator, e.g. the comma:

Code: Select all

from PySide import QtGui
minm = 11.63
sb=QtGui.QDoubleSpinBox()
sb.valueFromText("{:.2}".format(minm)) # returns 0.0 and actually means it failed to convert
sb.valueFromText("11,63") # returns 11.63
The proper way to fix this would be to create a locale specific string in the Python code and pass this to the setText() function. I wonder how difficult this will be.
I found the locale Python module which supports this but the main problem is to make things consistent with Qt.

An easier way might be to extend the InputField class with a new property rawText which can be set via Python. Internally the class performs the correct conversion.
wmayer
Founder
Posts: 20302
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: [2 Bugs] - In Show results window

Post by wmayer »

wmayer
Founder
Posts: 20302
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: [2 Bugs] - In Show results window

Post by wmayer »

When working with quantities there are two ways to do it:

Code: Select all

ui=FreeCADGui.UiLoader()
w=ui.createWidget("Gui::InputField")

minm=11.6387
unit = "MPa"
text="{:.6} {}".format(minm, unit)
w.setProperty("rawText",text)
w.show()
or

Code: Select all

ui=FreeCADGui.UiLoader()
w=ui.createWidget("Gui::InputField")

minm=11.6387
unit = "MPa"
text="{:.6} {}".format(minm, unit)
q=FreeCAD.Units.parseQuantity(text)
w.setText(q.UserString)
w.show()
Post Reply