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 403 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::ILUT:
392 // TODO for this preconditioner further options can be passed.
393 // see
394 // https://libeigen.gitlab.io/docs/classEigen_1_1IncompleteLUT.html
395 return createIterativeSolver<Solver,
396 Eigen::IncompleteLUT<double>>();
397 default:
398 OGS_FATAL("Invalid Eigen preconditioner type.");
399 }
400}
#define OGS_FATAL(...)
Definition Error.h:26
std::unique_ptr< EigenLinearSolverBase > createIterativeSolver()

References createIterativeSolver(), MathLib::EigenOption::DIAGONAL, MathLib::EigenOption::ILUT, 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 405 of file EigenLinearSolver.cpp.

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

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