VTK-9.0.3-1 is asserting with a simple cube FEM in FreeCAD

I’m not sure where to report a bug/issue, so here I am.

Full description of the issue is here:

How should I proceed ?

please share the failing dataset.

I’m a new user. Discourse will not allow me to upload an attachment.

I uploaded the FreeCAD file to this bug report.

You are not authorized to access bug #2009878.

please share using discourse, I’ve set your permissions so you can upload.

Description of problem:

VTK is firing an assert on a simple FreeCAD FEM.

Version-Release number of selected component (if applicable):

dnf list vtk
Installed Packages
vtk.x86_64 9.0.3-1.fc34

dnf list freecad
Installed Packages
freecad.x86_64 1:0.19.2-1.fc34

How reproducible:

Multiple computers, multiple users, every time.

Steps to Reproduce:

  1. Start FreeCAD
  2. Draw a simple 3D cube in Part workbench
  3. Perform a FEM

See attached FreeCAD source file.

Complete details here: gmsh fails on simple cube - FreeCAD Forum See post #13, posted at Wed Sep 29, 2021 3:12 pm

Actual results:

2021-10-01 19:43:25.760 ( 48.164s) [ 2BB67640] vtkCellArray.cxx:551 ERR| vtkCellArray (0x56322fccc390): Invalid location.
FreeCAD: /home/user/Programs/FreeCAD/sourcecode/src/3rdParty/salomesmesh/src/SMDS/SMDS_VtkEdge.cpp:119: virtual int SMDS_VtkEdge::NbNodes() const: Assertion `nbPoints >= 2’ failed.

Expected results:

A successful mesh.

Additional info:

VTK-7 is reported to work by several users. VTK-8 or 7 is available on FC33, but not FC34 and VTK is not straight forward to build on FC34 due to compiler issues.

I am in the process of reporting this issue to the VTK group. In the meantime, a good work around would be to build VTK-7 or 8 and make it available as a downgrade on FC34.

FEM Test.FCStd (8.8 KB)

There is no FCStd reader in VTK and your steps to reproduce are using FreeCAD, not VTK, are you sure this is a VTK issue ?

The error occurs when VTK is called while generating a mesh in FreeCAD. You’d need to install FreeCAD-0.19 and run the example in order to experience the error.

Is it a VTK problem ? VTK-7 and VTK-8 both work fine with FreeCAD-0.19 with this example. VTK-9 does not.

I appreciate your attention to my problem.

What would the extension of the input file be ? Maybe I can capture it mid process and send it to you.

No idea, it can be a misuse of VTK that used to work before, it can be a VTK bug. Without a minimal example to reproduce in VTK, it is down to FreeCAD developpers to figure out what is not working from a VTK user point of view.

file extension should .vtk or .vtp/u/r/i/s/m, maybe ? But since FreeCAD is using VTK they must be creating this cube using VTK directly, not using file from disk.

I’m looking at source code right now.

I just cloned vtk-master from github. GitHub - Kitware/VTK: Mirror of Visualization Toolkit repository

How do I pull vtk-7 and vtk-8 so I can compare the code ? I don’t see marked release versions ?

they are tagged.

I’ll check again.

The main repo of vtk is at https://gitlab.kitware.com/vtk/vtk/ - the github clone may not have all the older tags.

1 Like

Ahhh ! That makes sense. Thanks for the tip.

I cannot find the nbPoints>=2 assert in the master code branch. I’m using $grep -r “nbPoints>=2” * and $grep -r “nbPoints” *

This assert is not from vtk source code, FreeCAD: SMDS_VtkEdge Class Reference


src/3rdParty/salomesmesh/src/SMDS/SMDS_VtkEdge.cpp: int nbPoints = grid->GetCell(myVtkID)->GetNumberOfPoints();
src/3rdParty/salomesmesh/src/SMDS/SMDS_VtkEdge.cpp: assert(nbPoints >= 2);
src/3rdParty/salomesmesh/src/SMDS/SMDS_VtkEdge.cpp: return nbPoints;

Does anything about this look suspicious to you ?

Line 115:

int SMDS_VtkEdge::NbNodes() const
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
int nbPoints = grid->GetCell(myVtkID)->GetNumberOfPoints();
assert(nbPoints >= 2);
return nbPoints;

Why would the code work with vtk-7,8 and return a good mesh and yet not work with vtk-9 ? FreeCAD-0.19 is passing the same meshlist to each version of vtk. Something must have changed in vtk-9 ?

I am going to build vtk-7 and 8 and test with them.