1#ifndef DUNE_MULTIDOMAINGRID_MDGRIDTRAITS_HH
2#define DUNE_MULTIDOMAINGRID_MDGRIDTRAITS_HH
7#include <dune/grid/multidomaingrid/subdomainset.hh>
8#include <dune/grid/multidomaingrid/arraybasedset.hh>
9#include <dune/grid/multidomaingrid/singlevalueset.hh>
15template<
int dim,
int codim>
17 static const bool supported =
true;
20template<
int dim,
int codim>
21struct CellAndVertexCodims {
22 static const bool supported = (codim == 0 || codim == dim);
25template<
int dim, std::
size_t subDomainsPerCell, std::
size_t subDomainCount,
template<
int dim_,
int codim>
class supportedCodims = AllCodims>
26struct ArrayBasedTraits {
28 typedef int SubDomainIndex;
29 static const SubDomainIndex empty = -1;
30 static const int dimension = dim;
32 static const std::size_t maxSubDomainsPerCell = subDomainsPerCell;
34 static constexpr bool maxSubDomainIndexIsStatic()
39 static constexpr SubDomainIndex maxSubDomainIndex()
41 return subDomainCount;
44 struct EmptyCodimBase {
45 typedef int SizeContainer;
46 typedef int MultiIndexContainer;
47 typedef int SubDomainSet;
52 static const std::size_t maxSubDomainsPerEntity = (2<<(codim)) * maxSubDomainsPerCell;
53 typedef Dune::mdgrid::ArrayBasedSet<SubDomainIndex,maxSubDomainsPerEntity> SubDomainSet;
54 typedef std::array<int,maxSubDomainsPerEntity> MultiIndexContainer;
55 typedef std::array<int,subDomainCount> SizeContainer;
59 struct Codim :
public std::conditional_t<supportedCodims<dim,codim>::supported,CodimBase<codim>,EmptyCodimBase> {
60 static const bool supported = supportedCodims<dim,codim>::supported;
63 template<
int codim,
typename SizeContainer>
64 void setupSizeContainer(SizeContainer&)
const
70template<
int dim, std::
size_t subDomainsPerCell,
template<
int dim_,
int codim>
class supportedCodims = AllCodims>
71struct DynamicSubDomainCountTraits {
73 typedef int SubDomainIndex;
74 static const SubDomainIndex empty = -1;
75 static const int dimension = dim;
77 static constexpr bool maxSubDomainIndexIsStatic()
82 static const std::size_t maxSubDomainsPerCell = subDomainsPerCell;
84 SubDomainIndex maxSubDomainIndex()
const
86 return _subDomainCount;
89 struct EmptyCodimBase {
90 typedef int SizeContainer;
91 typedef int MultiIndexContainer;
92 typedef int SubDomainSet;
95 static void setupSizeContainer(
const SC&, std::size_t)
102 static const std::size_t maxSubDomainsPerEntity = (2<<(codim)) * maxSubDomainsPerCell;
103 typedef Dune::mdgrid::ArrayBasedSet<SubDomainIndex,maxSubDomainsPerEntity> SubDomainSet;
104 typedef std::array<int,maxSubDomainsPerEntity> MultiIndexContainer;
105 typedef std::vector<int> SizeContainer;
107 static void setupSizeContainer(SizeContainer& container, std::size_t subDomainCount)
109 container.resize(subDomainCount);
115 struct Codim :
public std::conditional_t<supportedCodims<dim,codim>::supported,CodimBase<codim>,EmptyCodimBase> {
116 static const bool supported = supportedCodims<dim,codim>::supported;
119 DynamicSubDomainCountTraits(std::size_t subDomainCount)
120 : _subDomainCount(subDomainCount)
123 template<
int codim,
typename SizeContainer>
124 void setupSizeContainer(SizeContainer& container)
const
126 Codim<codim>::setupSizeContainer(container,_subDomainCount);
131 const std::size_t _subDomainCount;
136template<
int dim, std::
size_t maxSubDomains,
template<
int dim_,
int codim>
class supportedCodims = AllCodims >
137struct FewSubDomainsTraits {
139 typedef unsigned int SubDomainIndex;
140 static const SubDomainIndex empty = ~SubDomainIndex(0);
141 static const int dimension = dim;
143 static const std::size_t maxSubDomainsPerCell = maxSubDomains;
145 static constexpr bool maxSubDomainIndexIsStatic()
150 static constexpr SubDomainIndex maxSubDomainIndex()
152 return maxSubDomains - 1;
155 struct EmptyCodimBase {
156 typedef int SizeContainer;
157 typedef int MultiIndexContainer;
158 typedef int SubDomainSet;
163 static const std::size_t maxSubDomainsPerEntity = maxSubDomains;
164 typedef Dune::mdgrid::IntegralTypeSubDomainSet<SubDomainIndex,maxSubDomainsPerEntity> SubDomainSet;
165 typedef std::array<int,maxSubDomainsPerEntity> MultiIndexContainer;
166 typedef std::array<int,maxSubDomains> SizeContainer;
170 struct Codim :
public std::conditional_t<supportedCodims<dim,codim>::supported,CodimBase<codim>,EmptyCodimBase> {
171 static const bool supported = supportedCodims<dim,codim>::supported;
175 void setupSizeContainer(
typename Codim<codim>::SizeContainer&)
const