8#include <kernel/geometry/conformal_mesh.hpp> 
    9#include <kernel/geometry/mesh_part.hpp> 
   10#include <kernel/adjacency/graph.hpp> 
   21      template<
typename Shape_, 
int codim_>
 
   24        static constexpr int face_dim = Shape_::dimension - codim_;
 
   27        const TargetSet& _target_face;
 
   28        Adjacency::Graph _elem_at_face;
 
   29        std::vector<Index> _indices;
 
   32        explicit PatchHaloBuild(
const TargetSetHolder<Shape_>& tsh, 
const IndexSetHolder<Shape_>& ish) :
 
   33          _target_face(tsh.template get_target_set<face_dim>()),
 
   34          _elem_at_face(Adjacency::
RenderType::
transpose, ish.template get_index_set<Shape_::dimension, face_dim>())
 
   38        void build(
const Index halo_rank, 
const Adjacency::Graph& ranks_at_elem)
 
   43          for(Index face(0); face < _target_face.get_num_entities(); ++face)
 
   46            const Index base_face = _target_face[face];
 
   49            if(_has_face_rank(base_face, halo_rank, ranks_at_elem))
 
   51              _indices.push_back(face);
 
   58          return Index(_indices.size());
 
   61        void fill(TargetSet& target_set)
 const 
   63          XASSERT(target_set.get_num_entities() == size());
 
   64          for(Index i(0); i < size(); ++i)
 
   66            target_set[i] = _indices[i];
 
   71        bool _has_face_rank(
const Index base_face, 
const Index halo_rank, 
const Adjacency::Graph& ranks_at_elem)
 
   74          auto ib = _elem_at_face.image_begin(base_face);
 
   75          auto ie = _elem_at_face.image_end(base_face);
 
   76          for(
auto ii(ib); ii != ie; ++ii)
 
   79            auto jb = ranks_at_elem.image_begin(*ii);
 
   80            auto je = ranks_at_elem.image_end(*ii);
 
   81            for(
auto jj(jb); jj != je; ++jj)
 
   93      template<
typename Shape_>
 
   94      class PatchHaloBuild<Shape_, 0>
 
   97        const TargetSet& _target_face;
 
   98        std::vector<Index> _indices;
 
  101        explicit PatchHaloBuild(
const TargetSetHolder<Shape_>& tsh, 
const IndexSetHolder<Shape_>&) :
 
  102          _target_face(tsh.template get_target_set<Shape_::dimension>())
 
  106        void build(
const Index halo_rank, 
const Adjacency::Graph& ranks_at_elem)
 
  111          for(Index elem(0); elem < _target_face.get_num_entities(); ++elem)
 
  114            const Index base_elem = _target_face[elem];
 
  117            auto jb = ranks_at_elem.image_begin(base_elem);
 
  118            auto je = ranks_at_elem.image_end(base_elem);
 
  119            for(
auto jj(jb); jj != je; ++jj)
 
  124                _indices.push_back(elem);
 
  133          return Index(_indices.size());
 
  136        void fill(TargetSet& target_set)
 const 
  138          XASSERT(target_set.get_num_entities() == size());
 
  139          for(Index i(0); i < size(); ++i)
 
  141            target_set[i] = _indices[i];
 
  146      template<
typename Shape_, 
int face_dim_ = Shape_::dimension>
 
  147      class PatchHaloBuildWrapper :
 
  148        public PatchHaloBuildWrapper<Shape_, face_dim_ - 1>
 
  150        typedef PatchHaloBuildWrapper<Shape_, face_dim_ - 1> BaseClass;
 
  152        static constexpr int face_codim = Shape_::dimension - face_dim_;
 
  154        PatchHaloBuild<Shape_, face_codim> _hbuild;
 
  157        explicit PatchHaloBuildWrapper(
const TargetSetHolder<Shape_>& tsh, 
const IndexSetHolder<Shape_>& ish) :
 
  163        void build(
const Index halo_rank, 
const Adjacency::Graph& ranks_at_elem)
 
  165          BaseClass::build(halo_rank, ranks_at_elem);
 
  166          _hbuild.build(halo_rank, ranks_at_elem);
 
  169        Index get_num_entities(
int dim)
 const 
  173            return Index(_hbuild.size());
 
  175            return BaseClass::get_num_entities(dim);
 
  178        void fill(TargetSetHolder<Shape_>& tsh)
 const 
  180          BaseClass::fill(tsh);
 
  181          _hbuild.fill(tsh.template get_target_set<face_dim_>());
 
  185      template<
typename Shape_>
 
  186      class PatchHaloBuildWrapper<Shape_, 0>
 
  188        static constexpr int face_codim = Shape_::dimension;
 
  190        PatchHaloBuild<Shape_, face_codim> _hbuild;
 
  193        explicit PatchHaloBuildWrapper(
const TargetSetHolder<Shape_>& tsh, 
const IndexSetHolder<Shape_>& ish) :
 
  198        void build(
const Index halo_rank, 
const Adjacency::Graph& ranks_at_elem)
 
  200          _hbuild.build(halo_rank, ranks_at_elem);
 
  203        Index get_num_entities(
int dim)
 const 
  206          return Index(_hbuild.size());
 
  209        void fill(TargetSetHolder<Shape_>& tsh)
 const 
  211          _hbuild.fill(tsh.template get_target_set<0>());
 
  217    template<
typename Mesh_>
 
  231    template<
typename Shape_, 
int num_coords_, 
typename Coord_>
 
  233      public Factory<MeshPart<Geometry::ConformalMesh<Shape_, num_coords_, Coord_>>>
 
  236      typedef Shape_ ShapeType;
 
  237      static constexpr int shape_dim = ShapeType::dimension;
 
  255      Index _cur_halo_rank;
 
  256      Intern::PatchHaloBuildWrapper<ShapeType> _halo_wrapper;
 
  262        _ranks_at_elem(ranks_at_elem),
 
  263        _base_mesh(base_mesh),
 
  264        _patch_mesh_part(patch_mesh_part),
 
  266        _halo_wrapper(patch_mesh_part.get_target_set_holder(), base_mesh.get_index_set_holder())
 
  274      void build(
Index halo_rank)
 
  276        _halo_wrapper.build(halo_rank, _ranks_at_elem);
 
  283      virtual Index get_num_entities(
int dim)
 override 
  285        return _halo_wrapper.get_num_entities(dim);
 
  288      virtual void fill_attribute_sets(AttributeSetContainer&)
 override 
  293      virtual void fill_index_sets(std::unique_ptr<IndexSetHolderType>&)
 override 
  298      virtual void fill_target_sets(TargetSetHolderType& target_set_holder)
 override 
  300        _halo_wrapper.fill(target_set_holder);
 
#define XASSERT(expr)
Assertion macro definition.
Adjacency Graph implementation.
Mesh Factory class template.
Class template for partial meshes.
TargetSetHolder< ShapeType > TargetSetHolderType
Target set holder type.
IndexSetHolder< ShapeType > IndexSetHolderType
Index set holder type.
std::map< String, std::unique_ptr< AttributeSetType > > AttributeSetContainer
submesh node bin container type
RenderType
Render type enumeration.
@ transpose
Render-Transpose mode.
std::uint64_t Index
Index data type.