6#ifndef DUNE_ISTL_BLOCKLEVEL_HH
7#define DUNE_ISTL_BLOCKLEVEL_HH
12#include <dune/common/indices.hh>
14#include <dune/common/hybridutilities.hh>
23template<
typename... Args>
24class MultiTypeBlockVector;
25template<
typename FirstRow,
typename... Args>
26class MultiTypeBlockMatrix;
29namespace Dune {
namespace Impl {
32template<
typename T>
struct MaxBlockLevel;
33template<
typename T>
struct MinBlockLevel;
36template<
typename M,
template<
typename B>
typename BlockLevel,
typename Op>
37constexpr std::size_t blockLevelMultiTypeBlockMatrix(
const Op& op)
41 using Block00 =
typename std::decay_t<decltype(std::declval<M>()[
_0][
_0])>;
42 std::size_t
blockLevel = BlockLevel<Block00>::value() + 1;
44 using namespace Dune::Hybrid;
46 using namespace Dune::Hybrid;
48 using Block =
typename std::decay_t<decltype(std::declval<M>()[i][j])>;
56template<
typename V,
template<
typename B>
typename BlockLevel,
typename Op>
57constexpr std::size_t blockLevelMultiTypeBlockVector(
const Op& op)
61 using Block0 =
typename std::decay_t<decltype(std::declval<V>()[
_0])>;
62 std::size_t
blockLevel = BlockLevel<Block0>::value() + 1;
64 using namespace Dune::Hybrid;
66 using Block =
typename std::decay_t<decltype(std::declval<V>()[i])>;
75 static constexpr std::size_t value(){
79 return MaxBlockLevel<typename T::block_type>::value() + 1;
87 static constexpr std::size_t value()
88 {
return MaxBlockLevel<T>::value(); }
92template<
typename FirstRow,
typename... Args>
95 static constexpr std::size_t value()
98 constexpr auto max = [](
const auto& a,
const auto& b){
return std::max(a,b); };
99 return blockLevelMultiTypeBlockMatrix<M, MaxBlockLevel>(
max);
104template<
typename FirstRow,
typename... Args>
107 static constexpr std::size_t value()
110 constexpr auto min = [](
const auto& a,
const auto& b){
return std::min(a,b); };
111 return blockLevelMultiTypeBlockMatrix<M, MinBlockLevel>(
min);
116template<
typename... Args>
119 static constexpr std::size_t value()
122 constexpr auto max = [](
const auto& a,
const auto& b){
return std::max(a,b); };
123 return blockLevelMultiTypeBlockVector<V, MaxBlockLevel>(
max);
128template<
typename... Args>
131 static constexpr std::size_t value()
134 constexpr auto min = [](
const auto& a,
const auto& b){
return std::min(a,b); };
135 return blockLevelMultiTypeBlockVector<V, MinBlockLevel>(
min);
143 static constexpr std::size_t value()
151 static constexpr std::size_t value()
162{
return Impl::MaxBlockLevel<T>::value(); }
167{
return Impl::MinBlockLevel<T>::value(); }
172{
return maxBlockLevel<T>() == minBlockLevel<T>(); }
178 static_assert(hasUniqueBlockLevel<T>(),
"Block level cannot be uniquely determined!");
179 return Impl::MaxBlockLevel<T>::value();
A Matrix class to support different block types.
Definition: multitypeblockmatrix.hh:46
A Vector class to support different block types.
Definition: multitypeblockvector.hh:59
constexpr index_constant< 0 > _0
Compile time index with value 0.
Definition: indices.hh:53
std::integral_constant< std::size_t, i > index_constant
An index constant with value i.
Definition: indices.hh:30
constexpr void forEach(Range &&range, F &&f)
Range based for loop.
Definition: hybridutilities.hh:268
constexpr auto integralRange(const Begin &begin, const End &end)
Create an integral range.
Definition: hybridutilities.hh:184
auto min(ADLTag< 0 >, const V &v1, const V &v2)
implements binary Simd::min()
Definition: defaults.hh:89
auto max(ADLTag< 0 >, const V &v1, const V &v2)
implements binary Simd::max()
Definition: defaults.hh:81
Namespace with predefined compile time indices for the range [0,19].
Definition: indices.hh:51
Dune namespace.
Definition: alignedallocator.hh:13
constexpr bool hasUniqueBlockLevel()
Determine if a vector/matrix has a uniquely determinable block level.
Definition: blocklevel.hh:171
constexpr std::size_t maxBlockLevel()
Determine the maximum block level of a possibly nested vector/matrix type.
Definition: blocklevel.hh:161
constexpr std::size_t blockLevel()
Determine the block level of a possibly nested vector/matrix type.
Definition: blocklevel.hh:176
constexpr std::size_t minBlockLevel()
Determine the minimum block level of a possibly nested vector/matrix type.
Definition: blocklevel.hh:166
Whether this type acts as a scalar in the context of (hierarchically blocked) containers.
Definition: typetraits.hh:194
Traits for type conversions and type information.