DUNE PDELab (2.8)
Hybrid utility functions that work on homogeneous as well as heterogeneous containers. More...
Functions | |
template<class T > | |
constexpr auto | Dune::Hybrid::size (const T &t) |
Size query. More... | |
template<class Container , class Index > | |
constexpr decltype(auto) | Dune::Hybrid::elementAt (Container &&c, Index &&i) |
Get element at given position from container. More... | |
template<class Begin , class End > | |
constexpr auto | Dune::Hybrid::integralRange (const Begin &begin, const End &end) |
Create an integral range. More... | |
template<class End > | |
constexpr auto | Dune::Hybrid::integralRange (const End &end) |
Create an integral range starting from 0. More... | |
template<class Range , class F > | |
constexpr void | Dune::Hybrid::forEach (Range &&range, F &&f) |
Range based for loop. More... | |
template<class Range , class T , class F > | |
constexpr T | Dune::Hybrid::accumulate (Range &&range, T value, F &&f) |
Accumulate values. More... | |
template<class Condition , class IfFunc , class ElseFunc > | |
decltype(auto) | Dune::Hybrid::ifElse (const Condition &condition, IfFunc &&ifFunc, ElseFunc &&elseFunc) |
A conditional expression. More... | |
template<class Condition , class IfFunc > | |
void | Dune::Hybrid::ifElse (const Condition &condition, IfFunc &&ifFunc) |
A conditional expression. More... | |
template<class T1 , class T2 > | |
constexpr auto | Dune::Hybrid::equals (T1 &&t1, T2 &&t2) |
Equality comparison. More... | |
template<class Cases , class Value , class Branches , class ElseBranch > | |
constexpr decltype(auto) | Dune::Hybrid::switchCases (const Cases &cases, const Value &value, Branches &&branches, ElseBranch &&elseBranch) |
Switch statement. More... | |
template<class Cases , class Value , class Branches > | |
constexpr void | Dune::Hybrid::switchCases (const Cases &cases, const Value &value, Branches &&branches) |
Switch statement. More... | |
Detailed Description
Hybrid utility functions that work on homogeneous as well as heterogeneous containers.
Function Documentation
◆ accumulate()
|
constexpr |
Accumulate values.
- Template Parameters
-
Range Type of given range T Type of accumulated value F Type of binary accumulation operator
- Parameters
-
range The range of values to accumulate value Initial value for accumulation f Binary operator for accumulation
This supports looping over the same ranges as Hybrid::forEach
References Dune::Hybrid::forEach().
Referenced by Dune::PDELab::SolverStatistics< T >::avg(), Dune::Functions::BSplinePreBasis< GV, MI >::BSplinePreBasis(), Dune::BCRSMatrix< B, A >::nonzeroes(), Dune::MultiTypeBlockVector< Args >::one_norm(), Dune::MultiTypeBlockVector< Args >::one_norm_real(), Dune::BDFMCubeLocalBasis< D, R, 2, 1 >::partial(), Dune::BDFMCubeLocalBasis< D, R, 2, 2 >::partial(), Dune::BDFMCubeLocalBasis< D, R, 2, 3 >::partial(), Dune::BDM1Cube2DLocalBasis< D, R >::partial(), Dune::BDM1Simplex2DLocalBasis< D, R >::partial(), Dune::BDM2Cube2DLocalBasis< D, R >::partial(), Dune::BDM2Simplex2DLocalBasis< D, R >::partial(), Dune::HierarchicalSimplexP2LocalBasis< D, R, 2 >::partial(), Dune::HierarchicalSimplexP2WithElementBubbleLocalBasis< D, R, 2 >::partial(), Dune::RT02DLocalBasis< D, R >::partial(), Dune::RT0Cube2DLocalBasis< D, R >::partial(), Dune::RT12DLocalBasis< D, R >::partial(), Dune::RT1Cube2DLocalBasis< D, R >::partial(), Dune::RT2Cube2DLocalBasis< D, R >::partial(), Dune::RT3Cube2DLocalBasis< D, R >::partial(), Dune::RT4Cube2DLocalBasis< D, R >::partial(), Dune::RefinedP1LocalBasis< D, R, 2 >::partial(), Dune::BDM1Cube3DLocalBasis< D, R >::partial(), Dune::HierarchicalSimplexP2LocalBasis< D, R, 3 >::partial(), Dune::HierarchicalSimplexP2WithElementBubbleLocalBasis< D, R, 3 >::partial(), Dune::RT03DLocalBasis< D, R >::partial(), Dune::RT0Cube3DLocalBasis< D, R >::partial(), Dune::RT1Cube3DLocalBasis< D, R >::partial(), Dune::RefinedP1LocalBasis< D, R, 3 >::partial(), Dune::PowerBasis< Backend, dimR >::partial(), Dune::P0LocalBasis< D, R, d >::partial(), Dune::EdgeS0_5Basis< Geometry, RF >::partial(), Dune::DualP1LocalBasis< D, R, dim, faceDualT >::partial(), Dune::DualQ1LocalBasis< D, R, dim >::partial(), Dune::RefinedP0LocalBasis< D, R, dim >::partial(), Dune::PolynomialBasis< Eval, CM, D, R >::partial(), Dune::QkStuff::QkLocalBasis< D, R, k, d >::partial(), Dune::LegendreStuff::DGLegendreLocalBasis< D, R, k, d >::partial(), Dune::QkStuff::QkGLLocalBasis< D, R, k, d >::partial(), Dune::Functions::BSplineLocalCoefficients< dim >::size(), Dune::PDELab::SolverStatistics< T >::stddev(), and Dune::MultiTypeBlockVector< Args >::two_norm2().
◆ elementAt()
|
constexpr |
Get element at given position from container.
- Template Parameters
-
Container Type of given container Index Type of index
- Parameters
-
c Given container i Index of element to obtain
- Returns
- The element at position i, i.e. c[i]
If this returns the i-th entry of c. It supports the following containers
- Containers providing dynamic access via operator[]
- Heterogeneous containers providing access via operator[](integral_constant<...>)
- std::tuple<...>
- std::integer_sequence
References Dune::Hybrid::elementAt().
Referenced by Dune::Hybrid::elementAt(), Dune::RandomAccessIteratorFacade< T, V, R, D >::operator[](), and Dune::ArrayList< T, N, A >::operator[]().
◆ equals()
|
constexpr |
Equality comparison.
If both types have a static member value, the result of comparing these is returned as std::integral_constant<bool, *>. Otherwise the result of a runtime comparison of t1 and t2 is directly returned.
References Dune::Hybrid::equals().
Referenced by Dune::Hybrid::equals(), Dune::BitSetVectorConstReference< block_size, Alloc >::operator!=(), Dune::operator!=(), Dune::BitSetVectorConstReference< block_size, Alloc >::operator==(), and Dune::operator==().
◆ forEach()
|
constexpr |
Range based for loop.
- Template Parameters
-
Range Type of given range F Type of given predicate
- Parameters
-
range The range to loop over f A predicate that will be called with each entry of the range
This supports looping over the following ranges
- ranges obtained from integralRange()
- all ranges that provide Hybrid::size() and Hybrid::elementAt()
This especially included instances of std::integer_sequence, std::tuple, Dune::TupleVector, and Dune::MultiTypeBlockVector.
References Dune::Hybrid::forEach().
Referenced by Dune::Hybrid::accumulate(), Dune::MultiTypeBlockVector< Args >::axpy(), Dune::Functions::CompositePreBasis< MI, IMS, SPB >::CompositePreBasis(), Dune::MultiTypeBlockVector< Args >::dim(), Dune::Functions::CompositePreBasis< MI, IMS, SPB >::dimension(), Dune::TypeTree::HybridTreePath< T >::element(), Dune::fillGridViewInfoSerial(), Dune::flatVectorForEach(), Dune::Hybrid::forEach(), Dune::MultiTypeBlockMatrix< FirstRow, Args >::frobenius_norm2(), Dune::MultiTypeBlockMatrix< FirstRow, Args >::infinity_norm(), Dune::MultiTypeBlockVector< Args >::infinity_norm(), Dune::MultiTypeBlockMatrix< FirstRow, Args >::infinity_norm_real(), Dune::MultiTypeBlockVector< Args >::infinity_norm_real(), Dune::Functions::CompositePreBasis< MI, IMS, SPB >::initializeIndices(), Dune::LocalFiniteElementVariantCache< Base >::LocalFiniteElementVariantCache(), Dune::Functions::CompositePreBasis< MI, IMS, SPB >::makeNode(), Dune::Functions::CompositePreBasis< MI, IMS, SPB >::maxNodeSize(), Dune::PDELab::LocalOrderingBase< ES, DI, CI >::node_size(), Dune::MultiTypeBlockMatrix< FirstRow, Args >::operator*=(), Dune::MultiTypeBlockVector< Args >::operator*=(), Dune::MultiTypeBlockMatrix< FirstRow, Args >::operator+=(), Dune::MultiTypeBlockVector< Args >::operator+=(), Dune::MultiTypeBlockMatrix< FirstRow, Args >::operator-=(), Dune::MultiTypeBlockVector< Args >::operator-=(), Dune::MultiTypeBlockMatrix< FirstRow, Args >::operator/=(), Dune::MultiTypeBlockVector< Args >::operator/=(), Dune::operator<<(), Dune::MultiTypeBlockMatrix< FirstRow, Args >::operator=(), Dune::MultiTypeBlockVector< Args >::operator=(), Dune::operator>>(), Dune::TypeTree::HybridTreePath< T >::operator[](), Dune::PDELab::FastDGGridOperator< GFSU, GFSV, LOP, MB, DF, RF, JF, CU, CV >::setupGridOperators(), Dune::PDELab::GridOperator< GFSU, GFSV, LOP, MB, DF, RF, JF, CU, CV >::setupGridOperators(), Dune::SizeCache< GridImp >::size(), Dune::PDELab::CompositeLexicographicOrdering< DI, CI, Children >::size(), Dune::PDELab::CombinedOperator< ApplyOp, Args >::skip_entity(), Dune::PDELab::CombinedOperator< ApplyOp, Args >::skip_intersection(), and Dune::Functions::CompositePreBasis< MI, IMS, SPB >::update().
◆ ifElse() [1/2]
void Dune::Hybrid::ifElse | ( | const Condition & | condition, |
IfFunc && | ifFunc | ||
) |
A conditional expression.
This provides an ifElse conditional with empty else clause.
References Dune::Hybrid::ifElse().
Referenced by Dune::Hybrid::ifElse().
◆ ifElse() [2/2]
decltype(auto) Dune::Hybrid::ifElse | ( | const Condition & | condition, |
IfFunc && | ifFunc, | ||
ElseFunc && | elseFunc | ||
) |
A conditional expression.
This will call either ifFunc or elseFunc depending on the condition. In any case a single argument will be passed to the called function. This will always be the identity function. Passing an expression through this function will lead to lazy evaluation. This way both 'branches' can contain expressions that are only valid within this branch if the condition is a std::integral_constant<bool,*>.
In order to do this, the passed functors must have a single argument of type auto.
Due to the lazy evaluation mechanism and support for std::integral_constant<bool,*> this allows to emulate a static if statement.
References Dune::Hybrid::ifElse().
◆ integralRange() [1/2]
|
constexpr |
Create an integral range.
- Template Parameters
-
Begin Type of begin entry of the range End Type of end entry of the range
- Parameters
-
begin First entry of the range end One past the last entry of the range
- Returns
- An object encoding the given range
If Begin and End are both instances of type std::integral_constant, the returned range encodes begin and end statically.
References Dune::Hybrid::integralRange().
Referenced by Dune::MultiTypeBlockVector< Args >::axpy(), Dune::MultiTypeBlockMatrix< FirstRow, Args >::frobenius_norm2(), Dune::MultiTypeBlockMatrix< FirstRow, Args >::infinity_norm(), Dune::MultiTypeBlockMatrix< FirstRow, Args >::infinity_norm_real(), Dune::MultiTypeBlockMatrix< FirstRow, Args >::operator*=(), Dune::MultiTypeBlockMatrix< FirstRow, Args >::operator+=(), Dune::MultiTypeBlockVector< Args >::operator+=(), Dune::MultiTypeBlockMatrix< FirstRow, Args >::operator-=(), Dune::MultiTypeBlockVector< Args >::operator-=(), Dune::MultiTypeBlockMatrix< FirstRow, Args >::operator/=(), Dune::operator<<(), and Dune::MultiTypeBlockMatrix< FirstRow, Args >::operator=().
◆ integralRange() [2/2]
|
constexpr |
Create an integral range starting from 0.
- Template Parameters
-
End Type of end entry of the range
- Parameters
-
end One past the last entry of the range
- Returns
- An object encoding the given range
This is a short cut for integralRange(_0, end).
References Dune::Indices::_0, and Dune::Hybrid::integralRange().
Referenced by Dune::Hybrid::integralRange().
◆ size()
|
constexpr |
Size query.
- Template Parameters
-
T Type of container whose size is queried
- Parameters
-
t Container whose size is queried
- Returns
- Size of t
If the size of t is known at compile type the size is returned as std::integral_constant<std::size_t, size>. Otherwise the result of t.size() is returned.
Supported types for deriving the size at compile time are:
- instances of std::integer_sequence
- all types std::tuple_size is implemented for
- all typed that have a static method size()
- instances of Dune::FieldVector
References Dune::Hybrid::size().
Referenced by Dune::Hybrid::size().
◆ switchCases() [1/2]
|
constexpr |
Switch statement.
- Template Parameters
-
Cases Type of case range Value Type of value to check against the cases Branches Type of branch function
- Parameters
-
cases A range of cases to check for value The value to check against the cases branches A callback that will be executed with matching entry from case list
Value is checked against all entries of the given range. If one matches, then branches is executed with the matching value as single argument. If the range is an std::integer_sequence, the value is passed as std::integral_constant. If non of the entries matches, then elseBranch is executed without any argument.
◆ switchCases() [2/2]
|
constexpr |
Switch statement.
- Template Parameters
-
Cases Type of case range Value Type of value to check against the cases Branches Type of branch function ElseBranch Type of branch function
- Parameters
-
cases A range of cases to check for value The value to check against the cases branches A callback that will be executed with matching entry from case list elseBranch A callback that will be executed if no other entry matches
Value is checked against all entries of the given range. If one matches, then branches is executed with the matching value as single argument. If the range is an std::integer_sequence, the value is passed as std::integral_constant. If non of the entries matches, then elseBranch is executed without any argument.
Notice that this short circuits, e.g., if one case matches, the others are no longer evaluated.
The return value will be deduced from the else branch.
![Creative Commons License](https://i.creativecommons.org/l/by-sa/4.0/80x15.png)