FEM VTK9.x with gmsh issue and FreeCAD 0.20

About the development of the FEM module/workbench.

Moderator: bernd

user1234
Veteran
Posts: 3512
Joined: Mon Jul 11, 2016 5:08 pm

FEM VTK9.x with gmsh issue and FreeCAD 0.20

Post by user1234 »

Hello!

see threads:

https://forum.freecad.org/viewtopic.php?t=28513
https://forum.freecad.org/viewtopic.php?t=62566
https://forum.freecad.org/viewtopic.php?t=63996
https://forum.freecad.org/viewtopic.php?t=65045
https://forum.freecad.org/viewtopic.php?t=66911

gmsh with VTK9.x does not work. Because there are many distributions, where only VTK9.x is available and also many, wher netgen does not work, i think this issue should be solved before the stable release of FreeCAD 0.20.

my fresh compiled version:

Code: Select all

OS: Debian GNU/Linux 11 (bullseye) (X-Cinnamon/lightdm-xsession)
Word size of FreeCAD: 64-bit
Version: 0.20.27972 (Git)
Build type: Release
Branch: master
Hash: 068f02c4b786bc425b44b7f8eec77ea6beab7f61
Python 3.9.2, Qt 5.15.2, Coin 4.0.0, OCC 7.6.1
Locale: English/United States (en_US)
with VTK9.0.1+dfsg1-8

gmsh version:

Code: Select all

Version       : 4.9.5
License       : GNU General Public License
Build OS      : Linux64
Build date    : 20220221
Build host    : gmsh.info
Build options : 64Bit ALGLIB[contrib] ANN[contrib] Bamg Blas[petsc] Blossom Cgns DIntegration Dlopen DomHex Eigen[contrib] Fltk Gmm[contrib] Hxt Jpeg Kbipack Lapack[petsc] LinuxJoystick MathEx[contrib] Med Mesh Metis[contrib] Mmg Mpeg Netgen ONELAB ONELABMetamodel OpenCASCADE OpenCASCADE-CAF OpenGL OpenMP OptHom PETSc Parser Plugins Png Post QuadMeshingTools QuadTri Solver TetGen/BR Voro++[contrib] WinslowUntangler Zlib
FLTK version  : 1.4.0
PETSc version : 3.14.4 (real arithmtic)
OCC version   : 7.6.1
MED version   : 4.1.0
Packaged by   : geuzaine
Web site      : https://gmsh.info
Issue tracker : https://gitlab.onelab.info/gmsh/gmsh/issues

Here a minimum working example, just cllear the mesh and run again.
mwe_VTK9.0.1.FCStd
(44.73 KiB) Downloaded 50 times
result_VTK9.0.1.png
result_VTK9.0.1.png (186.66 KiB) Viewed 2759 times

The console output while meshing.

Code: Select all

Active analysis found: Analysis
  ElementDimension: 3
  Group meshing for analysis is set to true in FEM General Preferences. Are you really sure about this? You could run into trouble!
  /tmp/fcfem_v3eok3rf/Body_Geometry.brep
  /tmp/fcfem_v3eok3rf/Body_Mesh.unv
  /tmp/fcfem_v3eok3rf/shape2mesh.geo
  /home/user/Programs/gmsh-4.9.0/bin/gmsh
2022-03-08 12:21:14.055 (  32.600s) [        AC7C3640]       vtkCellArray.cxx:551    ERR| vtkCellArray (0x562e9366ce10): Invalid location.
.....

many times, arround that often how many nodes are in the mesh

.....
2022-03-08 12:21:14.094 (  32.638s) [        AC7C3640]       vtkCellArray.cxx:551    ERR| vtkCellArray (0x562e9366ce10): Invalid location.
  New mesh was added to the mesh object.
Clean run of Gmsh

Here i compiled FreeCAD with VTK7.1.1+dfsg2-8 and the same (overwritten) file and result:
mwe_VTK7.1.1.FCStd
(76.33 KiB) Downloaded 46 times
result_VTK7.1.1.png
result_VTK7.1.1.png (187.31 KiB) Viewed 2759 times


I know, i should not bother other people with this, but i am not able to do it myself. Sadly i only can offer tests.

Ever help is welcome.

Greetings
user1234
user1234
Veteran
Posts: 3512
Joined: Mon Jul 11, 2016 5:08 pm

Re: FEM VTK9.x with gmsh issue and FreeCAD 0.20

Post by user1234 »

I think that deserves a ticket, since it makes on some OS configurations FEM unusable.

Greetings
user1234
User avatar
NewJoker
Veteran
Posts: 3089
Joined: Sun Oct 11, 2020 7:49 pm

Re: FEM VTK9.x with gmsh issue and FreeCAD 0.20

Post by NewJoker »

user1234 wrote: Thu Mar 10, 2022 5:12 pm I think that deserves a ticket, since it makes on some OS configurations FEM unusable.

Greetings
user1234
I created a GitHub issue for this: https://github.com/FreeCAD/FreeCAD/issues/6553

Unfortunately, it seems that at the moment there's no one to fix this.
wmayer
Founder
Posts: 20323
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: FEM VTK9.x with gmsh issue and FreeCAD 0.20

Post by wmayer »

gmsh with VTK9.x does not work.
Does gmsh depend on the VTK library? With ldd /usr/bin/gmsh I don't see it but it's an older gmsh version (3.0.6).
i think this issue should be solved before the stable release of FreeCAD 0.20.
Absolutely! It's a show stopper bug.

Another thing that must be carefully tested is if FreeCAD and gmsh are linked with different OCC versions. Here it can happen that the Brep file that FreeCAD creates cannot be loaded by gmsh. This is because with OCC 7.5 or 7.6 the default Brep creates different files that cannot be loaded with older OCC versions. The trick is to set an explicit format number that is supported by all OCC versions when exporting as Brep.
user1234
Veteran
Posts: 3512
Joined: Mon Jul 11, 2016 5:08 pm

Re: FEM VTK9.x with gmsh issue and FreeCAD 0.20

Post by user1234 »

wmayer wrote: Fri Mar 11, 2022 1:22 pm Does gmsh depend on the VTK library?
As far as i know, no. The gmsh i use, is also a binary to download, https://gmsh.info/bin/, and set the path in the FEM workbench to the binary.

wmayer wrote: Fri Mar 11, 2022 1:22 pm Another thing that must be carefully tested is if FreeCAD and gmsh are linked with different OCC versions. Here it can happen that the Brep file that FreeCAD creates cannot be loaded by gmsh. This is because with OCC 7.5 or 7.6 the default Brep creates different files that cannot be loaded with older OCC versions. The trick is to set an explicit format number that is supported by all OCC versions when exporting as Brep.
Also as far as i know, when you mesh it gmsh directly, the mesh is good (i (must (re)test it, i only saw the reports from other people). But i also tried to find the source of the issue long time ago, and i stuck somewhere in the 3rd Party in smesh. But i must recall it again. I will try some tests so mesh something in gmsh directly.

Greetings
user1234
user1234
Veteran
Posts: 3512
Joined: Mon Jul 11, 2016 5:08 pm

Re: FEM VTK9.x with gmsh issue and FreeCAD 0.20

Post by user1234 »

NewJoker wrote: Fri Mar 11, 2022 9:53 am I created a GitHub issue for this: https://github.com/FreeCAD/FreeCAD/issues/6553
Thanks, i have no accont in GitHub.

Greetings
user1234
User avatar
jnxd
Posts: 952
Joined: Mon Mar 30, 2015 2:30 pm
Contact:

Re: FEM VTK9.x with gmsh issue and FreeCAD 0.20

Post by jnxd »

Might or might not be related, but packages paraview and vtk are (currently?) in conflict with each other in Manjaro. If this is not a permanent thing, maybe vtk9 broke things?
user1234
Veteran
Posts: 3512
Joined: Mon Jul 11, 2016 5:08 pm

Re: FEM VTK9.x with gmsh issue and FreeCAD 0.20

Post by user1234 »

Hmmm, see that python3-paraview is in conflict with python3-vtk9 in Debian 11. But it is hard to believe since paraview and vtk working, more or less, hand in hand and both are from kitware.

Greetings
user1234
User avatar
jnxd
Posts: 952
Joined: Mon Mar 30, 2015 2:30 pm
Contact:

Re: FEM VTK9.x with gmsh issue and FreeCAD 0.20

Post by jnxd »

user1234 wrote: Tue Mar 08, 2022 11:46 am
Here a minimum working example, just cllear the mesh and run again.mwe_VTK9.0.1.FCStdresult_VTK9.0.1.png


The console output while meshing.

Code: Select all

Active analysis found: Analysis
  ElementDimension: 3
  Group meshing for analysis is set to true in FEM General Preferences. Are you really sure about this? You could run into trouble!
  /tmp/fcfem_v3eok3rf/Body_Geometry.brep
  /tmp/fcfem_v3eok3rf/Body_Mesh.unv
  /tmp/fcfem_v3eok3rf/shape2mesh.geo
  /home/user/Programs/gmsh-4.9.0/bin/gmsh
2022-03-08 12:21:14.055 (  32.600s) [        AC7C3640]       vtkCellArray.cxx:551    ERR| vtkCellArray (0x562e9366ce10): Invalid location.
.....

many times, arround that often how many nodes are in the mesh

.....
2022-03-08 12:21:14.094 (  32.638s) [        AC7C3640]       vtkCellArray.cxx:551    ERR| vtkCellArray (0x562e9366ce10): Invalid location.
  New mesh was added to the mesh object.
Clean run of Gmsh
I get the "invalid location" complaints the moment I open the file. But when making the mesh, I get:

Code: Select all

FreeCAD: .../src/3rdParty/salomesmesh/src/SMDS/SMDS_VtkEdge.cpp:119: virtual int SMDS_VtkEdge::NbNodes() const: Assertion `nbPoints >= 2' failed.
user1234
Veteran
Posts: 3512
Joined: Mon Jul 11, 2016 5:08 pm

Re: FEM VTK9.x with gmsh issue and FreeCAD 0.20

Post by user1234 »

Now testing with VTK9, gmsh4.9.5 (and OCCT7.6.1).

While recompiling with vtk9, i get a warning:

Code: Select all

/home/user/Programs/FreeCADmasterRelease/sourcecode/src/3rdParty/salomesmesh/src/StdMeshers/StdMeshers_Adaptive1D.cpp: In constructor ‘{anonymous}::TriaTreeData::TriaTreeData(const TopoDS_Face&, {anonymous}::ElementBndBoxTree*)’:
/home/user/Programs/FreeCADmasterRelease/sourcecode/src/3rdParty/salomesmesh/src/StdMeshers/StdMeshers_Adaptive1D.cpp:333:43: warning: ‘const Poly_Array1OfTriangle& Poly_Triangulation::Triangles() const’ is deprecated: Deprecated method, Triangle() should be used instead [-Wdeprecated-declarations]
  333 |       myPolyTrias       = & tr->Triangles();
      |                                           ^
In file included from /usr/local/include/opencascade/Poly_ListOfTriangulation.hxx:20,
                 from /usr/local/include/opencascade/BRep_Tool.hxx:30,
                 from /home/user/Programs/FreeCADmasterRelease/sourcecode/src/3rdParty/salomesmesh/src/StdMeshers/StdMeshers_Adaptive1D.cpp:40:
/usr/local/include/opencascade/Poly_Triangulation.hxx:318:32: note: declared here
  318 |   const Poly_Array1OfTriangle& Triangles() const { return myTriangles; }
      |     

When i export a *.brep and mesh it in gmsh, it meshes fine in gmsh.
0.png
0.png (48.86 KiB) Viewed 2098 times


When i export it as *.vtk file and import it in FreeCAD, also fine.
1.png
1.png (19.42 KiB) Viewed 2098 times



But FEM imports *.unv files and when i import it, i get the same error as reported:

Code: Select all

2022-03-21 19:41:01.905 (1131.933s) [        E21C6640]       vtkCellArray.cxx:551    ERR| vtkCellArray (0x55623c079fe0): Invalid location.
2022-03-21 19:41:01.905 (1131.933s) [        E21C6640]       vtkCellArray.cxx:551    ERR| vtkCellArray (0x55623c079fe0): Invalid location.

.....

2022-03-21 19:41:01.943 (1131.971s) [        E21C6640]       vtkCellArray.cxx:551    ERR| vtkCellArray (0x55623c079fe0): Invalid location.
2022-03-21 19:41:01.943 (1131.971s) [        E21C6640]       vtkCellArray.cxx:551    ERR| vtkCellArray (0x55623c079fe0): Invalid location.
<Gui> Document.cpp(819): C++ exception in Unnamed1#mwe001 thrown Node count not supported by ViewProviderFemMesh, [4|5|6|8|10|13|15|20] are allowed


jnxd wrote: Mon Mar 21, 2022 6:14 pmI get the "invalid location" complaints the moment I open the file. But when making the mesh, I get:

Code: Select all

FreeCAD: .../src/3rdParty/salomesmesh/src/SMDS/SMDS_VtkEdge.cpp:119: virtual int SMDS_VtkEdge::NbNodes() const: Assertion `nbPoints >= 2' failed.
Yes, i think smesh is the culprit, but sadly silly me, i am not capable to prove that, nor to solve that.

Greetings
user1234
Post Reply