[Solved] FEM doesn't work anymore

About the development of the FEM module/workbench.

Moderator: bernd

ElMastro
Posts: 39
Joined: Mon May 27, 2019 9:52 am

[Solved] FEM doesn't work anymore

Postby ElMastro » Mon May 27, 2019 10:13 am

Good morning,
I've used Freecad for some years, but suddenly I realized I can't make the FEM module work anymore.
My version is

Code: Select all

OS: ArchBang Linux
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.16117 (Git)
Build type: Release
Branch: makepkg
Hash: dbb4cc6415bac848a294f03b80f65e888d531742
Python version: 3.7.3
Qt version: 5.12.3
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: Italian/Italy (it_IT)
I tried to make a tutorial of the FEM on https://www.freecadweb.org/wiki/FEM_tutorial/it
First thing it doesn't show any window,and hitting Mesh> Mesh from shape by Gmsh it build it, but on the shell the output is

Code: Select all

Traceback (most recent call last):
  File "/usr/lib/freecad/Mod/Fem/femguiobjects/_ViewProviderFemMeshGmsh.py", line 72, in setEdit
    taskd = _TaskPanelFemMeshGmsh(self.Object)
  File "/usr/lib/freecad/Mod/Fem/femguiobjects/_ViewProviderFemMeshGmsh.py", line 222, in __init__
    QtCore.QObject.connect(self.form.if_max, QtCore.SIGNAL("valueChanged(Base::Quantity)"), self.max_changed)
<class 'AttributeError'>: 'PySide2.QtWidgets.QWidget' object has no attribute 'if_max'
I add the force and the constraint, but when I add The Material, again from the shell it says

Code: Select all

Traceback (most recent call last):
  File "/usr/lib/freecad/Mod/Fem/femguiobjects/_ViewProviderFemMaterial.py", line 71, in setEdit
    taskd = _TaskPanelFemMaterial(self.Object)
  File "/usr/lib/freecad/Mod/Fem/femguiobjects/_ViewProviderFemMaterial.py", line 119, in __init__
    QtCore.QObject.connect(self.parameterWidget.cb_materials, QtCore.SIGNAL("activated(int)"), self.choose_material)
<class 'AttributeError'>: 'PySide2.QtWidgets.QWidget' object has no attribute 'cb_materials'
Active Task Dialog found! Please close this one before opening  a new one!
And doesn't make me change the Material showing a warning (Active Task Dialog found! Please close this one before opening a new one).
I recompiled it, but nothing seems wrong with the installation (also other modules works perfectly), I searched in the forum but I couldn't find anything similar. For reference, my gmsh verso is

Code: Select all

gmsh -info
Version       : 4.2.3
License       : GNU General Public License
Build OS      : Linux64
Build date    : 20190407
Build host    : archbang
Build options : 64Bit ALGLIB Ann Bamg Blas Blossom Cairo DIntegration Dlopen DomHex Fltk GMP Gmm Hxt Hxt3D Jpeg Kbipack Lapack LinuxJoystick MathEx Med Mesh Metis Mmg3d Mpeg NativeFileChooser Netgen ONELAB ONELABMetamodel OpenCASCADE OpenCASCADE-CAF OpenGL OptHom Parser Plugins Png Post QuadTri Solver TetGen/BR Voro++ Zlib
FLTK version  : 1.3.5
OCC version   : 7.3.0
MED version   : 4.0.0
Web site      : http://gmsh.info
Issue tracker : https://gitlab.onelab.info/gmsh/gmsh/issues
and calculix and netgen are working.

Any suggestions?
Last edited by Kunda1 on Thu Jun 27, 2019 11:47 am, edited 2 times in total.
Reason: fixed title
User avatar
bernd
Posts: 8719
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: FEM doesn't work anymore

Postby bernd » Mon May 27, 2019 12:32 pm

ElMastro wrote:
Mon May 27, 2019 10:13 am
Good morning,
I've used Freecad for some years, but suddenly I realized I can't make the FEM module work anymore.
OK, there is at least on positve in this problem ... you joined the FreeCAD community :D Welcome to FreeCAD forum ...

ElMastro wrote:
Mon May 27, 2019 10:13 am
Version: 0.18.16117 (Git)
I can not reporduce it on Windows 0.18.16117

ElMastro wrote:
Mon May 27, 2019 10:13 am
I recompiled it, but nothing seems wrong with the installation (also other modules works perfectly),
does it mean you have the same porblem on a self compiled FreeCAD 0.18.16117 ? If yes would it be possible to write step by step what you have done? Something like start FreeCAD, make a box ... or provide some Python code to reproduce this. We had something similar in german forum, but I have not been able to reprocuce the problem.

ElMastro wrote:
Mon May 27, 2019 10:13 am
I add the force and the constraint, but when I add The Material, again from the shell it says

Code: Select all

Traceback (most recent call last):
  File "/usr/lib/freecad/Mod/Fem/femguiobjects/_ViewProviderFemMaterial.py", line 71, in setEdit
    taskd = _TaskPanelFemMaterial(self.Object)
  File "/usr/lib/freecad/Mod/Fem/femguiobjects/_ViewProviderFemMaterial.py", line 119, in __init__
    QtCore.QObject.connect(self.parameterWidget.cb_materials, QtCore.SIGNAL("activated(int)"), self.choose_material)
<class 'AttributeError'>: 'PySide2.QtWidgets.QWidget' object has no attribute 'cb_materials'
Active Task Dialog found! Please close this one before opening  a new one!
And doesn't make me change the Material showing a warning (Active Task Dialog found! Please close this one before opening a new one).
This is a follow up from the former problem. The mesh object is still in edit mode with an open task panel (which is not open due to the problem we do not know yet.) Try to finish the edit mode for the gmsh mesh object. right click on the obj. finish edit mode. The other workaround would be to savet the file and restart FreeCAD.
ElMastro
Posts: 39
Joined: Mon May 27, 2019 9:52 am

Re: FEM doesn't work anymore

Postby ElMastro » Tue May 28, 2019 9:59 am

Thanks for the welcome :)

Yes, my copy is self compile, the script used is here https://aur.archlinux.org/cgit/aur.git/ ... ?h=freecad

What I do is this:
  • start Freecad
  • build a box
  • switch to FEM module
  • build an Analysis pressing the button
(nothing seems strange until this)[/list]
  • Mesh > Mesh from shape by Gmsh
When I do the mesh, this is what I see
https://ibb.co/BBr5KZC (can't upload the image with the code)
That is different from when I could use it, but it may depend on the fact that several version has passed.
  • change the resolution of the mesh to 0.1 mm (cube is small, 1 mm of height/lenght/depth)
  • click OK
Now the program complains with

Code: Select all

Traceback (most recent call last):
  File "/usr/lib/freecad/Mod/Fem/femguiobjects/_ViewProviderFemMeshGmsh.py", line 72, in setEdit
    taskd = _TaskPanelFemMeshGmsh(self.Object)
  File "/usr/lib/freecad/Mod/Fem/femguiobjects/_ViewProviderFemMeshGmsh.py", line 222, in __init__
    QtCore.QObject.connect(self.form.if_max, QtCore.SIGNAL("valueChanged(Base::Quantity)"), self.max_changed)
<class 'AttributeError'>: 'PySide2.QtWidgets.QWidget' object has no attribute 'if_max'
The mesh has been generated, and it is invisible. However when I click on it it doesn't appair. I search on the internet but solutions seems to be for netgen meshes.
If I click on information it says

Code: Select all

========================== Dump contents of mesh ==========================

1) Total number of nodes:      	0
2) Total number of edges:      	0
3) Total number of faces:      	0
4) Total number of polygons:   	0
5) Total number of volumes:    	0
6) Total number of polyhedrons:	0

7) Total number of linear edges:	0
8) Total number of linear faces:	0
9) Total number of linear volumes:	0

10) Total number of quadratic edges:	0
11) Total number of quadratic faces:	0
12) Total number of quadratic volumes:	0

===========================================================================
I tried to check if using gmsh/netgen outside freecad works, but as I import the mesh it si not bound on the part, and so I couldn't do the FEM so far
User avatar
bernd
Posts: 8719
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: FEM doesn't work anymore

Postby bernd » Tue May 28, 2019 12:52 pm

very very strange. IMHO it seams the widget is not found or somehow broken.

Do you use a path with special character? Do you run from build directory or do you install FreeCAD?

I may try to breake it for me to, I got some ideas what could caus this. I will come back ...
ElMastro wrote:
Tue May 28, 2019 9:59 am
I tried to check if using gmsh/netgen outside freecad works, but as I import the mesh it si not bound on the part, and so I couldn't do the FEM so far
you do not need to bound it to the part.

- export the part as brep
- mesh with external mesher
- export the mesh to unv
- import unv mesh into FreeCAD
- move mesh object inside Analysis
- run analysis

I you would like to have changes on the mesh, just remesh with external mesher, export, import and exchange the mesh object in FreeCAD analysis by drag and drop.
User avatar
bernd
Posts: 8719
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: FEM doesn't work anymore

Postby bernd » Tue May 28, 2019 12:56 pm

Ha you are on Arch Linux ... :shock: There was some problem, but different, but Arch problems https://forum.freecadweb.org/viewtopic. ... 40#p309083
ElMastro
Posts: 39
Joined: Mon May 27, 2019 9:52 am

Re: FEM doesn't work anymore

Postby ElMastro » Tue May 28, 2019 2:20 pm

All right, I can confirm that gmsh works like a charm, mesh is loaded within FreeCAD without problem, but as I try to set the material or set the condition of the Analysis it gives the problem.

I remember having problems in the update of the python dependencies of Freecad some time ago (a few weeks I believe). This to me sounds as bug, and probably the best think could be to inform the developers.
User avatar
bernd
Posts: 8719
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: FEM doesn't work anymore

Postby bernd » Tue May 28, 2019 2:29 pm

it seams all python FEM task panels do not work for you ...

They might be missing. Does it even not work if you start FreeCAD from Build directory?

Would you run this code:

Code: Select all

FreeCAD.getHomePath() + "Mod/Fem/Resources/ui/MeshGmsh.ui"
For me it gives ...

Code: Select all

>>>
>>> FreeCAD.getHomePath() + "Mod/Fem/Resources/ui/MeshGmsh.ui"
'C:/0_BHA_privat/progr/FreeCAD_0.19.xxxxx_Py3Qt5/Mod/Fem/Resources/ui/MeshGmsh.ui'
>>> 
Than in the directory printed ... there are the ui files ... screen attached ...

screen.PNG
screen.PNG (56.53 KiB) Viewed 932 times
wmayer
Site Admin
Posts: 15122
Joined: Thu Feb 19, 2009 10:32 am

Re: FEM doesn't work anymore

Postby wmayer » Tue May 28, 2019 5:52 pm

According to the error message the .ui file can be loaded and a form created. But for some reason the mechanism to access a sub-control by its name doesn't work.

Here some test code you can try:

Code: Select all

form = FreeCADGui.PySideUic.loadUi(FreeCAD.getHomePath() + "Mod/Fem/Resources/ui/MeshGmsh.ui")
form
form.if_max # this doesn't seem to work for you

from PySide2 import QtWidgets

f=form.findChildren(QtWidgets.QLineEdit)
f[0].metaObject().className()
f[0].objectName()

form.show()
ElMastro
Posts: 39
Joined: Mon May 27, 2019 9:52 am

Re: FEM doesn't work anymore

Postby ElMastro » Wed May 29, 2019 10:24 am

running
FreeCAD.getHomePath() + "Mod/Fem/Resources/ui/MeshGmsh.ui"
it says

Code: Select all

'/usr/lib/freecad/Mod/Fem/Resources/ui/MeshGmsh.ui'
and the folders contains all the files

Code: Select all

ls /usr/lib/freecad/Mod/Fem/Resources/ui/
ElectrostaticPotential.ui  FlowVelocity.ui         MeshGroup.ui
ElementFluid1D.ui          InitialFlowVelocity.ui  MeshGroupXDMFExport.ui
ElementGeometry1D.ui       Material.ui             MeshRegion.ui
ElementGeometry2D.ui       MeshBoundaryLayer.ui    ResultShow.ui
ElementRotation1D.ui       MeshGmsh.ui             SolverCalculix.ui
That there are on your version
When I ran the code
form = FreeCADGui.PySideUic.loadUi(FreeCAD.getHomePath() + "Mod/Fem/Resources/ui/MeshGmsh.ui")
form
form.if_max # this doesn't seem to work for you

from PySide2 import QtWidgets

f=form.findChildren(QtWidgets.QLineEdit)
f[0].metaObject().className()
f[0].objectName()

form.show()
This appear
https://ibb.co/fDng019

Which I remember to be the form I used when I used the fem.
wmayer
Site Admin
Posts: 15122
Joined: Thu Feb 19, 2009 10:32 am

Re: FEM doesn't work anymore

Postby wmayer » Wed May 29, 2019 10:40 am

But what's the output for each line of code?