Cannot interpolate point data function obtained from VtkReader
I am trying to read a grid with a point-based vector field using VtkReader
, and obtain the values of the vector field at the grid nodes. As the object returned by VtkReader::getPointData
is a grid function I need to call Functions::interpolate
with a Lagrange basis to get the actual point values. [Is that correct? The documentation doesn't mention interpolate
explicitely, but I see no other way to get the point values.]
Anyway, this doesn't compile, because interpolate
apparently wants to call derivative
for the function returend by getPointData
, which is not implemented. Here is my test program:
#include <config.h>
#include <dune/functions/functionspacebases/interpolate.hh>
#include <dune/functions/functionspacebases/lagrangebasis.hh>
#include <dune/functions/functionspacebases/powerbasis.hh>
#include <dune/grid/uggrid.hh>
#include <dune/vtk/vtkreader.hh>
using namespace Dune;
int main ()
{
constexpr int dim = 3;
using Grid = UGGrid<dim>;
// Read the grid
Vtk::VtkReader<Grid> vtkReader;
vtkReader.read("my_file");
auto grid = vtkReader.createGrid();
using namespace Functions::BasisFactory;
auto basis = makeBasis(
grid->leafGridView(),
power<dim>(
lagrange<1>()
));
// Read vector-valued point data
auto displacementPointData = vtkReader.getPointData("displacement");
// Interpolate to get the vector of coefficients
std::vector<FieldVector<double,dim> > displacement(basis.size());
Functions::interpolate(basis, displacement, displacementPointData);
}
Am I doing something wrong here?