From 7d435278045b41f21e2f151f35a4bc5b2d1e8f87 Mon Sep 17 00:00:00 2001 From: Lisa Julia Nebel <lisa_julia.nebel@tu-dresden.de> Date: Fri, 9 Jul 2021 10:01:34 +0200 Subject: [PATCH] Adapt the solver in the Riemannian Proximal Newton solver: Use cholmod if the dune-solvers version >= 2.8, use umfpack for older versions --- dune/gfe/riemannianpnsolver.cc | 13 +++++++++++-- dune/gfe/riemannianpnsolver.hh | 11 +++++++++-- src/cosserat-continuum.cc | 4 ---- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/dune/gfe/riemannianpnsolver.cc b/dune/gfe/riemannianpnsolver.cc index bb7dc9c6..68841b25 100644 --- a/dune/gfe/riemannianpnsolver.cc +++ b/dune/gfe/riemannianpnsolver.cc @@ -11,8 +11,13 @@ #include <dune/fufem/assemblers/localassemblers/massassembler.hh> #include <dune/fufem/assemblers/basisinterpolationmatrixassembler.hh> -// Using a cholmod solver as the inner solver +#if DUNE_VERSION_GTE(DUNE_SOLVERS, 2, 8) +// Using a cholmod solver as the inner solver, available only since 2.8 #include <dune/solvers/solvers/cholmodsolver.hh> +#else +// Using a umfpack solver as the inner solver +#include <dune/solvers/solvers/umfpacksolver.hh> +#endif #include <dune/solvers/norms/twonorm.hh> #include <dune/solvers/norms/h1seminorm.hh> @@ -96,8 +101,12 @@ setup(const GridType& grid, ////////////////////////////////////////////////////////////////// // Create the inner solver using a cholmod solver ////////////////////////////////////////////////////////////////// - +#if DUNE_VERSION_GTE(DUNE_SOLVERS, 2, 8) innerSolver_ = std::make_shared<Dune::Solvers::CholmodSolver<MatrixType,CorrectionType> >(); +#else + std::cout << "using umfpacksolver" << std::endl; + innerSolver_ = std::make_shared<Dune::Solvers::UMFPackSolver<MatrixType,CorrectionType> >(); +#endif innerSolver_->setIgnore(*globalDirichletNodes); // ////////////////////////////////////////////////////////////////////////////////////// diff --git a/dune/gfe/riemannianpnsolver.hh b/dune/gfe/riemannianpnsolver.hh index f802bd81..c640311b 100644 --- a/dune/gfe/riemannianpnsolver.hh +++ b/dune/gfe/riemannianpnsolver.hh @@ -13,7 +13,11 @@ #include <dune/solvers/common/boxconstraint.hh> #include <dune/solvers/norms/h1seminorm.hh> #include <dune/solvers/solvers/iterativesolver.hh> +#if DUNE_VERSION_GTE(DUNE_SOLVERS, 2, 8) #include <dune/solvers/solvers/cholmodsolver.hh> +#else +#include <dune/solvers/solvers/umfpacksolver.hh> +#endif #include <dune/gfe/periodic1dpq1nodalbasis.hh> @@ -67,7 +71,7 @@ public: hessianMatrix_(nullptr), h1SemiNorm_(NULL) {} - /** \brief Set up the solver using a choldmod solver as the inner solver */ + /** \brief Set up the solver using a choldmod or umfpack solver as the inner solver */ void setup(const GridType& grid, const Assembler* assembler, const SolutionType& x, @@ -123,8 +127,11 @@ protected: const Assembler* assembler_; /** \brief The solver for the quadratic inner problems */ +#if DUNE_VERSION_GTE(DUNE_SOLVERS, 2, 8) std::shared_ptr<typename Dune::Solvers::CholmodSolver<MatrixType,CorrectionType>> innerSolver_; - +#else + std::shared_ptr<typename Dune::Solvers::UMFPackSolver<MatrixType,CorrectionType>> innerSolver_; +#endif /** \brief The Dirichlet nodes */ const Dune::BitSetVector<blocksize>* ignoreNodes_; diff --git a/src/cosserat-continuum.cc b/src/cosserat-continuum.cc index 21e564b5..83e5819d 100644 --- a/src/cosserat-continuum.cc +++ b/src/cosserat-continuum.cc @@ -575,9 +575,6 @@ int main (int argc, char *argv[]) try solver.solve(); xTargetSpace = solver.getSol(); } else { //parameterSet.get<std::string>("solvertype") == "proximalNewton" -#if DUNE_VERSION_LT(DUNE_COMMON, 2, 8) - DUNE_THROW(Exception, "Please install dune-solvers >= 2.8 to use the Proximal Newton Solver with Cholmod!"); -#else RiemannianProximalNewtonSolver<DeformationFEBasis, TargetSpace> solver; solver.setup(*grid, &assembler, @@ -590,7 +587,6 @@ int main (int argc, char *argv[]) try solver.setInitialIterate(xTargetSpace); solver.solve(); xTargetSpace = solver.getSol(); -#endif } for (int i = 0; i < xTargetSpace.size(); i++) { -- GitLab