OGS
MathLib::details Namespace Reference

Classes

class  EigenDirectLinearSolver
 Template class for Eigen direct linear solvers. More...
 
class  EigenIterativeLinearSolver
 Template class for Eigen iterative linear solvers. More...
 

Typedefs

template<typename Mat , typename Precon >
using EigenCGSolver = Eigen::ConjugateGradient<Mat, Eigen::Lower, Precon>
 

Functions

template<template< typename, typename > class Solver, typename Precon >
std::unique_ptr< EigenLinearSolverBasecreateIterativeSolver ()
 
template<template< typename, typename > class Solver>
std::unique_ptr< EigenLinearSolverBasecreateIterativeSolver (EigenOption::PreconType precon_type)
 
std::unique_ptr< EigenLinearSolverBasecreateIterativeSolver (EigenOption::SolverType solver_type, EigenOption::PreconType precon_type)
 

Typedef Documentation

◆ EigenCGSolver

template<typename Mat , typename Precon >
using MathLib::details::EigenCGSolver = Eigen::ConjugateGradient<Mat, Eigen::Lower, Precon>

Definition at line 406 of file EigenLinearSolver.cpp.

Function Documentation

◆ createIterativeSolver() [1/3]

template<template< typename, typename > class Solver, typename Precon >
std::unique_ptr< EigenLinearSolverBase > MathLib::details::createIterativeSolver ( )

Definition at line 372 of file EigenLinearSolver.cpp.

373{
374 using Slv =
376 return std::make_unique<Slv>();
377}
Template class for Eigen iterative linear solvers.

Referenced by MathLib::EigenLinearSolver::EigenLinearSolver(), createIterativeSolver(), and createIterativeSolver().

◆ createIterativeSolver() [2/3]

template<template< typename, typename > class Solver>
std::unique_ptr< EigenLinearSolverBase > MathLib::details::createIterativeSolver ( EigenOption::PreconType precon_type)

Definition at line 380 of file EigenLinearSolver.cpp.

382{
383 switch (precon_type)
384 {
385 case EigenOption::PreconType::NONE:
386 return createIterativeSolver<Solver,
387 Eigen::IdentityPreconditioner>();
388 case EigenOption::PreconType::DIAGONAL:
390 Solver, Eigen::DiagonalPreconditioner<double>>();
391 case EigenOption::PreconType::LeastSquareDIAGONAL:
393 Solver, Eigen::LeastSquareDiagonalPreconditioner<double>>();
394 case EigenOption::PreconType::ILUT:
395 // TODO for this preconditioner further options can be passed.
396 // see
397 // https://libeigen.gitlab.io/docs/classEigen_1_1IncompleteLUT.html
398 return createIterativeSolver<Solver,
399 Eigen::IncompleteLUT<double>>();
400 default:
401 OGS_FATAL("Invalid Eigen preconditioner type.");
402 }
403}
#define OGS_FATAL(...)
Definition Error.h:26
std::unique_ptr< EigenLinearSolverBase > createIterativeSolver()

References createIterativeSolver(), MathLib::EigenOption::DIAGONAL, MathLib::EigenOption::ILUT, MathLib::EigenOption::LeastSquareDIAGONAL, MathLib::EigenOption::NONE, and OGS_FATAL.

◆ createIterativeSolver() [3/3]

std::unique_ptr< EigenLinearSolverBase > MathLib::details::createIterativeSolver ( EigenOption::SolverType solver_type,
EigenOption::PreconType precon_type )

Definition at line 408 of file EigenLinearSolver.cpp.

410{
411 switch (solver_type)
412 {
413 case EigenOption::SolverType::BiCGSTAB:
414 {
415 return createIterativeSolver<Eigen::BiCGSTAB>(precon_type);
416 }
417 case EigenOption::SolverType::BiCGSTABL:
418 {
419#ifdef USE_EIGEN_UNSUPPORTED
420#if EIGEN_VERSION_AT_LEAST(3, 4, 90)
421 return createIterativeSolver<Eigen::BiCGSTABL>(precon_type);
422#else
423 OGS_FATAL("BiCGSTABL requires at least Eigen version 3.4.90");
424#endif
425#else
426 OGS_FATAL(
427 "The code is not compiled with the Eigen unsupported modules. "
428 "Linear solver type BiCGSTABL is not available.");
429#endif
430 }
431 case EigenOption::SolverType::CG:
432 {
433 return createIterativeSolver<EigenCGSolver>(precon_type);
434 }
435 case EigenOption::SolverType::LeastSquareCG:
436 {
437 return createIterativeSolver<Eigen::LeastSquaresConjugateGradient>(
438 precon_type);
439 }
440 case EigenOption::SolverType::GMRES:
441 {
442#ifdef USE_EIGEN_UNSUPPORTED
443 return createIterativeSolver<Eigen::GMRES>(precon_type);
444#else
445 OGS_FATAL(
446 "The code is not compiled with the Eigen unsupported modules. "
447 "Linear solver type GMRES is not available.");
448#endif
449 }
450 case EigenOption::SolverType::IDRS:
451 {
452#ifdef USE_EIGEN_UNSUPPORTED
453#if EIGEN_VERSION_AT_LEAST(3, 4, 90)
454 return createIterativeSolver<Eigen::IDRS>(precon_type);
455#else
456 OGS_FATAL("IDRS requires at least Eigen version 3.4.90");
457#endif
458#else
459 OGS_FATAL(
460 "The code is not compiled with the Eigen unsupported modules. "
461 "Linear solver type IDRS is not available.");
462#endif
463 }
464 case EigenOption::SolverType::IDRSTABL:
465 {
466#ifdef USE_EIGEN_UNSUPPORTED
467#if EIGEN_VERSION_AT_LEAST(3, 4, 90)
468 return createIterativeSolver<Eigen::IDRSTABL>(precon_type);
469#else
470 OGS_FATAL("IDRSTABL requires at least Eigen version 3.4.90");
471#endif
472#else
473 OGS_FATAL(
474 "The code is not compiled with the Eigen unsupported modules. "
475 "Linear solver type IDRSTABL is not available.");
476#endif
477 }
478 default:
479 OGS_FATAL("Invalid Eigen iterative linear solver type. Aborting.");
480 }
481}

References MathLib::EigenOption::BiCGSTAB, MathLib::EigenOption::BiCGSTABL, MathLib::EigenOption::CG, createIterativeSolver(), MathLib::EigenOption::GMRES, MathLib::EigenOption::IDRS, MathLib::EigenOption::IDRSTABL, MathLib::EigenOption::LeastSquareCG, and OGS_FATAL.