4#ifndef DUNE_ISTL_BLOCKLEVEL_HH
5#define DUNE_ISTL_BLOCKLEVEL_HH
10#include <dune/common/indices.hh>
12#include <dune/common/hybridutilities.hh>
21template<
typename... Args>
22class MultiTypeBlockVector;
23template<
typename FirstRow,
typename... Args>
24class MultiTypeBlockMatrix;
30template<
typename T>
struct MaxBlockLevel;
31template<
typename T>
struct MinBlockLevel;
34template<
typename M,
template<
typename B>
typename BlockLevel,
typename Op>
35constexpr std::size_t blockLevelMultiTypeBlockMatrix(
const Op& op)
39 using Block00 =
typename std::decay_t<decltype(std::declval<M>()[
_0][
_0])>;
40 std::size_t
blockLevel = BlockLevel<Block00>::value() + 1;
42 using namespace Dune::Hybrid;
44 using namespace Dune::Hybrid;
46 using Block =
typename std::decay_t<decltype(std::declval<M>()[i][j])>;
54template<
typename V,
template<
typename B>
typename BlockLevel,
typename Op>
55constexpr std::size_t blockLevelMultiTypeBlockVector(
const Op& op)
59 using Block0 =
typename std::decay_t<decltype(std::declval<V>()[
_0])>;
60 std::size_t
blockLevel = BlockLevel<Block0>::value() + 1;
62 using namespace Dune::Hybrid;
64 using Block =
typename std::decay_t<decltype(std::declval<V>()[i])>;
73 static constexpr std::size_t value(){
77 return MaxBlockLevel<typename T::block_type>::value() + 1;
85 static constexpr std::size_t value()
86 {
return MaxBlockLevel<T>::value(); }
90template<
typename FirstRow,
typename... Args>
93 static constexpr std::size_t value()
96 constexpr auto max = [](
const auto& a,
const auto& b){
return std::max(a,b); };
97 return blockLevelMultiTypeBlockMatrix<M, MaxBlockLevel>(
max);
102template<
typename FirstRow,
typename... Args>
105 static constexpr std::size_t value()
108 constexpr auto min = [](
const auto& a,
const auto& b){
return std::min(a,b); };
109 return blockLevelMultiTypeBlockMatrix<M, MinBlockLevel>(
min);
114template<
typename... Args>
117 static constexpr std::size_t value()
120 constexpr auto max = [](
const auto& a,
const auto& b){
return std::max(a,b); };
121 return blockLevelMultiTypeBlockVector<V, MaxBlockLevel>(
max);
126template<
typename... Args>
129 static constexpr std::size_t value()
132 constexpr auto min = [](
const auto& a,
const auto& b){
return std::min(a,b); };
133 return blockLevelMultiTypeBlockVector<V, MinBlockLevel>(
min);
141 static constexpr std::size_t value()
149 static constexpr std::size_t value()
160{
return Impl::MaxBlockLevel<T>::value(); }
165{
return Impl::MinBlockLevel<T>::value(); }
170{
return maxBlockLevel<T>() == minBlockLevel<T>(); }
176 static_assert(hasUniqueBlockLevel<T>(),
"Block level cannot be uniquely determined!");
177 return Impl::MaxBlockLevel<T>::value();
A Matrix class to support different block types.
Definition: multitypeblockmatrix.hh:44
A Vector class to support different block types.
Definition: multitypeblockvector.hh:56
Traits for type conversions and type information.
constexpr index_constant< 0 > _0
Compile time index with value 0.
Definition: indices.hh:51
std::integral_constant< std::size_t, i > index_constant
An index constant with value i.
Definition: indices.hh:28
constexpr void forEach(Range &&range, F &&f)
Range based for loop.
Definition: hybridutilities.hh:266
constexpr auto integralRange(const Begin &begin, const End &end)
Create an integral range.
Definition: hybridutilities.hh:182
auto min(ADLTag< 0 >, const V &v1, const V &v2)
implements binary Simd::min()
Definition: defaults.hh:87
auto max(ADLTag< 0 >, const V &v1, const V &v2)
implements binary Simd::max()
Definition: defaults.hh:79
Namespace with predefined compile time indices for the range [0,19].
Definition: indices.hh:49
Dune namespace.
Definition: alignedallocator.hh:11
constexpr bool hasUniqueBlockLevel()
Determine if a vector/matrix has a uniquely determinable block level.
Definition: blocklevel.hh:169
constexpr std::size_t maxBlockLevel()
Determine the maximum block level of a possibly nested vector/matrix type.
Definition: blocklevel.hh:159
constexpr std::size_t blockLevel()
Determine the block level of a possibly nested vector/matrix type.
Definition: blocklevel.hh:174
constexpr std::size_t minBlockLevel()
Determine the minimum block level of a possibly nested vector/matrix type.
Definition: blocklevel.hh:164
Whether this type acts as a scalar in the context of (hierarchically blocked) containers.
Definition: typetraits.hh:194