dune-vtk  0.2
parallelgridcreator.hh
Go to the documentation of this file.
1 #pragma once
2 
3 #include <cstdint>
4 #include <string>
5 #include <vector>
6 
7 #include <dune/grid/common/gridfactory.hh>
12 
13 namespace Dune
14 {
15  namespace Vtk
16  {
17  // create a distributed grid in parallel. Currently only supported by ALUGrid
18  template <class Grid>
20  : public DerivedGridCreator<ContinuousGridCreator<Grid>, ParallelGridCreator<Grid>>
21  {
26 
27  // The GridFactory must support insertion of global vertex IDs
28  static_assert(Std::is_detected<HasInsertVertex, GridFactory<Grid>, GlobalCoordinate, VertexId>{}, "");
29 
30  public:
31 
32  using Super::Super;
33 
34  void insertVerticesImpl (std::vector<GlobalCoordinate> const& points,
35  std::vector<std::uint64_t> const& point_ids)
36  {
37  assert(point_ids.size() == points.size());
38  for (std::size_t i = 0; i < points.size(); ++i)
39  this->factory().insertVertex(points[i], VertexId(point_ids[i]));
40  }
41 
42  void insertPiecesImpl (std::vector<std::string> const& pieces)
43  {
44  if (int(pieces.size()) == this->comm().size()) {
45  VtkReader<Grid, Self> pieceReader(this->factory());
46  pieceReader.read(pieces[this->comm().rank()], true);
47  }
48  }
49  };
50 
51  // deduction guides
52  template <class Grid>
53  ParallelGridCreator(GridFactory<Grid>&)
55 
56  } // end namespace Vtk
57 } // end namespace Dune
Definition: datacollectorinterface.hh:9
typename Impl::VertexIdType< GF >::type VertexId_t
Definition: gridcreators/common.hh:22
decltype(std::declval< Factory >().insertVertex(std::declval< Args >()...)) HasInsertVertex
Definition: gridcreators/common.hh:10
ParallelGridCreator(GridFactory< Grid > &) -> ParallelGridCreator< Grid >
auto comm() const
Return the mpi collective communicator.
Definition: gridcreatorinterface.hh:89
GridFactory< Grid > & factory()
Return the associated GridFactory.
Definition: gridcreatorinterface.hh:77
Definition: derivedgridcreator.hh:19
typename Super::GlobalCoordinate GlobalCoordinate
Definition: derivedgridcreator.hh:23
GridCreatorInterface< typename GridCreator::Grid, Derived > Super
Definition: derivedgridcreator.hh:21
Definition: parallelgridcreator.hh:21
void insertPiecesImpl(std::vector< std::string > const &pieces)
Definition: parallelgridcreator.hh:42
typename Super::GlobalCoordinate GlobalCoordinate
Definition: parallelgridcreator.hh:24
void insertVerticesImpl(std::vector< GlobalCoordinate > const &points, std::vector< std::uint64_t > const &point_ids)
Definition: parallelgridcreator.hh:34
VertexId_t< GridFactory< Grid > > VertexId
Definition: parallelgridcreator.hh:25
File-Reader for Vtk unstructured .vtu files.
Definition: vtkreader.hh:37
void read(std::string const &filename, bool fillCreator=true)
Read the grid from file with filename into the GridCreator.
Definition: vtkreader.impl.hh:20