diff --git a/dumux/io/grid/griddata.hh b/dumux/io/grid/griddata.hh index 82ea57ac84f135e78a3563404863f1d93b753a44..cfaff4c911879b4521af482dfdcacd424675c4e2 100644 --- a/dumux/io/grid/griddata.hh +++ b/dumux/io/grid/griddata.hh @@ -30,6 +30,7 @@ #endif #include "gmshgriddatahandle.hh" +#include "vtkgriddatahandle.hh" namespace Dumux { @@ -55,7 +56,8 @@ class GridData using Intersection = typename Grid::LeafIntersection; using Element = typename Grid::template Codim<0>::Entity; using Vertex = typename Grid::template Codim<Grid::dimension>::Entity; - using DataHandle = GmshGridDataHandle<Grid, Dune::GridFactory<Grid>, std::vector<int>>; + using GmshDataHandle = GmshGridDataHandle<Grid, Dune::GridFactory<Grid>, std::vector<int>>; + using VtkDataHandle = VtkGridDataHandle<Grid, Dune::GridFactory<Grid>, std::vector<double>>; enum DataSourceType { dgf, gmsh, vtk }; @@ -77,7 +79,7 @@ public: , dataSourceType_(DataSourceType::dgf) {} - //! constructor for gmsh grid data + //! constructor for VTK grid data GridData(std::shared_ptr<Grid> grid, std::shared_ptr<Dune::GridFactory<Grid>> factory, VTKReader::Data&& cellData, VTKReader::Data&& pointData) : gridPtr_(grid) @@ -210,9 +212,9 @@ public: * \note this data handle is the default */ template<bool ug = Detail::isUG<Grid>::value, typename std::enable_if_t<!ug, int> = 0> - DataHandle createGmshDataHandle() + GmshDataHandle createGmshDataHandle() { - return DataHandle(*gridPtr_, *gridFactory_, elementMarkers_, boundaryMarkers_, faceMarkers_); + return GmshDataHandle(*gridPtr_, *gridFactory_, elementMarkers_, boundaryMarkers_, faceMarkers_); } /*! @@ -220,9 +222,9 @@ public: * \note this data handle is the specialized for UGGrid since UGGrid can't communicate element data (yet) */ template<bool ug = Detail::isUG<Grid>::value, typename std::enable_if_t<ug, int> = 0> - DataHandle createGmshDataHandle() + GmshDataHandle createGmshDataHandle() { - return DataHandle(*gridPtr_, *gridFactory_, elementMarkers_, boundaryMarkers_); + return GmshDataHandle(*gridPtr_, *gridFactory_, elementMarkers_, boundaryMarkers_); } // \} @@ -250,7 +252,10 @@ public: while (level0element.hasFather()) level0element = level0element.father(); - return cellData_.at(fieldName)[gridFactory_->insertionIndex(level0element)]; + if (gridPtr_->comm().size() > 1) + return cellData_.at(fieldName)[gridPtr_->levelGridView(0).indexSet().index(level0element)]; + else + return cellData_.at(fieldName)[gridFactory_->insertionIndex(level0element)]; } /*! @@ -270,7 +275,18 @@ public: if (pointData_.count(fieldName) == 0) DUNE_THROW(Dune::IOError, "No field with the name " << fieldName << " found in point data"); - return pointData_.at(fieldName)[gridFactory_->insertionIndex(vertex)]; + if (gridPtr_->comm().size() > 1) + return pointData_.at(fieldName)[gridPtr_->levelGridView(0).indexSet().index(vertex)]; + else + return pointData_.at(fieldName)[gridFactory_->insertionIndex(vertex)]; + } + + /*! + * \brief Create a data handle for communication of the data in parallel simulations + */ + VtkDataHandle createVtkDataHandle() + { + return VtkDataHandle(*gridPtr_, *gridFactory_, cellData_, pointData_); } // \}