dune-grid  2.2.1
alugrid/common/persistentcontainer.hh
Go to the documentation of this file.
1 #ifndef DUNE_ALU_PERSISTENTCONTAINER_HH
2 #define DUNE_ALU_PERSISTENTCONTAINER_HH
3 
4 #if HAVE_ALUGRID
6 #include <dune/grid/alugrid.hh>
7 
8 namespace Dune
9 {
10  // PersistentContainer for ALUGrid
11  // -------------------------------
12 
13  template< int dim, int dimworld, class Data, class Allocator >
14  class PersistentContainer< ALUConformGrid< dim, dimworld >, Data, Allocator >
15  : public PersistentContainerVector< ALUConformGrid< dim, dimworld >,
16  typename ALUConformGrid< dim, dimworld >::HierarchicIndexSet,
17  std::vector<Data,Allocator> >
18  {
19  public:
20  typedef ALUConformGrid< dim, dimworld > GridType;
21  private:
22  typedef PersistentContainerVector< GridType, typename GridType::HierarchicIndexSet, std::vector<Data,Allocator> > BaseType;
23 
24  public:
27  PersistentContainer ( const GridType &grid, const int codim, const Allocator &allocator = Allocator() )
28  : BaseType( grid, codim, grid.hierarchicIndexSet(), 1.1, allocator )
29  {}
30  };
31 
32  template< int dim, int dimworld, class Data, class Allocator >
33  class PersistentContainer< ALUCubeGrid< dim, dimworld >, Data, Allocator >
34  : public PersistentContainerVector< ALUCubeGrid< dim, dimworld >,
35  typename ALUCubeGrid< dim, dimworld >::HierarchicIndexSet,
36  std::vector<Data,Allocator> >
37  {
38  public:
39  typedef ALUCubeGrid< dim, dimworld > GridType;
40  private:
41  typedef PersistentContainerVector< GridType, typename GridType::HierarchicIndexSet, std::vector<Data,Allocator> > BaseType;
42 
43  public:
46  PersistentContainer ( const GridType &grid, const int codim, const Allocator &allocator = Allocator() )
47  : BaseType( grid, codim, grid.hierarchicIndexSet(), 1.1, allocator )
48  {}
49  };
50 
51  template< int dim, int dimworld, class Data, class Allocator >
52  class PersistentContainer< ALUSimplexGrid< dim, dimworld >, Data, Allocator >
53  : public PersistentContainerVector< ALUSimplexGrid< dim, dimworld >,
54  typename ALUSimplexGrid< dim, dimworld >::HierarchicIndexSet,
55  std::vector<Data,Allocator> >
56  {
57  public:
58  typedef ALUSimplexGrid< dim, dimworld > GridType;
59  private:
60  typedef PersistentContainerVector< GridType, typename GridType::HierarchicIndexSet, std::vector<Data,Allocator> > BaseType;
61 
62  public:
65  PersistentContainer ( const GridType &grid, const int codim, const Allocator &allocator = Allocator() )
66  : BaseType( grid, codim, grid.hierarchicIndexSet(), 1.1, allocator )
67  {}
68  };
69 
70  template< int dim, int dimworld, ALUGridElementType eltype, ALUGridRefinementType refinementtype, class Comm,
71  class Data, class Allocator >
72  class PersistentContainer< ALUGrid< dim, dimworld, eltype, refinementtype, Comm >, Data, Allocator >
73  : public PersistentContainerVector< ALUGrid< dim, dimworld, eltype, refinementtype, Comm >,
74  typename ALUGrid< dim, dimworld, eltype, refinementtype, Comm >::HierarchicIndexSet,
75  std::vector<Data,Allocator> >
76  {
77  public:
78  typedef ALUGrid< dim, dimworld, eltype, refinementtype, Comm > GridType;
79  private:
80  typedef PersistentContainerVector< GridType, typename GridType::HierarchicIndexSet, std::vector<Data,Allocator> > BaseType;
81 
82  public:
85  PersistentContainer ( const GridType &grid, const int codim, const Allocator &allocator = Allocator() )
86  : BaseType( grid, codim, grid.hierarchicIndexSet(), 1.1, allocator )
87  {}
88  };
89 
90  template< int dim, int dimworld, ALU2DSPACE ElementType elType>
91  class ALU2dGrid;
92 
93 
94  template< int dim, int dimworld, ALU2DSPACE ElementType elType, class Data, class Allocator >
95  class PersistentContainer< ALU2dGrid< dim, dimworld, elType >, Data, Allocator >
96  : public PersistentContainerVector< ALU2dGrid< dim, dimworld, elType >,
97  typename ALU2dGrid< dim, dimworld, elType >::HierarchicIndexSet,
98  std::vector<Data,Allocator> >
99  {
100  public:
101  typedef ALU2dGrid< dim, dimworld, elType > GridType;
102  private:
103  typedef PersistentContainerVector< GridType, typename GridType::HierarchicIndexSet, std::vector<Data,Allocator> > BaseType;
104 
105  public:
108  PersistentContainer ( const GridType &grid, const int codim, const Allocator &allocator = Allocator() )
109  : BaseType( grid, codim, grid.hierarchicIndexSet(), 1.1, allocator )
110  {}
111  };
112 
113  template< ALU3dGridElementType elType, class Comm, class Data, class Allocator >
114  class PersistentContainer< ALU3dGrid< elType, Comm >, Data, Allocator >
115  : public PersistentContainerVector< ALU3dGrid< elType, Comm >,
116  typename ALU3dGrid< elType, Comm >::HierarchicIndexSet,
117  std::vector<Data,Allocator> >
118  {
119  public:
120  typedef ALU3dGrid< elType, Comm > GridType;
121  private:
122  typedef PersistentContainerVector< GridType, typename GridType::HierarchicIndexSet, std::vector<Data,Allocator> > BaseType;
123 
124  protected:
125  using BaseType :: index_;
126  using BaseType :: data_;
127 
128  public:
131  PersistentContainer ( const GridType &grid, const int codim, const Allocator &allocator = Allocator() )
132  : BaseType( grid, codim, grid.hierarchicIndexSet(), 1.1, allocator )
133  {}
134 
137  const Data& getData ( const size_t idx ) const
138  {
139  assert( idx < data_.size() );
140  return data_[ idx ];
141  }
142  };
143 
144 } // end namespace Dune
145 #endif // ENABLE_ALU
146 
147 #endif // end DUNE_ALU_PERSISTENTCONTAINER_HH