Skip to content
Snippets Groups Projects
vtk.cc 1.07 KiB
Newer Older
Elias Pipping's avatar
Elias Pipping committed
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include "vtk.hh"

template <class VertexBasis, class CellBasis, class VectorType,
          class SingletonVectorType, class GridView>
void writeVtk(VertexBasis vertexBasis, VectorType displacement,
              SingletonVectorType state, CellBasis cellBasis,
              SingletonVectorType stress, GridView gridView,
              std::string filename) {
  auto const displacement_ptr =
      Dune::make_shared<VTKBasisGridFunction<VertexBasis, VectorType> const>(
          vertexBasis, displacement, "displacement");
  auto const state_ptr = Dune::make_shared<
      VTKBasisGridFunction<VertexBasis, SingletonVectorType> const>(
      vertexBasis, state, "state");
  auto const vonmises_ptr = Dune::make_shared<
      VTKBasisGridFunction<CellBasis, SingletonVectorType> const>(
      cellBasis, stress, "stress");

  Dune::VTKWriter<GridView> writer(gridView);
  writer.addVertexData(state_ptr);
  writer.addVertexData(displacement_ptr);
  writer.addCellData(vonmises_ptr);

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

#include "vtk_tmpl.cc"