32#ifndef OPM_PARENTTOCHILDRENCELLGLOBALIDHANDLE_HEADER
33#define OPM_PARENTTOCHILDRENCELLGLOBALIDHANDLE_HEADER
36#include <opm/grid/cpgrid/Entity.hpp>
47struct ParentToChildrenCellGlobalIdHandle {
63 ParentToChildrenCellGlobalIdHandle(
const std::vector<std::tuple<
int, std::vector<int>>>& parent_to_children,
64 std::vector<std::vector<DataType>>& level_cell_global_ids)
65 : parent_to_children_(parent_to_children)
66 , level_cell_global_ids_(level_cell_global_ids)
71 bool fixedSize(std::size_t, std::size_t)
76 bool contains(std::size_t, std::size_t codim)
82 std::size_t size(
const T& element)
85 const auto& [level, children] = parent_to_children_[element.index()];
89 if ( (element.partitionType() != Dune::InteriorEntity) || (level == -1))
91 return children.size();
95 template <
class B,
class T>
96 void gather(B& buffer,
const T& element)
99 const auto& [level, children] = parent_to_children_[element.index()];
103 if ( (element.partitionType() != Dune::InteriorEntity) || (level==-1)) {
108 for (
const auto& child : children)
111 buffer.write(level_cell_global_ids_[level-1][child]);
115 template <
class B,
class T>
116 void scatter(B& buffer,
const T& element, std::size_t num_children)
118 const auto& [level, children] = parent_to_children_[element.index()];
121 if ( ( (element.partitionType() == Dune::OverlapEntity) && (level==-1) ) || (element.partitionType() == Dune::InteriorEntity ) ) {
124 for (std::size_t child = 0; child < num_children; ++child) {
133 assert(children.size()>0);
135 for (
const auto& child : children) {
138 auto& target_entry = level_cell_global_ids_[level-1][child];
139 buffer.read(target_entry);
145 const std::vector<std::tuple<int, std::vector<int>>>& parent_to_children_;
146 std::vector<std::vector<DataType>>& level_cell_global_ids_;