9#include <kernel/geometry/index_set.hpp> 
   10#include <kernel/geometry/target_set.hpp> 
   25        int shape_dim_ = Shape_::dimension,
 
   26        int cell_dim_ = shape_dim_>
 
   27      class BoundaryFaceComputer :
 
   28        public BoundaryFaceComputer<Shape_, shape_dim_, cell_dim_-1>
 
   31        typedef BoundaryFaceComputer<Shape_, shape_dim_, cell_dim_-1> BaseClass;
 
   32        typedef std::array<std::vector<int>, std::size_t(shape_dim_)> BndMasksType;
 
   33        typedef std::array<std::vector<Index>, std::size_t(shape_dim_)> FaceIdxType;
 
   36        template<
typename ParentIndexSetHolder_>
 
   37        void _compute_mask(
const ParentIndexSetHolder_& index_set_holder, BndMasksType& bnd_masks, 
const std::vector<Index>& facets)
 
   43          std::vector<int>& mask = bnd_masks.at(std::size_t(cell_dim_-1));
 
   45          const auto& face_index_set = index_set_holder.template get_index_set<shape_dim_-1, cell_dim_-1>();
 
   49          mask.resize(face_index_set.get_index_bound(), 0);
 
   52          for(Index i(0); i < 
Index(facets.size()); ++i)
 
   54            for(
int j(0); j < face_index_set.get_num_indices(); ++j)
 
   55              ++mask[face_index_set(facets[i], j)];
 
   58          BaseClass::_compute_mask(index_set_holder, bnd_masks, facets);
 
   61        void _compute_faces(
const BndMasksType& bnd_masks, FaceIdxType& face_idx)
 
   64          const std::vector<int>& mask = bnd_masks.at(std::size_t(cell_dim_-1));
 
   65          std::vector<Index>& faces = face_idx.at(std::size_t(cell_dim_-1));
 
   69          for(Index i(0); i < 
Index(mask.size()); ++i)
 
   77          for(Index i(0); i < 
Index(mask.size()); ++i)
 
   84          BaseClass::_compute_faces(bnd_masks, face_idx);
 
   88        void fill_target_sets(TargetSetHolder<Shape_>& target_set_holder, 
const FaceIdxType& face_idx)
 
   90          const std::vector<Index>& faces = face_idx.at(std::size_t(cell_dim_-1)) ;
 
   92          TargetSet& target_set = target_set_holder.template get_target_set<cell_dim_-1>();
 
   93          XASSERTM(target_set.get_num_entities() == 
Index(faces.size()), 
"invalid target set size");
 
   95          for(Index i(0); i < target_set.get_num_entities(); ++i)
 
   96            target_set[i] = faces[i];
 
   98          BaseClass::fill_target_sets(target_set_holder, face_idx);
 
  101        Index build_halo_buffer(std::vector<int>& buffer, 
const BndMasksType& bnd_masks, 
const TargetSetHolder<Shape_>& halo_trg_holder)
 
  103          Index offset = BaseClass::build_halo_buffer(buffer, bnd_masks, halo_trg_holder);
 
  104          const TargetSet& target_set = halo_trg_holder.template get_target_set<cell_dim_-1>();
 
  105          const std::vector<int>& mask = bnd_masks.at(std::size_t(cell_dim_-1));
 
  106          for(Index i(0); i < target_set.get_num_entities(); ++i, ++offset)
 
  107            buffer[offset] = mask[target_set[i]];
 
  111        Index mask_halo_buffer(BndMasksType& bnd_masks, 
const std::vector<int>& buffer, 
const TargetSetHolder<Shape_>& halo_trg_holder)
 
  113          Index offset = BaseClass::mask_halo_buffer(bnd_masks, buffer, halo_trg_holder);
 
  114          const TargetSet& target_set = halo_trg_holder.template get_target_set<cell_dim_-1>();
 
  115          std::vector<int>& mask = bnd_masks.at(std::size_t(cell_dim_-1));
 
  116          for(Index i(0); i < target_set.get_num_entities(); ++i, ++offset)
 
  118            if(buffer[offset] != 0)
 
  119              mask[target_set[i]] = 1;
 
  126      template<
typename Shape_, 
int shape_dim_>
 
  127      class BoundaryFaceComputer<Shape_, shape_dim_, shape_dim_> :
 
  128        public BoundaryFaceComputer<Shape_, shape_dim_, shape_dim_-1>
 
  130        typedef BoundaryFaceComputer<Shape_, shape_dim_, shape_dim_-1> BaseClass;
 
  131        typedef std::array<std::vector<int>, std::size_t(shape_dim_)> BndMasksType;
 
  132        typedef std::array<std::vector<Index>, std::size_t(shape_dim_)> FaceIdxType;
 
  135        template<
typename ParentIndexSetHolder_>
 
  136        void compute_all(
const ParentIndexSetHolder_& index_set_holder, BndMasksType& bnd_masks, FaceIdxType& face_idx)
 
  139          std::vector<int>& mask = bnd_masks.at(std::size_t(shape_dim_-1));
 
  140          std::vector<Index>& faces = face_idx.at(std::size_t(shape_dim_-1));
 
  147          const auto& face_index_set = index_set_holder.template get_index_set<shape_dim_, shape_dim_-1>();
 
  151          mask.resize(face_index_set.get_index_bound(), 0);
 
  154          for(Index i(0); i < face_index_set.get_num_entities(); ++i)
 
  157            for(
int j(0); j < face_index_set.get_num_indices(); ++j)
 
  158              ++mask[face_index_set(i,j)];
 
  163          for(Index i(0); i < 
Index(mask.size()); ++i)
 
  166            ASSERTM((mask[i] > 0) && (mask[i] < 3), 
"invalid number of cells at facet");
 
  172          faces.reserve(count);
 
  173          for(Index i(0); i < 
Index(mask.size()); ++i)
 
  181          BaseClass::_compute_mask(index_set_holder, bnd_masks, face_idx.back());
 
  182          BaseClass::_compute_faces(bnd_masks, face_idx);
 
  185        template<
typename ParentIndexSetHolder_>
 
  186        void compute_masks(
const ParentIndexSetHolder_& index_set_holder, BndMasksType& bnd_masks, FaceIdxType& face_idx, 
const std::vector<int>& facet_mask)
 
  189          std::vector<int>& mask = bnd_masks.at(std::size_t(shape_dim_-1));
 
  190          std::vector<Index>& faces = face_idx.at(std::size_t(shape_dim_-1));
 
  197          const auto& face_index_set = index_set_holder.template get_index_set<shape_dim_, shape_dim_-1>();
 
  201          mask.resize(face_index_set.get_index_bound(), 0);
 
  204          for(Index i(0); i < face_index_set.get_num_entities(); ++i)
 
  207            for(
int j(0); j < face_index_set.get_num_indices(); ++j)
 
  208              ++mask[face_index_set(i,j)];
 
  212          XASSERTM(facet_mask.size() == mask.size(), 
"invalid mask vector size");
 
  213          for(std::size_t i(0); i < mask.size(); ++i)
 
  214            mask[i] = (facet_mask[i] != 0 ? 0 : mask[i]);
 
  218          for(Index i(0); i < 
Index(mask.size()); ++i)
 
  221            ASSERTM((facet_mask[i] != 0) || ((mask[i] > 0) && (mask[i] < 3)), 
"invalid number of cells at facet");
 
  227          faces.reserve(count);
 
  228          for(Index i(0); i < 
Index(mask.size()); ++i)
 
  234          BaseClass::_compute_mask(index_set_holder, bnd_masks, faces);
 
  237        void compute_faces(
const BndMasksType& bnd_masks, FaceIdxType& face_idx)
 
  240          BaseClass::_compute_faces(bnd_masks, face_idx);
 
  243        void fill_target_sets(TargetSetHolder<Shape_>& target_set_holder, 
const FaceIdxType& face_idx)
 
  245          const std::vector<Index>& faces = face_idx.at(std::size_t(shape_dim_-1));
 
  247          TargetSet& target_set = target_set_holder.template get_target_set<shape_dim_-1>();
 
  248          XASSERTM(target_set.get_num_entities() == 
Index(faces.size()), 
"invalid target set size");
 
  250          for(Index i(0); i < target_set.get_num_entities(); ++i)
 
  251            target_set[i] = faces[i];
 
  253          BaseClass::fill_target_sets(target_set_holder, face_idx);
 
  256        Index build_halo_buffer(std::vector<int>& buffer, 
const BndMasksType& bnd_masks, 
const TargetSetHolder<Shape_>& halo_trg_holder)
 
  258          Index offset = BaseClass::build_halo_buffer(buffer, bnd_masks, halo_trg_holder);
 
  259          const TargetSet& target_set = halo_trg_holder.template get_target_set<shape_dim_-1>();
 
  260          const std::vector<int>& mask = bnd_masks.at(std::size_t(shape_dim_-1));
 
  261          for(Index i(0); i < target_set.get_num_entities(); ++i, ++offset)
 
  262            buffer[offset] = mask[target_set[i]];
 
  266        Index mask_halo_buffer(BndMasksType& bnd_masks, 
const std::vector<int>& buffer, 
const TargetSetHolder<Shape_>& halo_trg_holder)
 
  268          Index offset = BaseClass::mask_halo_buffer(bnd_masks, buffer, halo_trg_holder);
 
  269          const TargetSet& target_set = halo_trg_holder.template get_target_set<shape_dim_-1>();
 
  270          std::vector<int>& mask = bnd_masks.at(std::size_t(shape_dim_-1));
 
  271          for(Index i(0); i < target_set.get_num_entities(); ++i, ++offset)
 
  273            if(buffer[offset] == 1)
 
  274              mask[target_set[i]] = 1;
 
  281      template<
typename Shape_, 
int shape_dim_>
 
  282      class BoundaryFaceComputer<Shape_, shape_dim_, 0>
 
  285        typedef std::array<std::vector<int>, std::size_t(shape_dim_)> BndMasksType;
 
  286        typedef std::array<std::vector<Index>, std::size_t(shape_dim_)> FaceIdxType;
 
  288        template<
typename ParentIndexSetHolder_>
 
  289        void _compute_mask(
const ParentIndexSetHolder_&, BndMasksType&, 
const std::vector<Index>&)
 
  294        void _compute_faces(
const BndMasksType&, FaceIdxType&)
 
  300        void fill_target_sets(TargetSetHolder<Shape_>&, 
const FaceIdxType&)
 
  305        Index build_halo_buffer(std::vector<int>&, 
const BndMasksType&, 
const TargetSetHolder<Shape_>&)
 
  310        Index mask_halo_buffer(BndMasksType&, 
const std::vector<int>&, 
const TargetSetHolder<Shape_>&)
 
#define ASSERTM(expr, msg)
Debug-Assertion macro definition with custom message.
#define XASSERTM(expr, msg)
Assertion macro definition with custom message.
std::uint64_t Index
Index data type.