31#ifndef OPM_PARENTTOCHILDCELLTOPOINTGLOBALIDHANDLE_HEADER
32#define OPM_PARENTTOCHILDCELLTOPOINTGLOBALIDHANDLE_HEADER
34#include <opm/grid/common/CommunicationUtils.hpp>
35#include <opm/grid/cpgrid/Entity.hpp>
47struct ParentToChildCellToPointGlobalIdHandle {
67 ParentToChildCellToPointGlobalIdHandle(
const Dune::CpGrid::Communication& comm,
68 const std::vector<std::tuple<
int, std::vector<int>>>& parent_to_children,
69 const std::vector<std::vector<std::array<int,8>>>& level_cell_to_point,
70 std::vector<std::vector<DataType>>& level_winning_ranks,
71 std::vector<std::vector<DataType>>& level_point_global_ids)
73 , parent_to_children_(parent_to_children)
74 , level_cell_to_point_(level_cell_to_point)
75 , level_winning_ranks_(level_winning_ranks)
76 , level_point_global_ids_(level_point_global_ids)
79 bool fixedSize(std::size_t, std::size_t)
85 bool contains(std::size_t, std::size_t codim)
92 std::size_t size(
const T& element)
96 const auto& [level, children] = parent_to_children_[element.index()];
100 if ( (element.partitionType() != Dune::InteriorEntity) || (level == -1))
102 return 1 + ( 8*children.size());
106 template <
class B,
class T>
107 void gather(B& buffer,
const T& element)
110 const auto& [level, children] = parent_to_children_[element.index()];
114 if ( (element.partitionType() != Dune::InteriorEntity) || (level==-1)) {
122 buffer.write( comm_.rank() );
123 for (
const auto& child : children)
124 for (const auto& corner : level_cell_to_point_[level -1][child])
125 buffer.write(level_point_global_ids_[level-1][corner]);
129 template <
class B,
class T>
130 void scatter(B& buffer,
const T& element, std::size_t size)
132 const auto& [level, children] = parent_to_children_[element.index()];
135 if ( ( (element.partitionType() == Dune::OverlapEntity) && (level==-1) ) || (element.partitionType() == Dune::InteriorEntity ) ) {
138 for (std::size_t received_int = 0; received_int < size; ++received_int) {
146 assert(children.size()>0);
150 buffer.read(tmp_rank);
151 for (
const auto& child : children) {
152 for (
const auto& corner : level_cell_to_point_[level -1][child]) {
153 auto& min_rank = level_winning_ranks_[level-1][corner];
155 if (tmp_rank < min_rank) {
157 auto& target_entry = level_point_global_ids_[level-1][corner];
158 buffer.read(target_entry);
161 buffer.read(rubbish);
169 const Dune::CpGrid::Communication& comm_;
170 const std::vector<std::tuple<int, std::vector<int>>>& parent_to_children_;
171 const std::vector<std::vector<std::array<int,8>>>& level_cell_to_point_;
172 std::vector<std::vector<DataType>>& level_winning_ranks_;
173 std::vector<std::vector<DataType>>& level_point_global_ids_;