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

VTKPlotter segmentation fault

+2 votes

Hello everybody,

I am using dolfin version 1.4.0 on a computer running Ubuntu 14.04. FEniCS was installed through the repository provided at http://fenicsproject.org/download/ubuntu_details.html .

I have a problem when trying to plot a Function with a VTKPlotter.
Take for example the following source code:
1) poisson.ufl

cell = triangle
V = FiniteElement ("Lagrange", cell, 1)

u = TrialFunction (V)
v = TestFunction (V)

f = Coefficient (V)

a = inner (grad (u), grad (v)) * dx

L = inner (f, v) * dx

2) main.cpp

#include <dolfin.h>
#include "poisson.h"

class MyExpression : public dolfin::Expression
{
    void eval (dolfin::Array<double>& values, const dolfin::Array<double>& x) const
    {
        values[0] = x[0];
    }
};

int main (int argc, char* argv[])
{
    dolfin::UnitSquareMesh mesh (10, 10);
    poisson::FunctionSpace V (mesh);

    MyExpression myExpression;
    dolfin::Function myFunction (V);
    myFunction = myExpression;

    std::cout << "Plotting mesh..." << std::endl;
    dolfin::VTKPlotter meshPlotter (dolfin::reference_to_no_delete_pointer (mesh));
    meshPlotter.plot ();

    std::cout << "Plotting function..." << std::endl;
    dolfin::VTKPlotter functionPlotter (dolfin::reference_to_no_delete_pointer (myFunction));
    functionPlotter.plot ();

    return 0;
}

Why is it that I can plot the mesh just fine but the call to functionPlotter.plot() generates a segmentation fault? What am I doing wrong?

Thanks a lot!

Mattia

asked Dec 30, 2014 by mattia_ FEniCS Novice (270 points)
...