unitcube_alugrid.hh 1.69 KB
Newer Older
1 2
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
3 4
#ifndef UNITCUBE_ALUGRID_HH
#define UNITCUBE_ALUGRID_HH
5

6 7 8
#include <array>
#include <memory>

9 10
#include "unitcube.hh"

11
#if HAVE_DUNE_ALUGRID
12 13
#include <dune/alugrid/grid.hh>
#include <dune/alugrid/3d/gridfactory.hh>
14

15 16
// ALU3dGrid and ALU2dGrid simplex specialization.
// Note: element type determined by type
17
template<int dim>
18
class UnitCube<Dune::ALUGrid<dim,dim,Dune::simplex,Dune::nonconforming>,1>
19 20
{
public:
21
  typedef Dune::ALUGrid<dim,dim,Dune::simplex,Dune::nonconforming> GridType;
22

23
private:
24
  std::shared_ptr<GridType> grid_;
25

26 27
public:
  UnitCube ()
28
  {
29 30
    Dune::FieldVector<typename GridType::ctype,dim> lowerLeft(0);
    Dune::FieldVector<typename GridType::ctype,dim> upperRight(1);
31
    std::array<unsigned int,dim> elements;
32
    std::fill(elements.begin(), elements.end(), 1);
33

34
    grid_ = Dune::StructuredGridFactory<GridType>::createSimplexGrid(lowerLeft, upperRight, elements);
35 36 37 38 39 40
  }

  GridType &grid ()
  {
    return *grid_;
  }
41 42
};

43 44
// ALU3dGrid hexahedra specialization. Note: element type determined by type
template<>
45
class UnitCube<Dune::ALUGrid<3,3,Dune::cube,Dune::nonconforming>,1>
46 47
{
public:
48
  typedef Dune::ALUGrid<3,3,Dune::cube,Dune::nonconforming> GridType;
49

50
private:
51
  std::shared_ptr<GridType> grid_;
52

53 54
public:
  UnitCube ()
55
  {
56 57
    Dune::FieldVector<GridType::ctype,3> lowerLeft(0);
    Dune::FieldVector<GridType::ctype,3> upperRight(1);
58
    std::array<unsigned int,3> elements = { {1,1,1} };
59

60
    grid_ = Dune::StructuredGridFactory<GridType>::createCubeGrid(lowerLeft, upperRight, elements);
61 62 63 64 65 66
  }

  GridType &grid ()
  {
    return *grid_;
  }
67
};
68
#endif // HAVE_DUNE_ALUGRID
69

70
#endif // UNITCUBE_ALUGRID_HH