Skip to content
Snippets Groups Projects
Commit 1ecef7c8 authored by Tom Fischer's avatar Tom Fischer
Browse files

[MaL/LA/Eigen] Rm. unnecessary constructor / setOption.

parent 0fbee00e
No related branches found
No related tags found
No related merge requests found
......@@ -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("------------------------------------------------------------------");
......
......@@ -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
*/
......
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