[2 Bugs] - In Show results window

About the development of the FEM module/workbench.

Moderator: bernd

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

[2 Bugs] - In Show results window

Postby EkaitzEsteban » Thu Jan 03, 2019 10:39 am

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 531 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 531 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
Posts: 5764
Joined: Thu Jan 05, 2017 9:03 pm

Re: [2 Bugs] - In Show results window

Postby Kunda1 » Thu Jan 03, 2019 1:19 pm

Have you tried with 0.18dev version per the FEM subforum sticky post guidelines?
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
User avatar
bernd
Posts: 8428
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: [2 Bugs] - In Show results window

Postby bernd » Fri Jan 04, 2019 7:10 pm

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
Posts: 8428
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: [2 Bugs] - In Show results window

Postby bernd » Fri Jan 04, 2019 8:05 pm

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
Posts: 8428
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: [2 Bugs] - In Show results window

Postby bernd » Fri Jan 11, 2019 5:51 am

issue #3769 created for the second one
wmayer
Site Admin
Posts: 14887
Joined: Thu Feb 19, 2009 10:32 am

Re: [2 Bugs] - In Show results window

Postby wmayer » Tue Jan 15, 2019 8:45 pm

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

Re: [2 Bugs] - In Show results window

Postby EkaitzEsteban » Wed Jan 16, 2019 8:29 pm

Thank you bernd and wmayer.
wmayer
Site Admin
Posts: 14887
Joined: Thu Feb 19, 2009 10:32 am

Re: [2 Bugs] - In Show results window

Postby wmayer » Wed Jan 16, 2019 11:34 pm

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
Site Admin
Posts: 14887
Joined: Thu Feb 19, 2009 10:32 am

Re: [2 Bugs] - In Show results window

Postby wmayer » Thu Jan 17, 2019 1:57 am

wmayer
Site Admin
Posts: 14887
Joined: Thu Feb 19, 2009 10:32 am

Re: [2 Bugs] - In Show results window

Postby wmayer » Thu Jan 17, 2019 11:51 am

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()