#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include "vtk.hh"

template <class VertexBasis, class CellBasis, class VectorType,
          class SingletonVectorType>
void writeVtk(VertexBasis const &vertexBasis, VectorType const &displacement,
              SingletonVectorType const &logState, CellBasis const &cellBasis,
              SingletonVectorType const &stress, std::string const &filename) {
  Dune::VTKWriter<typename VertexBasis::GridView> writer(
      vertexBasis.getGridView());

  auto const displacementPointer =
      Dune::make_shared<VTKBasisGridFunction<VertexBasis, VectorType> const>(
          vertexBasis, displacement, "displacement");
  writer.addVertexData(displacementPointer);

  auto const logStatePointer = Dune::make_shared<
      VTKBasisGridFunction<VertexBasis, SingletonVectorType> const>(
      vertexBasis, logState, "logState");
  writer.addVertexData(logStatePointer);

  auto const vonmisesPointer = Dune::make_shared<
      VTKBasisGridFunction<CellBasis, SingletonVectorType> const>(
      cellBasis, stress, "stress");
  writer.addCellData(vonmisesPointer);

  writer.write(filename.c_str());
}

#include "vtk_tmpl.cc"