This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

JIT-compiled expression using vtk

0 votes

Trying to create a JIT-compiled expression that uses some VTK object. However, even with such a simple code as:

I0 = dolfin.Expression('''
#include <vtkSmartPointer.h>
#include <vtkPoints.h>

namespace dolfin
{

class MyFun : public Expression
{
    public:
        MyFun(): Expression()
        {
            points->InsertNextPoint(0.,0.,0.);
        };

    private:
        vtkSmartPointer<vtkPoints> points;
};

}''')

I'm getting some PETSC runtime error:

[0]PETSC ERROR: ------------------------------------------------------------------------
[0]PETSC ERROR: Caught signal number 11 SEGV: Segmentation Violation, probably memory access out of range
[0]PETSC ERROR: Try option -start_in_debugger or -on_error_attach_debugger
[0]PETSC ERROR: or see http://www.mcs.anl.gov/petsc/documentation/faq.html#valgrind
[0]PETSC ERROR: or try http://valgrind.org on GNU/linux and Apple Mac OS X to find memory corruption errors
[0]PETSC ERROR: configure using --with-debugging=yes, recompile, link, and run 
[0]PETSC ERROR: to get more information on the crash.
application called MPI_Abort(MPI_COMM_WORLD, 59) - process 0

If you comment the InsertNextPoint line then it runs fine, though nothing gets done of course. Any idea what might be going on? Thanks!

asked Feb 20, 2016 by Martin Genet FEniCS User (1,460 points)

1 Answer

+1 vote
 
Best answer

Have you tried to write the same code in C++? It might be that you
need to supply additional flags and libraries to the compiler. Instant previously supported complication with VTK etc, but this was not used much and currently it is broken. A working C++ example would be the first step to make it work.

answered Feb 20, 2016 by Kent-Andre Mardal FEniCS Expert (14,380 points)
selected Feb 22, 2016 by Martin Genet

My bad! The code should be:

I0 = dolfin.Expression('''
#include <vtkSmartPointer.h>
#include <vtkPoints.h>

namespace dolfin
{

class MyFun : public Expression
{
    public:
        MyFun(): Expression()
        {
            points->InsertNextPoint(0.,0.,0.);
        };

    private:
        vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
};

}''')

Thanks!

...