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 inline static const SubDomainIndex empty = -1;
75 inline static const int dimension = dim;
77 inline static const std::size_t maxSubDomainsPerCell = subDomainsPerCell;
79 static constexpr bool maxSubDomainIndexIsStatic()
85 SubDomainIndex maxSubDomainIndex()
const
87 return _subDomainCount;
90 struct EmptyCodimBase {
91 typedef int SizeContainer;
92 typedef int MultiIndexContainer;
93 typedef int SubDomainSet;
96 static void setupSizeContainer(
const SC&, std::size_t)
103 static const std::size_t maxSubDomainsPerEntity = (2<<(codim)) * maxSubDomainsPerCell;
104 typedef Dune::mdgrid::ArrayBasedSet<SubDomainIndex,maxSubDomainsPerEntity> SubDomainSet;
105 typedef std::array<int,maxSubDomainsPerEntity> MultiIndexContainer;
106 typedef std::vector<int> SizeContainer;
108 static void setupSizeContainer(SizeContainer& container, std::size_t subDomainCount)
110 container.resize(subDomainCount);
116 struct Codim :
public std::conditional_t<supportedCodims<dim,codim>::supported,CodimBase<codim>,EmptyCodimBase> {
117 static const bool supported = supportedCodims<dim,codim>::supported;
120 DynamicSubDomainCountTraits(std::size_t subDomainCount)
121 : _subDomainCount(subDomainCount)
124 template<
int codim,
typename SizeContainer>
125 void setupSizeContainer(SizeContainer& container)
const
127 Codim<codim>::setupSizeContainer(container,_subDomainCount);
132 const std::size_t _subDomainCount;
137template<
int dim, std::
size_t maxSubDomains,
template<
int dim_,
int codim>
class supportedCodims = AllCodims >
138struct FewSubDomainsTraits {
140 typedef unsigned int SubDomainIndex;
141 inline static const SubDomainIndex empty = ~SubDomainIndex(0);
142 inline static const int dimension = dim;
144 inline static const std::size_t maxSubDomainsPerCell = maxSubDomains;
146 static constexpr bool maxSubDomainIndexIsStatic()
151 static constexpr SubDomainIndex maxSubDomainIndex()
153 return maxSubDomains - 1;
156 struct EmptyCodimBase {
157 typedef int SizeContainer;
158 typedef int MultiIndexContainer;
159 typedef int SubDomainSet;
164 inline static const std::size_t maxSubDomainsPerEntity = maxSubDomains;
165 typedef Dune::mdgrid::IntegralTypeSubDomainSet<SubDomainIndex,maxSubDomainsPerEntity> SubDomainSet;
166 typedef std::array<int,maxSubDomainsPerEntity> MultiIndexContainer;
167 typedef std::array<int,maxSubDomains> SizeContainer;
171 struct Codim :
public std::conditional_t<supportedCodims<dim,codim>::supported,CodimBase<codim>,EmptyCodimBase> {
172 inline static const bool supported = supportedCodims<dim,codim>::supported;
176 void setupSizeContainer(
typename Codim<codim>::SizeContainer&)
const