Commit a5568018 authored by Carsten Gräser's avatar Carsten Gräser
Browse files

Add support for dynamic container of local solvers

This allows to have different local solvers in `NonlinearGSStep`.
The feature existed before but was restricted to statically sized
containers. This patch adds support for dynamically sized ones.
parent ca025a83
Pipeline #43258 passed with stage
in 9 minutes and 47 seconds
......@@ -15,6 +15,19 @@
namespace Dune {
namespace TNNMG {
namespace Impl {
template<class C, class = void>
struct IsContainer : std::false_type {};
template<class C>
struct IsContainer<C, std::void_t<decltype(std::declval<C>().size())>> : std::true_type {};
template<class C>
constexpr bool IsHybridContainer_v = Impl::IsContainer<C>::value or IsTuple<C>::value;
}
......@@ -50,7 +63,7 @@ private:
* recursively inside of a localSolver.
*/
template<class V, class F, class BV, class LS,
std::enable_if_t<not IsTuple<LS>::value, int> = 0>
std::enable_if_t<not Impl::IsHybridContainer_v<LS>, int> = 0>
void gaussSeidelLoop(V& x, const F& f, const BV& ignore, const LS& localSolver)
{
namespace H = Dune::Hybrid;
......@@ -87,17 +100,11 @@ void gaussSeidelLoop(V& x, const F& f, const BV& ignore, const LS& localSolver)
* recursively inside of a localSolver.
*/
template<class V, class F, class BV, class LS,
std::enable_if_t<IsTuple<LS>::value, int> = 0>
std::enable_if_t<Impl::IsHybridContainer_v<LS>, int> = 0>
void gaussSeidelLoop(V& x, const F& f, const BV& ignore, const LS& localSolvers)
{
namespace H = Dune::Hybrid;
// Clang 3.8 refuses to recognise H::size as constant here, so that
// we need to use the decltype(...)::value kludge
static_assert(decltype(H::size(x))::value == decltype(H::size(localSolvers))::value,
"Size of local solver tuple provided to gaussSeidelLoop does not "
"match size of problem.");
auto&& shiftedF = shift(f, x);
H::forEach(H::integralRange(H::size(x)), [&](auto&& i) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment