1#ifndef DUNE_MULTIDOMAINGRID_GMSHREADERPARSER_HH
2#define DUNE_MULTIDOMAINGRID_GMSHREADERPARSER_HH
4#include <dune/common/exceptions.hh>
11template<
typename HostGr
id,
typename MDGr
idTraits>
17template<
typename Gr
idType>
18class GmshReaderParser;
20template<
class HostGr
id,
class MDGTraits>
21class GmshReaderParser<Dune::mdgrid::MultiDomainGrid<HostGrid, MDGTraits>> :
public Dune::GmshReaderParser<HostGrid> {
26 GmshReaderParser(Dune::GridFactory<Grid>& factory,
bool v,
bool i)
27 : Dune::GmshReaderParser<HostGrid>{factory.hostGridFactory(), v, i}
31 void read (
const std::string& f)
33 Dune::GmshReaderParser<HostGrid>::read(f);
35 const auto& sub_domain_ids = this->elementIndexMap();
36 if (begin(sub_domain_ids) == end(sub_domain_ids))
39 *std::max_element(begin(sub_domain_ids), end(sub_domain_ids));
40 if (max_subdomains < 1)
42 "Gmsh phisical entity indices are 1-index based, but a 0 "
44 _factory.makeGrid(max_subdomains);
45 auto& grid = _factory.grid();
47 grid.startSubDomainMarking();
49 for (
const auto& cell : elements(grid.leafGridView())) {
50 assert(sub_domain_ids[i] != 0);
51 grid.addToSubDomain(sub_domain_ids[i] - 1, cell), i++;
54 grid.preUpdateSubDomains();
55 grid.updateSubDomains();
56 grid.postUpdateSubDomains();
60 Dune::GridFactory<Grid>& _factory;
A meta grid for dividing an existing DUNE grid into subdomains that can be accessed as a grid in thei...
Definition: multidomaingrid.hh:243