Skip to content
Snippets Groups Projects
Commit 7d435278 authored by Lisa Julia Nebel's avatar Lisa Julia Nebel
Browse files

Adapt the solver in the Riemannian Proximal Newton solver:

Use cholmod if the dune-solvers version >= 2.8, use umfpack for older versions
parent 05b545c3
No related branches found
No related tags found
1 merge request!81Fix error in surfacecosseratenergy
......@@ -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);
// //////////////////////////////////////////////////////////////////////////////////////
......
......@@ -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_;
......
......@@ -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++) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment