diff --git a/dumux/linear/istlsolvers.hh b/dumux/linear/istlsolvers.hh index 42dfbf1914e04d1569cf53709977536ec6c2ef42..97f5a8316a25c7c060749b8e3048f4790d05e454 100644 --- a/dumux/linear/istlsolvers.hh +++ b/dumux/linear/istlsolvers.hh @@ -143,16 +143,24 @@ public: { initializeParameters_(paramGroup); #if HAVE_MPI - solverCategory_ = Detail::solverCategory<LinearSolverTraits>(gridView); - if (solverCategory_ != Dune::SolverCategory::sequential) + if constexpr (LinearSolverTraits::canCommunicate) { - parallelHelper_ = std::make_unique<ParallelISTLHelper<LinearSolverTraits>>(gridView, dofMapper); - communication_ = std::make_shared<Comm>(gridView.comm(), solverCategory_); - scalarProduct_ = Dune::createScalarProduct<XVector>(*communication_, solverCategory_); - parallelHelper_->createParallelIndexSet(*communication_); + solverCategory_ = Detail::solverCategory<LinearSolverTraits>(gridView); + if (solverCategory_ != Dune::SolverCategory::sequential) + { + parallelHelper_ = std::make_unique<ParallelISTLHelper<LinearSolverTraits>>(gridView, dofMapper); + communication_ = std::make_shared<Comm>(gridView.comm(), solverCategory_); + scalarProduct_ = Dune::createScalarProduct<XVector>(*communication_, solverCategory_); + parallelHelper_->createParallelIndexSet(*communication_); + } + else + scalarProduct_ = std::make_shared<ScalarProduct>(); } else + { + solverCategory_ = Dune::SolverCategory::sequential; scalarProduct_ = std::make_shared<ScalarProduct>(); + } #else solverCategory_ = Dune::SolverCategory::sequential; scalarProduct_ = std::make_shared<ScalarProduct>(); @@ -174,10 +182,13 @@ public: solverCategory_ = Detail::solverCategory(gridView); scalarProduct_ = scalarProduct; communication_ = communication; - if (solverCategory_ != Dune::SolverCategory::sequential) + if constexpr (LinearSolverTraits::canCommunicate) { - parallelHelper_ = std::make_unique<ParallelISTLHelper<LinearSolverTraits>>(gridView, dofMapper); - parallelHelper_->createParallelIndexSet(communication); + if (solverCategory_ != Dune::SolverCategory::sequential) + { + parallelHelper_ = std::make_unique<ParallelISTLHelper<LinearSolverTraits>>(gridView, dofMapper); + parallelHelper_->createParallelIndexSet(communication); + } } } #endif