9#include <kernel/geometry/mesh_part.hpp> 
   10#include <kernel/geometry/conformal_mesh.hpp> 
   11#include <kernel/geometry/structured_mesh.hpp> 
   12#include <kernel/geometry/shape_convert_factory.hpp> 
   27    template<
typename Mesh_>
 
   31    template<
typename Coord_>
 
   33      public Factory< ConformalMesh<Shape::Hypercube<1>, 1, Coord_> >
 
   39      typedef typename MeshType::VertexSetType VertexSetType;
 
   41      typedef typename MeshType::IndexSetHolderType IndexSetHolderType;
 
   48      virtual Index get_num_entities(
int dim)
 override 
   50        return Index(2 - dim);
 
   53      virtual void fill_vertex_set(VertexSetType& vertex_set)
 override 
   55        vertex_set[0][0] = Coord_(0);
 
   56        vertex_set[1][0] = Coord_(1);
 
   59      virtual void fill_index_sets(IndexSetHolderType& index_set_holder)
 override 
   61        IndexSet<2>& v_e(index_set_holder.template get_index_set<1,0>());
 
   67    template<
typename Coord_>
 
   68    class UnitCubeFactory< ConformalMesh<Shape::Hypercube<2>, 2, Coord_> > :
 
   69      public Factory< ConformalMesh<Shape::Hypercube<2>, 2, Coord_> >
 
   73      typedef Shape::Hypercube<2> ShapeType;
 
   75      typedef ConformalMesh<Shape::Hypercube<2>, 2, Coord_> MeshType;
 
   77      typedef typename MeshType::VertexSetType VertexSetType;
 
   79      typedef typename MeshType::IndexSetHolderType IndexSetHolderType;
 
   86      virtual Index get_num_entities(
int dim)
 override 
  101      virtual void fill_vertex_set(VertexSetType& vertex_set)
 override 
  103        for(
Index i(0); i < 4u; ++i)
 
  105          for(
int j(0); j < 2; ++j)
 
  107            vertex_set[i][j] = Coord_((i >> j) & 0x1);
 
  112      virtual void fill_index_sets(IndexSetHolderType& index_set_holder)
 override 
  114        _fill_sub_index_set<1,0>(index_set_holder);
 
  115        _fill_cell_index_set<0>(index_set_holder);
 
  116        _fill_cell_index_set<1>(index_set_holder);
 
  120      template<
int cell_dim_, 
int face_dim_>
 
  121      static void _fill_sub_index_set(IndexSetHolderType& index_set_holder)
 
  123        typedef typename Intern::FaceIndexMapping<ShapeType, cell_dim_, face_dim_> FimType;
 
  124        typename IndexSetHolderType::template IndexSet<cell_dim_, face_dim_>::Type&
 
  125          idx(index_set_holder.template get_index_set<cell_dim_, face_dim_>());
 
  127        for(
int i(0); i < Shape::FaceTraits<ShapeType, cell_dim_>::count; ++i)
 
  129          for(
int j(0); j < idx.num_indices; ++j)
 
  136      template<
int face_dim_>
 
  137      static void _fill_cell_index_set(IndexSetHolderType& index_set_holder)
 
  139        typename IndexSetHolderType::template IndexSet<2, face_dim_>::Type&
 
  140          idx(index_set_holder.template get_index_set<2, face_dim_>());
 
  141        for(
int j(0); j < idx.num_indices; ++j)
 
  143          idx[0][j] = 
Index(j);
 
  148    template<
typename Coord_>
 
  149    class UnitCubeFactory< ConformalMesh<Shape::Hypercube<3>, 3, Coord_> > :
 
  150      public Factory< ConformalMesh<Shape::Hypercube<3>, 3, Coord_> >
 
  154      typedef Shape::Hypercube<3> ShapeType;
 
  156      typedef ConformalMesh<Shape::Hypercube<3>, 3, Coord_> MeshType;
 
  158      typedef typename MeshType::VertexSetType VertexSetType;
 
  160      typedef typename MeshType::IndexSetHolderType IndexSetHolderType;
 
  167      virtual Index get_num_entities(
int dim)
 override 
  184      virtual void fill_vertex_set(VertexSetType& vertex_set)
 override 
  186        for(
Index i(0); i < 8u; ++i)
 
  188          for(
int j(0); j < 3; ++j)
 
  190            vertex_set[i][j] = Coord_((i >> j) & 0x1);
 
  195      virtual void fill_index_sets(IndexSetHolderType& index_set_holder)
 override 
  197        _fill_sub_index_set<1,0>(index_set_holder);
 
  198        _fill_sub_index_set<2,0>(index_set_holder);
 
  199        _fill_sub_index_set<2,1>(index_set_holder);
 
  200        _fill_cell_index_set<0>(index_set_holder);
 
  201        _fill_cell_index_set<1>(index_set_holder);
 
  202        _fill_cell_index_set<2>(index_set_holder);
 
  206      template<
int cell_dim_, 
int face_dim_>
 
  207      static void _fill_sub_index_set(IndexSetHolderType& index_set_holder)
 
  209        typedef typename Intern::FaceIndexMapping<ShapeType, cell_dim_, face_dim_> FimType;
 
  210        typename IndexSetHolderType::template IndexSet<cell_dim_, face_dim_>::Type&
 
  211          idx(index_set_holder.template get_index_set<cell_dim_, face_dim_>());
 
  213        for(
int i(0); i < Shape::FaceTraits<ShapeType, cell_dim_>::count; ++i)
 
  215          for(
int j(0); j < idx.num_indices; ++j)
 
  222      template<
int face_dim_>
 
  223      static void _fill_cell_index_set(IndexSetHolderType& index_set_holder)
 
  225        typename IndexSetHolderType::template IndexSet<3, face_dim_>::Type&
 
  226          idx(index_set_holder.template get_index_set<3, face_dim_>());
 
  227        for(
int j(0); j < idx.num_indices; ++j)
 
  235    class UnitCubeFactory< MeshPart<ConformalMesh<Shape::Hypercube<2> > > >:
 
  236    public Factory< MeshPart<ConformalMesh<Shape::Hypercube<2> > > >
 
  239      typedef Shape::Hypercube<2> ShapeType;
 
  241      typedef MeshPart<ConformalMesh<ShapeType>> MeshType;
 
  243      typedef MeshType::TargetSetHolderType TargetSetHolderType;
 
  246      virtual Index get_num_entities(
int dim)
 override 
  259      virtual void fill_target_sets(TargetSetHolderType& target_set_holder)
 override 
  262        TargetSet& vi(target_set_holder.get_target_set<0>());
 
  269        TargetSet& ei(target_set_holder.get_target_set<1>());
 
  286    template<
typename Coord_, 
int dim_>
 
  287    class UnitCubeFactory< ConformalMesh<Shape::Simplex<dim_>, dim_, Coord_> > :
 
  288      public Factory< ConformalMesh<Shape::Simplex<dim_>, dim_, Coord_> >
 
  292      typedef ConformalMesh<Shape::Simplex<dim_>, dim_, Coord_> MeshType;
 
  294      typedef typename MeshType::VertexSetType VertexSetType;
 
  296      typedef typename MeshType::IndexSetHolderType IndexSetHolderType;
 
  300      typedef ShapeConvertFactory<MeshType> FactoryType;
 
  302      typedef ConformalMesh<Shape::Hypercube<dim_>, dim_, Coord_> GeneratorMeshType;
 
  304      GeneratorMeshType* _generator_mesh;
 
  305      FactoryType* _factory;
 
  309        _generator_mesh(nullptr),
 
  312        UnitCubeFactory<GeneratorMeshType> cube_factory;
 
  313        _generator_mesh = 
new GeneratorMeshType(cube_factory);
 
  314        _factory = 
new FactoryType(*_generator_mesh);
 
  317      virtual ~UnitCubeFactory()
 
  319        delete _generator_mesh;
 
  323      virtual Index get_num_entities(
int dim)
 override 
  325        return _factory->get_num_entities(dim);
 
  328      virtual void fill_vertex_set(VertexSetType& vertex_set)
 override 
  330        _factory->fill_vertex_set(vertex_set);
 
  333      virtual void fill_index_sets(IndexSetHolderType& index_set_holder)
 override 
  335        _factory->fill_index_sets(index_set_holder);
 
  339    template<
int dim_, 
typename Coord_>
 
  340    class UnitCubeFactory< StructuredMesh<dim_, dim_, Coord_> > :
 
  341      public Factory< StructuredMesh<dim_, dim_, Coord_> >
 
  345      typedef Shape::Hypercube<dim_> ShapeType;
 
  347      typedef StructuredMesh<dim_, dim_, Coord_> MeshType;
 
  349      typedef typename MeshType::VertexSetType VertexSetType;
 
  355      explicit UnitCubeFactory(
Index level = 
Index(0)) :
 
  360      virtual Index get_num_slices(
int DOXY(dir))
 override 
  362        return (
Index(1) << _level); 
 
  365      virtual void fill_vertex_set(VertexSetType& vertex_set)
 override 
  368        const Coord_ sc = Coord_(1) / Coord_(
Index(1) << _level); 
 
  374        const Index nv = vertex_set.get_num_vertices();
 
  376        for(
Index i(0); i < nv; ++i)
 
  379          auto& v = vertex_set[i];
 
  380          for(
int j(0); j < dim_; ++j, k /= nx)
 
  382            v[j] = Coord_(k % nx) * sc;
 
  402    template<
typename Mesh_, 
template<
typename> 
class Factory_>
 
  406    template<
typename Shape_, 
int num_coords_, 
typename Coord_, 
template<
typename> 
class Factory_>
 
  408      public Factory< ConformalMesh<Shape_, num_coords_, Coord_> >
 
  412      typedef typename MeshType::VertexSetType VertexSetType;
 
  413      typedef typename MeshType::IndexSetHolderType IndexSetHolderType;
 
  417      typedef Factory_<MeshType> MyFactoryType;
 
  420      MeshType* _coarse_mesh;
 
  421      MeshFactory* _factory;
 
  424      template<
typename... Arguments>
 
  426        _coarse_mesh(nullptr),
 
  431          _factory = 
new MyFactoryType(std::forward<Arguments>(args)...);
 
  436        MyFactoryType my_factory(std::forward<Arguments>(args)...);
 
  437        _coarse_mesh = 
new MeshType(my_factory);
 
  440        _factory = 
new Refinery(*_coarse_mesh);
 
  443        for(
Index i(1); i < num_refines; ++i)
 
  446          MeshType* mesh_old = _coarse_mesh;
 
  448          _coarse_mesh = 
new MeshType(*_factory);
 
  454          _factory = 
new Refinery(*_coarse_mesh);
 
  458      virtual ~RefineFactory()
 
  460        if(_factory != 
nullptr)
 
  464        if(_coarse_mesh != 
nullptr)
 
  470      virtual Index get_num_entities(
int dim)
 override 
  472        return _factory->get_num_entities(dim);
 
  475      virtual void fill_vertex_set(VertexSetType& vertex_set)
 override 
  477        _factory->fill_vertex_set(vertex_set);
 
  480      virtual void fill_index_sets(IndexSetHolderType& index_set_holder)
 override 
  482        _factory->fill_index_sets(index_set_holder);
 
  486    template<
int shape_dim_, 
int num_coords_, 
typename Coord_, 
template<
typename> 
class Factory_>
 
  487    class RefineFactory< StructuredMesh<shape_dim_, num_coords_, Coord_>, Factory_ > :
 
  488      public Factory< StructuredMesh<shape_dim_, num_coords_, Coord_> >
 
  491      typedef StructuredMesh<shape_dim_, num_coords_, Coord_> MeshType;
 
  492      typedef typename MeshType::VertexSetType VertexSetType;
 
  495      typedef Factory<MeshType> MeshFactory;
 
  496      typedef Factory_<MeshType> MyFactoryType;
 
  497      typedef StandardRefinery<MeshType> Refinery;
 
  499      MeshType* _coarse_mesh;
 
  500      MeshFactory* _factory;
 
  503      template<
typename... Arguments>
 
  504      explicit RefineFactory(
Index num_refines, Arguments&&... args) :
 
  505        _coarse_mesh(nullptr),
 
  510          _factory = 
new MyFactoryType(std::forward<Arguments>(args)...);
 
  515        MyFactoryType my_factory(std::forward<Arguments>(args)...);
 
  516        _coarse_mesh = 
new MeshType(my_factory);
 
  519        _factory = 
new Refinery(*_coarse_mesh);
 
  522        for(
Index i(1); i < num_refines; ++i)
 
  525          MeshType* mesh_old = _coarse_mesh;
 
  527          _coarse_mesh = 
new MeshType(*_factory);
 
  533          _factory = 
new Refinery(*_coarse_mesh);
 
  537      virtual ~RefineFactory()
 
  539        if(_factory != 
nullptr)
 
  543        if(_coarse_mesh != 
nullptr)
 
  549      virtual void fill_vertex_set(VertexSetType& vertex_set)
 override 
  551        _factory->fill_vertex_set(vertex_set);
 
  554      virtual Index get_num_slices(
int dir)
 override 
  556        return _factory->get_num_slices(dir);
 
  561    template<
typename MeshType_>
 
  562    using RefinedUnitCubeFactory = RefineFactory<MeshType_, Geometry::UnitCubeFactory >;
 
  574    template<
typename Mesh_>
 
  579    template<
int shape_dim_, 
typename Coord_>
 
  581      public Factory<ConformalMesh<Shape::Hypercube<shape_dim_>, shape_dim_, Coord_>>
 
  587      typedef typename BaseClass::VertexSetType VertexSetType;
 
  588      typedef typename BaseClass::IndexSetHolderType IndexSetHolderType;
 
  590      static_assert(shape_dim_ <= 3, 
"this class can only be used for dimension <= 3");
 
  593      Index _num_slices[3];
 
  594      Index _num_entities[4];
 
  595      std::unique_ptr<StructIndexSetHolder<shape_dim_>> _sish;
 
  602        _num_slices[1] = (shape_dim_ >= 2 ? ny : 
Index(0));
 
  603        _num_slices[2] = (shape_dim_ >= 3 ? nz : 
Index(0));
 
  606        _sish.reset(
new StructIndexSetHolder<shape_dim_>(_num_slices));
 
  609        _num_entities[0] = _sish-> 
template get_index_set<shape_dim_, 0>().get_index_bound();
 
  610        if constexpr (shape_dim_ >= 2)
 
  611          _num_entities[1] = _sish-> 
template get_index_set<shape_dim_, 1>().get_index_bound();
 
  612        if constexpr (shape_dim_ >= 3)
 
  613          _num_entities[2] = _sish-> 
template get_index_set<shape_dim_, 2>().get_index_bound();
 
  614        _num_entities[shape_dim_] = _sish-> 
template get_index_set<shape_dim_, 0>().get_num_entities();
 
  617      virtual Index get_num_entities(
int dim)
 override 
  619        return _num_entities[dim];
 
  622      virtual void fill_vertex_set(VertexSetType& vertex_set)
 override 
  624        const Coord_ fx = (_num_slices[0] > 0u ? Coord_(1) / Coord_(_num_slices[0]) : Coord_(0));
 
  625        const Coord_ fy = (_num_slices[1] > 0u ? Coord_(1) / Coord_(_num_slices[1]) : Coord_(0));
 
  626        const Coord_ fz = (_num_slices[2] > 0u ? Coord_(1) / Coord_(_num_slices[2]) : Coord_(0));
 
  627        for(
Index i(0u); i <= _num_slices[2]; ++i)
 
  629          for(
Index j(0u); j <= _num_slices[1]; ++j)
 
  631            for(
Index k(0u); k <= _num_slices[0]; ++k)
 
  633              auto& v =vertex_set[k + (_num_slices[0]+1u) * (j + (_num_slices[1]+1u)*i)];
 
  634              v[0] = Coord_(k) * fx;
 
  635              if constexpr(shape_dim_ >= 2) v[1] = Coord_(j) * fy;
 
  636              if constexpr(shape_dim_ >= 3) v[2] = Coord_(i) * fz;
 
  645      virtual void fill_index_sets(IndexSetHolderType& index_set_holder)
 override 
  648        _sish->copy_to(index_set_holder);
 
  653        StructUnitCubeFactory factory(nx, ny, nz);
 
  654        return MeshType(factory);
 
  657      static std::unique_ptr<MeshType> make_unique_from(
Index nx = 1u, 
Index ny = 1u, 
Index nz = 1u)
 
  659        StructUnitCubeFactory factory(nx, ny, nz);
 
  660        return std::unique_ptr<MeshType>(
new MeshType(factory));
 
  665    template<
int shape_dim_, 
typename Coord_>
 
  666    class StructUnitCubeFactory<ConformalMesh<Shape::Simplex<shape_dim_>, shape_dim_, Coord_>> :
 
  667      public Factory<ConformalMesh<Shape::Simplex<shape_dim_>, shape_dim_, Coord_>>
 
  670      typedef ConformalMesh<Shape::Simplex<shape_dim_>, shape_dim_, Coord_> MeshType;
 
  671      typedef ConformalMesh<Shape::Hypercube<shape_dim_>, shape_dim_, Coord_> QuadMeshType;
 
  672      typedef Factory<MeshType> BaseClass;
 
  674      typedef typename BaseClass::VertexSetType VertexSetType;
 
  675      typedef typename BaseClass::IndexSetHolderType IndexSetHolderType;
 
  677      static_assert(shape_dim_ <= 3, 
"this class can only be used for dimension <= 3");
 
  680      std::unique_ptr<QuadMeshType> _quad_mesh;
 
  681      std::unique_ptr<ShapeConvertFactory<MeshType>> _shape_convert_factory;
 
  684      explicit StructUnitCubeFactory(
Index nx = 1u, 
Index ny = 1u, 
Index nz = 1u)
 
  687        StructUnitCubeFactory<QuadMeshType> quad_factory(nx, ny, nz);
 
  688        this->_quad_mesh.reset(
new QuadMeshType(quad_factory));
 
  691        this->_shape_convert_factory.reset(
new ShapeConvertFactory<MeshType>(*this->_quad_mesh));
 
  694      virtual Index get_num_entities(
int dim)
 override 
  696        return this->_shape_convert_factory->get_num_entities(dim);
 
  699      virtual void fill_vertex_set(VertexSetType& vertex_set)
 override 
  701        this->_shape_convert_factory->fill_vertex_set(vertex_set);
 
  704      virtual void fill_index_sets(IndexSetHolderType& index_set_holder)
 override 
  706        this->_shape_convert_factory->fill_index_sets(index_set_holder);
 
  711        StructUnitCubeFactory factory(nx, ny, nz);
 
  712        return MeshType(factory);
 
  715      static std::unique_ptr<MeshType> make_unique_from(
Index nx = 1u, 
Index ny = 1u, 
Index nz = 1u)
 
  717        StructUnitCubeFactory factory(nx, ny, nz);
 
  718        return std::unique_ptr<MeshType>(
new MeshType(factory));
 
  723    template<
int shape_dim_, 
typename Coord_>
 
  724    class StructUnitCubeFactory<StructuredMesh<shape_dim_, shape_dim_, Coord_>> :
 
  725      public Factory<StructuredMesh<shape_dim_, shape_dim_, Coord_>>
 
  728      typedef StructuredMesh<shape_dim_, shape_dim_, Coord_> MeshType;
 
  729      typedef Factory<MeshType> BaseClass;
 
  731      typedef typename BaseClass::VertexSetType VertexSetType;
 
  733      static_assert(shape_dim_ <= 3, 
"this class can only be used for dimension <= 3");
 
  736      Index _num_slices[3];
 
  739      explicit StructUnitCubeFactory(
Index nx = 1u, 
Index ny = 1u, 
Index nz = 1u)
 
  742        _num_slices[1] = (shape_dim_ >= 2 ? ny : 
Index(0));
 
  743        _num_slices[2] = (shape_dim_ >= 3 ? nz : 
Index(0));
 
  746      virtual Index get_num_slices(
int dir)
 override 
  748        XASSERT((dir >= 0) && (dir <= shape_dim_));
 
  749        return _num_slices[dir];
 
  752      virtual void fill_vertex_set(VertexSetType& vertex_set)
 override 
  754        const Coord_ fx = (_num_slices[0] > 0u ? Coord_(1) / Coord_(_num_slices[0]) : Coord_(0));
 
  755        const Coord_ fy = (_num_slices[1] > 0u ? Coord_(1) / Coord_(_num_slices[1]) : Coord_(0));
 
  756        const Coord_ fz = (_num_slices[2] > 0u ? Coord_(1) / Coord_(_num_slices[2]) : Coord_(0));
 
  757        for(
Index i(0u); i <= _num_slices[2]; ++i)
 
  759          for(
Index j(0u); j <= _num_slices[1]; ++j)
 
  761            for(
Index k(0u); k <= _num_slices[0]; ++k)
 
  763              auto& v =vertex_set[k + (_num_slices[0]+1u) * (j + (_num_slices[1]+1u)*i)];
 
  764              v[0] = Coord_(k) * fx;
 
  765              if constexpr(shape_dim_ >= 2) v[1] = Coord_(j) * fy;
 
  766              if constexpr(shape_dim_ >= 3) v[2] = Coord_(i) * fz;
 
  777        StructUnitCubeFactory factory(nx, ny, nz);
 
  778        return MeshType(factory);
 
  781      static std::unique_ptr<MeshType> make_unique_from(
Index nx = 1u, 
Index ny = 1u, 
Index nz = 1u)
 
  783        StructUnitCubeFactory factory(nx, ny, nz);
 
  784        return std::unique_ptr<MeshType>(
new MeshType(factory));
 
  828    template<
typename Mesh_>
 
  835    template<
typename Coord_>
 
  837      public Factory< ConformalMesh<Shape::Hypercube<2>, 2, Coord_> >
 
  845      typedef typename MeshType::VertexSetType VertexSetType;
 
  847      typedef typename MeshType::IndexSetHolderType IndexSetHolderType;
 
  854      virtual Index get_num_entities(
int dim)
 override 
  869      virtual void fill_vertex_set(VertexSetType& vertex_set)
 override 
  871        vertex_set[0][0] = Coord_(0);
 
  872        vertex_set[0][1] = Coord_(0);
 
  874        vertex_set[1][0] = Coord_(1);
 
  875        vertex_set[1][1] = Coord_(0);
 
  877        vertex_set[2][0] = Coord_(0);
 
  878        vertex_set[2][1] = Coord_(1);
 
  880        vertex_set[3][0] = Coord_(1);
 
  881        vertex_set[3][1] = Coord_(1);
 
  883        vertex_set[4][0] = Coord_(0.25);
 
  884        vertex_set[4][1] = Coord_(0.25);
 
  886        vertex_set[5][0] = Coord_(0.75);
 
  887        vertex_set[5][1] = Coord_(0.25);
 
  889        vertex_set[6][0] = Coord_(0.25);
 
  890        vertex_set[6][1] = Coord_(0.75);
 
  892        vertex_set[7][0] = Coord_(0.75);
 
  893        vertex_set[7][1] = Coord_(0.75);
 
  897      virtual void fill_index_sets(IndexSetHolderType& index_set_holder)
 override 
  899        IndexSet<4>& v_q = index_set_holder.template get_index_set<2,0>();
 
  926        IndexSet<4>& e_q = index_set_holder.template get_index_set<2,1>();
 
  934        e_q(1,1) = 
Index(10);
 
  940        e_q(2,2) = 
Index(11);
 
  941        e_q(2,3) = 
Index(10);
 
  944        e_q(3,1) = 
Index(11);
 
  953        IndexSet<2>& v_e = index_set_holder.template get_index_set<1,0>();
 
  985        v_e(10,0) = 
Index(7);
 
  986        v_e(10,1) = 
Index(3);
 
  988        v_e(11,0) = 
Index(6);
 
  989        v_e(11,1) = 
Index(2);
 
 1001    template<
typename Coord_, 
int dim_>
 
 1002    class UnitStarCubeFactory< ConformalMesh<Shape::Simplex<dim_>, dim_, Coord_> > :
 
 1003      public Factory< ConformalMesh<Shape::Simplex<dim_>, dim_, Coord_> >
 
 1007      typedef Shape::Simplex<dim_> ShapeType;
 
 1009      typedef ConformalMesh<Shape::Simplex<dim_>, dim_, Coord_> MeshType;
 
 1011      typedef typename MeshType::VertexSetType VertexSetType;
 
 1013      typedef typename MeshType::IndexSetHolderType IndexSetHolderType;
 
 1015      typedef ShapeConvertFactory<MeshType> FactoryType;
 
 1017      typedef ConformalMesh<Shape::Hypercube<dim_>, dim_, Coord_> GeneratorMeshType;
 
 1020      GeneratorMeshType* _generator_mesh;
 
 1021      FactoryType* _factory;
 
 1024      UnitStarCubeFactory() :
 
 1025        _generator_mesh(nullptr),
 
 1028        UnitStarCubeFactory<GeneratorMeshType> cube_factory;
 
 1029        _generator_mesh = 
new GeneratorMeshType(cube_factory);
 
 1030        _factory = 
new FactoryType(*_generator_mesh);
 
 1033      virtual ~UnitStarCubeFactory()
 
 1035        delete _generator_mesh;
 
 1039      virtual Index get_num_entities(
int dim)
 override 
 1041        return _factory->get_num_entities(dim);
 
 1044      virtual void fill_vertex_set(VertexSetType& vertex_set)
 override 
 1046        _factory->fill_vertex_set(vertex_set);
 
 1049      virtual void fill_index_sets(IndexSetHolderType& index_set_holder)
 override 
 1051        _factory->fill_index_sets(index_set_holder);
 
 1069    template<
int dim_, 
typename Coord_>
 
 1071      public Factory< ConformalMesh<Shape::Hypercube<1>, dim_, Coord_> >
 
 1093        XASSERTM(!points_.empty(), 
"PolylineFactory constructor called on empty point set!");
 
 1119        const auto& jt(
_points.end());
 
 1120        for(
auto it(
_points.begin()); it != jt; ++i)
 
 1122          vertex_set[i] = *it;
 
 1132        IndexSet<2>& v_e(index_set_holder.template get_index_set<1,0>());
 
 1136          v_e[i][1] = i + 
Index(1);
 
 1141    template<
typename Mesh_>
 
 1146    template<
typename Coord_>
 
 1148      public Factory< ConformalMesh<Shape::Simplex<2>, 3, Coord_> >
 
 1156      typedef typename MeshType::VertexSetType VertexSetType;
 
 1158      typedef typename MeshType::IndexSetHolderType IndexSetHolderType;
 
 1165      virtual Index get_num_entities(
int dim)
 override 
 1180      virtual void fill_vertex_set(VertexSetType& vertex_set)
 override 
 1183        const Coord_ va = Coord_(0);
 
 1184        const Coord_ vb = 
Math::sqrt(Coord_(2) / (Coord_(5) + s5));
 
 1185        const Coord_ vc = (s5 + Coord_(1)) / 
Math::sqrt(Coord_(10) + Coord_(2)*s5);
 
 1186        vertex_set[ 0][0] =  va;
 
 1187        vertex_set[ 0][1] = -vb;
 
 1188        vertex_set[ 0][2] =  vc;
 
 1189        vertex_set[ 1][0] =  vc;
 
 1190        vertex_set[ 1][1] =  va;
 
 1191        vertex_set[ 1][2] =  vb;
 
 1192        vertex_set[ 2][0] =  vc;
 
 1193        vertex_set[ 2][1] =  va;
 
 1194        vertex_set[ 2][2] = -vb;
 
 1195        vertex_set[ 3][0] = -vc;
 
 1196        vertex_set[ 3][1] =  va;
 
 1197        vertex_set[ 3][2] = -vb;
 
 1198        vertex_set[ 4][0] = -vc;
 
 1199        vertex_set[ 4][1] =  va;
 
 1200        vertex_set[ 4][2] =  vb;
 
 1201        vertex_set[ 5][0] = -vb;
 
 1202        vertex_set[ 5][1] =  vc;
 
 1203        vertex_set[ 5][2] =  va;
 
 1204        vertex_set[ 6][0] =  vb;
 
 1205        vertex_set[ 6][1] =  vc;
 
 1206        vertex_set[ 6][2] =  va;
 
 1207        vertex_set[ 7][0] =  vb;
 
 1208        vertex_set[ 7][1] = -vc;
 
 1209        vertex_set[ 7][2] =  va;
 
 1210        vertex_set[ 8][0] = -vb;
 
 1211        vertex_set[ 8][1] = -vc;
 
 1212        vertex_set[ 8][2] =  va;
 
 1213        vertex_set[ 9][0] =  va;
 
 1214        vertex_set[ 9][1] = -vb;
 
 1215        vertex_set[ 9][2] = -vc;
 
 1216        vertex_set[10][0] =  va;
 
 1217        vertex_set[10][1] =  vb;
 
 1218        vertex_set[10][2] = -vc;
 
 1219        vertex_set[11][0] =  va;
 
 1220        vertex_set[11][1] =  vb;
 
 1221        vertex_set[11][2] =  vc;
 
 1224      virtual void fill_index_sets(IndexSetHolderType& index_set_holder)
 override 
 1227        auto& ve = index_set_holder.template get_index_set<1,0>();
 
 1290        auto& vf = index_set_holder.template get_index_set<2,0>();
 
 1356    template<
typename Coord_>
 
 1357    class UnitSphereFactory< ConformalMesh<Shape::Hypercube<2>, 3, Coord_> > :
 
 1358      public Factory< ConformalMesh<Shape::Hypercube<2>, 3, Coord_> >
 
 1362      typedef Shape::Hypercube<2> ShapeType;
 
 1364      typedef ConformalMesh<Shape::Hypercube<2>, 3, Coord_> MeshType;
 
 1366      typedef typename MeshType::VertexSetType VertexSetType;
 
 1368      typedef typename MeshType::IndexSetHolderType IndexSetHolderType;
 
 1375      virtual Index get_num_entities(
int dim)
 override 
 1390      virtual void fill_vertex_set(VertexSetType& vertex_set)
 override 
 1392        const Coord_ scale = Coord_(2) / 
Math::sqrt(Coord_(3));
 
 1393        for(
Index i(0); i < 8u; ++i)
 
 1395          for(
int j(0); j < 3; ++j)
 
 1397            vertex_set[i][j] = scale * (Coord_((i >> j) & 0x1) - Coord_(0.5));
 
 1402      virtual void fill_index_sets(IndexSetHolderType& index_set_holder)
 override 
 1404        _fill_index_set<1,0>(index_set_holder);
 
 1405        _fill_index_set<2,0>(index_set_holder);
 
 1406        _fill_index_set<2,1>(index_set_holder);
 
 1410      template<
int cell_dim_, 
int face_dim_>
 
 1411      static void _fill_index_set(IndexSetHolderType& index_set_holder)
 
 1413        typedef typename Intern::FaceIndexMapping<Shape::Hypercube<3>, cell_dim_, face_dim_> FimType;
 
 1414        auto& idx = index_set_holder.template get_index_set<cell_dim_, face_dim_>();
 
 1416        for(
int i(0); i < Shape::FaceTraits<Shape::Hypercube<3>, cell_dim_>::count; ++i)
 
 1418          for(
int j(0); j < idx.num_indices; ++j)
 
 1420            idx[
Index(i)][j] = 
Index(FimType::map(i, j));
 
 1427    template<
typename MeshType_>
 
 1428    using RefinedUnitSphereFactory = RefineFactory<MeshType_, Geometry::UnitSphereFactory>;
 
#define XASSERT(expr)
Assertion macro definition.
#define XASSERTM(expr, msg)
Assertion macro definition with custom message.
Mesh Factory class template.
Conformal Index-Set class template.
Constructs a polyline mesh.
MeshType::VertexSetType VertexSetType
vertex set type
virtual void fill_vertex_set(VertexSetType &vertex_set) override
std::deque< Tiny::Vector< Coord_, dim_ > > & _points
Reference to the set of points in the polyline.
MeshType::IndexSetHolderType IndexSetHolderType
index holder type
virtual Index get_num_entities(int dimension) override
virtual void fill_index_sets(IndexSetHolderType &index_set_holder) override
PolylineFactory(std::deque< typename VertexSetType::VertexType > &points_)
From deque of Tiny::Vectors constructor.
ConformalMesh< Shape::Hypercube< 1 >, dim_, Coord_ > MeshType
mesh type
static void compute(IndexSetHolder< Shape_ > &index_set_holder)
Routine that does the actual work.
Standard Refinery class template.
Structured unit-cube mesh factory.
Unit cube factory with star shaped mesh topology.
T_ sqrt(T_ x)
Returns the square-root of a value.
std::uint64_t Index
Index data type.
Fixed-Sized Vertex Set class template.
Hypercube shape tag struct template.
Simplex shape tag struct template.