diff --git a/MathLib/LinAlg/Eigen/EigenLinearSolver.cpp b/MathLib/LinAlg/Eigen/EigenLinearSolver.cpp index 068239b55919f6d9f73eaf8dd884434a8b5a45da..60475aa4a5c7248011ec0402e819bbf8e84486ae 100644 --- a/MathLib/LinAlg/Eigen/EigenLinearSolver.cpp +++ b/MathLib/LinAlg/Eigen/EigenLinearSolver.cpp @@ -23,11 +23,9 @@ #include <unsupported/Eigen/src/IterativeSolvers/Scaling.h> #endif -#include "BaseLib/ConfigTree.h" #include "EigenMatrix.h" #include "EigenTools.h" #include "EigenVector.h" -#include "MathLib/LinAlg/LinearSolverOptions.h" namespace MathLib { @@ -219,51 +217,6 @@ std::unique_ptr<EigenLinearSolverBase> createIterativeSolver( } // namespace details -EigenLinearSolver::EigenLinearSolver(const std::string& /*solver_name*/, - const BaseLib::ConfigTree* const option) -{ - using Matrix = EigenMatrix::RawMatrixType; - - if (option) - { - setOption(*option); - } - - // TODO for my taste it is much too unobvious that the default solver type - // currently is SparseLU. - switch (option_.solver_type) - { - case EigenOption::SolverType::SparseLU: - { - using SolverType = - Eigen::SparseLU<Matrix, Eigen::COLAMDOrdering<int>>; - solver_ = std::make_unique< - details::EigenDirectLinearSolver<SolverType>>(); - return; - } - case EigenOption::SolverType::BiCGSTAB: - case EigenOption::SolverType::CG: - case EigenOption::SolverType::GMRES: - solver_ = details::createIterativeSolver(option_.solver_type, - option_.precon_type); - return; - case EigenOption::SolverType::PardisoLU: - { -#ifdef USE_MKL - using SolverType = Eigen::PardisoLU<EigenMatrix::RawMatrixType>; - solver_.reset(new details::EigenDirectLinearSolver<SolverType>); - return; -#else - OGS_FATAL( - "The code is not compiled with Intel MKL. Linear solver type " - "PardisoLU is not available."); -#endif - } - } - - OGS_FATAL("Invalid Eigen linear solver type. Aborting."); -} - EigenLinearSolver::EigenLinearSolver(std::string const& /*solver_name*/, EigenOption const& option) : option_(option) @@ -305,66 +258,6 @@ EigenLinearSolver::EigenLinearSolver(std::string const& /*solver_name*/, EigenLinearSolver::~EigenLinearSolver() = default; -void EigenLinearSolver::setOption(BaseLib::ConfigTree const& option) -{ - ignoreOtherLinearSolvers(option, "eigen"); - //! \ogs_file_param{prj__linear_solvers__linear_solver__eigen} - auto const ptSolver = option.getConfigSubtreeOptional("eigen"); - if (!ptSolver) - { - return; - } - - if (auto solver_type = - //! \ogs_file_param{prj__linear_solvers__linear_solver__eigen__solver_type} - ptSolver->getConfigParameterOptional<std::string>("solver_type")) - { - option_.solver_type = MathLib::EigenOption::getSolverType(*solver_type); - } - if (auto precon_type = - //! \ogs_file_param{prj__linear_solvers__linear_solver__eigen__precon_type} - ptSolver->getConfigParameterOptional<std::string>("precon_type")) - { - option_.precon_type = MathLib::EigenOption::getPreconType(*precon_type); - } - if (auto error_tolerance = - //! \ogs_file_param{prj__linear_solvers__linear_solver__eigen__error_tolerance} - ptSolver->getConfigParameterOptional<double>("error_tolerance")) - { - option_.error_tolerance = *error_tolerance; - } - if (auto max_iteration_step = - //! \ogs_file_param{prj__linear_solvers__linear_solver__eigen__max_iteration_step} - ptSolver->getConfigParameterOptional<int>("max_iteration_step")) - { - option_.max_iterations = *max_iteration_step; - } - if (auto scaling = - //! \ogs_file_param{prj__linear_solvers__linear_solver__eigen__scaling} - ptSolver->getConfigParameterOptional<bool>("scaling")) - { -#ifdef USE_EIGEN_UNSUPPORTED - option_.scaling = *scaling; -#else - OGS_FATAL( - "The code is not compiled with the Eigen unsupported modules. " - "scaling is not available."); -#endif - } - if (auto restart = - //! \ogs_file_param{prj__linear_solvers__linear_solver__eigen__restart} - ptSolver->getConfigParameterOptional<int>("restart")) - { -#ifdef USE_EIGEN_UNSUPPORTED - option_.restart = *restart; -#else - OGS_FATAL( - "The code is not compiled with the Eigen unsupported modules. " - "GMRES/GMRES option restart is not available."); -#endif - } -} - bool EigenLinearSolver::solve(EigenMatrix& A, EigenVector& b, EigenVector& x) { INFO("------------------------------------------------------------------"); diff --git a/MathLib/LinAlg/Eigen/EigenLinearSolver.h b/MathLib/LinAlg/Eigen/EigenLinearSolver.h index 976f8402d879ea28f65047d3f321e20473bdc3ca..f9e082b88f275768475e1ae915d63a8fdf030b3e 100644 --- a/MathLib/LinAlg/Eigen/EigenLinearSolver.h +++ b/MathLib/LinAlg/Eigen/EigenLinearSolver.h @@ -15,11 +15,6 @@ #include "EigenOption.h" -namespace BaseLib -{ -class ConfigTree; -} - namespace MathLib { class EigenMatrix; @@ -34,15 +29,6 @@ public: * Constructor * @param solver_name A name used as a prefix for command line options * if there are such options available. - * @param option A pointer to a linear solver option. In case you omit - * this argument, default settings follow those of - * LisOption struct. - */ - EigenLinearSolver(const std::string& solver_name, - BaseLib::ConfigTree const* const option); - - /** - * Constructor * @param option Eigen linear solver options. */ explicit EigenLinearSolver(std::string const& solver_name, @@ -50,11 +36,6 @@ public: ~EigenLinearSolver(); - /** - * parse linear solvers configuration - */ - void setOption(const BaseLib::ConfigTree& option); - /** * copy linear solvers options */