[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

Re: FEM doesn't work anymore

Post by ElMastro »

Great Work!
Now almost everything works also on mine, in details
[*] Create the piece
[*] The Analysis is created
[*] Mesh GUI shows correctly
[*] Mesh is created without elements, in the terminal output is

Code: Select all

 TypeError: Can't call meta function because I have no idea how to handle Base::Quantity
TypeError: Can't call meta function because I have no idea how to handle Base::Quantity
========================== 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 do believe this could depend on gmsh, although it seems to works stand-alone)
[*] When I click Material, the beautiful material GUI shows itselfs also with the library of material included
[*] When I click on OK, however, the output in console is

Code: Select all

Traceback (most recent call last):
  File "/usr/lib/freecad/Mod/Fem/femguiobjects/_ViewProviderFemMaterial.py", line 261, in accept
    if checkunits(self.material) is True:
  File "/usr/lib/freecad/Mod/Material/materialtools/cardutils.py", line 609, in check_mat_units
    known_quantities = get_known_material_quantity_parameter()
  File "/usr/lib/freecad/Mod/Material/materialtools/cardutils.py", line 330, in get_known_material_quantity_parameter
    template_data = get_material_template()
  File "/usr/lib/freecad/Mod/Material/materialtools/cardutils.py", line 224, in get_material_template
    import yaml
<class 'ModuleNotFoundError'>: No module named 'yaml'
[*] I I try to go further (write the *.inp file) the message "Active Task Dialog found! Please close this one before opening a new one!" keep appearing.
I searched on Internet, found nothing about this.
Output in Python console is

Code: Select all

Python 3.7.3 (default, Mar 26 2019, 21:43:19) 
[GCC 8.2.1 20181127] on linux
Type 'help', 'copyright', 'credits' or 'license' for more information.
>>> App.newDocument("Senza nome")
>>> App.setActiveDocument("Senza_nome")
>>> App.ActiveDocument=App.getDocument("Senza_nome")
>>> Gui.ActiveDocument=Gui.getDocument("Senza_nome")
>>> Gui.activeDocument().activeView().viewDefaultOrientation()
>>> Gui.activateWorkbench("PartWorkbench")
>>> App.ActiveDocument.addObject("Part::Box","Box")
>>> App.ActiveDocument.ActiveObject.Label = "Cubo"
>>> App.ActiveDocument.recompute()
>>> Gui.SendMsgToActiveView("ViewFit")
>>> Gui.activateWorkbench("FemWorkbench")
>>> import FemGui
>>> import ObjectsFem
>>> ObjectsFem.makeAnalysis(FreeCAD.ActiveDocument, 'Analysis')
>>> FemGui.setActiveAnalysis(FreeCAD.ActiveDocument.ActiveObject)
>>> ObjectsFem.makeSolverCalculixCcxTools(FreeCAD.ActiveDocument)
>>> FemGui.getActiveAnalysis().addObject(FreeCAD.ActiveDocument.ActiveObject)
>>> ObjectsFem.makeMeshGmsh(FreeCAD.ActiveDocument, 'FEMMeshGmsh')
>>> FreeCAD.ActiveDocument.ActiveObject.Part = FreeCAD.ActiveDocument.Box
>>> FemGui.getActiveAnalysis().addObject(FreeCAD.ActiveDocument.ActiveObject)
>>> FreeCADGui.ActiveDocument.setEdit(FreeCAD.ActiveDocument.ActiveObject.Name)
>>> print(FreeCAD.ActiveDocument.FEMMeshGmsh.FemMesh)
>>> import PySide
>>> mesh_info = str(FreeCAD.ActiveDocument.FEMMeshGmsh.FemMesh)
>>> PySide.QtGui.QMessageBox.information(None, 'FEM Mesh Info', mesh_info)
>>> FemGui.getActiveAnalysis().addObject(ObjectsFem.makeMaterialSolid(FreeCAD.ActiveDocument, 'SolidMaterial'))
>>> FreeCADGui.ActiveDocument.setEdit(FreeCAD.ActiveDocument.ActiveObject.Name)
>>> FemGui.setActiveAnalysis(App.activeDocument().Analysis)
>>> FemGui.setActiveAnalysis(App.activeDocument().Analysis)
>>> FemGui.setActiveAnalysis(App.activeDocument().Analysis)
Sorry for the long post
ElMastro
Posts: 39
Joined: Mon May 27, 2019 9:52 am

Re: FEM doesn't work anymore

Post by ElMastro »

Next thing I'll try to run the analysis on a external generated mesh (directly on gmsh) to understand what changes
wmayer
Founder
Posts: 20317
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: FEM doesn't work anymore

Post by wmayer »

You must install the package python3-yaml.
ElMastro
Posts: 39
Joined: Mon May 27, 2019 9:52 am

Re: FEM doesn't work anymore

Post by ElMastro »

thank to your help (almost everything) works now:
I couldn't find python3-yaml, installed python-yaml and python2-yaml; rebuilt, and now is the situation;
[*] Make the part, start the analysis, everything is fine so far
[*] Mesh doesn't works, output in shell is

Code: Select all

TypeError: Can't call meta function because I have no idea how to handle Base::Quantity
TypeError: Can't call meta function because I have no idea how to handle Base::Quantity
========================== 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

===========================================================================
Output is an empty mesh
[*] Export the piece as *.brep, mesh it in gmsh, load it in freecad as *.unv
[*] Select a material, apply it as a solid, everything seems ok
[*] Apply constrains, forces, etc
[*] Double click on CalculixccxTools, it writes the *.inp file
[*] When I run Calculix, thi is in the form

Code: Select all

0.0: Check dependencies...
0.1: Write completed.
0.0: CalculiX binary: /usr/bin/
0.0: Run CalculiX...
0.0: Starting CalculiX...
0.0: CalculiX stopped.
0.0: CalculiX execute error: PySide2.QtCore.QProcess.ProcessError.FailedToStart
In the Shell outputs is

Code: Select all

runCalculix
run CalculiX at: /usr/bin/ with: /tmp/femd8uj2tot/Cube
Error() PySide2.QtCore.QProcess.ProcessError.FailedToStart
...However...If I open the *.inp file in calculix, it works. If I load the *.frd files results are shown correctly.
wmayer
Founder
Posts: 20317
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: FEM doesn't work anymore

Post by wmayer »

I couldn't find python3-yaml, installed python-yaml and python2-yaml; rebuilt, and now is the situation;
OK, the package names are distribution specific, then: for Debian and its derivatives it's python-yaml for Py2 and python3-yaml for Py3.
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: FEM doesn't work anymore

Post by bernd »

ElMastro wrote: Sun Jun 23, 2019 3:29 pm [*] Mesh is created without elements, in the terminal output is
would you restart FreeCAD make a new document and try this code ...

Code: Select all

import Part, ObjectsFem

doc = App.ActiveDocument
box_obj = doc.addObject('Part::Box', 'Box')
doc.recompute()

femmesh_obj = ObjectsFem.makeMeshGmsh(doc, box_obj.Name + '_Mesh')
femmesh_obj.Part = box_obj
doc.recompute()
box_obj.ViewObject.Visibility = False

from femmesh import gmshtools
gmsh_mesh = gmshtools.GmshTools(femmesh_obj)
error = gmsh_mesh.create_mesh()
print(error)
doc.recompute()

Attachments
simpleboxmesh.FCStd
(89.51 KiB) Downloaded 37 times
ElMastro
Posts: 39
Joined: Mon May 27, 2019 9:52 am

Re: FEM doesn't work anymore

Post by ElMastro »

With a new document, running the code the output is

Code: Select all

Python 3.7.3 (default, Mar 26 2019, 21:43:19) 
[GCC 8.2.1 20181127] on linux
Type 'help', 'copyright', 'credits' or 'license' for more information.
>>> import Part, ObjectsFem
>>> 
>>> doc = App.ActiveDocument
>>> box_obj = doc.addObject('Part::Box', 'Box')
Traceback (most recent call last):
  File "<input>", line 1, in <module>
AttributeError: 'NoneType' object has no attribute 'addObject'
>>> doc.recompute()
Traceback (most recent call last):
  File "<input>", line 1, in <module>
AttributeError: 'NoneType' object has no attribute 'recompute'
>>> 
>>> femmesh_obj = ObjectsFem.makeMeshGmsh(doc, box_obj.Name + '_Mesh')
Traceback (most recent call last):
  File "<input>", line 1, in <module>
NameError: name 'box_obj' is not defined
>>> femmesh_obj.Part = box_obj
Traceback (most recent call last):
  File "<input>", line 1, in <module>
NameError: name 'box_obj' is not defined
>>> doc.recompute()
Traceback (most recent call last):
  File "<input>", line 1, in <module>
AttributeError: 'NoneType' object has no attribute 'recompute'
>>> box_obj.ViewObject.Visibility = False
Traceback (most recent call last):
  File "<input>", line 1, in <module>
NameError: name 'box_obj' is not defined
>>> 
>>> from femmesh import gmshtools
>>> gmsh_mesh = gmshtools.GmshTools(femmesh_obj)
Traceback (most recent call last):
  File "<input>", line 1, in <module>
NameError: name 'femmesh_obj' is not defined
>>> error = gmsh_mesh.create_mesh()
Traceback (most recent call last):
  File "<input>", line 1, in <module>
NameError: name 'gmsh_mesh' is not defined
>>> print(error)
Traceback (most recent call last):
  File "<input>", line 1, in <module>
NameError: name 'error' is not defined
>>> doc.recompute()
Traceback (most recent call last):
  File "<input>", line 1, in <module>
AttributeError: 'NoneType' object has no attribute 'recompute'
Loading simpleboxmesh.FCStd the output is

Code: Select all

Python 3.7.3 (default, Jun 24 2019, 04:54:02) 
[GCC 9.1.0] on linux
Type 'help', 'copyright', 'credits' or 'license' for more information.
>>> App.setActiveDocument("simpleboxmesh")
>>> App.ActiveDocument=App.getDocument("simpleboxmesh")
>>> Gui.ActiveDocument=Gui.getDocument("simpleboxmesh")
>>> import Part, ObjectsFem
>>> 
>>> doc = App.ActiveDocument
>>> box_obj = doc.addObject('Part::Box', 'Box')
>>> doc.recompute()
1
>>> 
>>> femmesh_obj = ObjectsFem.makeMeshGmsh(doc, box_obj.Name + '_Mesh')
>>> femmesh_obj.Part = box_obj
>>> doc.recompute()
1
>>> box_obj.ViewObject.Visibility = False
>>> 
>>> from femmesh import gmshtools
>>> gmsh_mesh = gmshtools.GmshTools(femmesh_obj)
>>> error = gmsh_mesh.create_mesh()

We are going to start Gmsh FEM mesh run!
  Part to mesh: Name --> Box001,  Label --> Box001, ShapeType --> Solid
  CharacteristicLengthMax: 1e+22
  CharacteristicLengthMin: 0.0
  ElementOrder: 2
  ElementDimension: 3
  /tmp/Box001_Geometry.brep
  /tmp/Box001_Mesh_TmpGmsh.unv
  /tmp/shape2mesh.geo
  /usr/bin
  No Group meshing for analysis.
>>> print(error)
Error executing: /usr/bin - /tmp/shape2mesh.geo

>>> doc.recompute()
0
>>> 
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: FEM doesn't work anymore

Post by bernd »

In FreeCAD FEM preferences gmsh you need to set te path to gmsh binary
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: FEM doesn't work anymore

Post by bernd »

moved the mesh region question to a new topic since ot is a totally new question. https://forum.freecadweb.org/viewtopic.php?f=18&t=37304

you may make anther post here and move the message part with your thanks back here. Just as you like.
ElMastro
Posts: 39
Joined: Mon May 27, 2019 9:52 am

Re: FEM doesn't work anymore

Post by ElMastro »

I apologize, the path I set proved to be wrong. Now everything works. I wold like to give an heartfelt thank to everybody for the patience and the time.
Post Reply