Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parameter management utilities #163

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from
10 changes: 7 additions & 3 deletions resolve/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ add_subdirectory(utilities)
# C++ files
set(ReSolve_SRC
LinSolver.cpp
LinSolverDirect.cpp
LinSolverIterative.cpp
GramSchmidt.cpp
LinSolverIterativeFGMRES.cpp
LinSolverDirectCpuILU0.cpp
Expand All @@ -36,23 +38,25 @@ set(ReSolve_CUDASDK_SRC

# C++ code that links to ROCm libraries
set(ReSolve_ROCM_SRC
LinSolverDirectRocSolverRf.cpp
LinSolverDirectRocSparseILU0.cpp
LinSolverDirectRocSolverRf.cpp
LinSolverDirectRocSparseILU0.cpp
)

# Header files to be installed
set(ReSolve_HEADER_INSTALL
Common.hpp
cusolver_defs.hpp
LinSolver.hpp
LinSolverDirect.hpp
LinSolverIterative.hpp
LinSolverIterativeFGMRES.hpp
LinSolverDirectCpuILU0.hpp
SystemSolver.hpp
GramSchmidt.hpp
MemoryUtils.hpp)

set(ReSolve_KLU_HEADER_INSTALL
LinSolverDirectKLU.hpp
LinSolverDirectKLU.hpp
)

set(ReSolve_LUSOL_HEADER_INSTALL
Expand Down
6 changes: 1 addition & 5 deletions resolve/Common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@ namespace ReSolve {
constexpr double EPSMAC = 1.0e-16;


// TODO: let cmake manage these. combined with the todo above relating to cstdint
// this is related to resolve/lusol/lusol_precision.f90. whatever is here should
// have an equivalent there

// NOTE: i'd love to make this std::float64_t but we're not on c++23
/// @todo Provide CMake option to se these types at config time
using real_type = double;
using index_type = std::int32_t;

Expand Down
179 changes: 14 additions & 165 deletions resolve/LinSolver.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/**
* @file LinSolverIterative.cpp
* @author Kasia Swirydowicz ([email protected])
* @author Slaven Peles ([email protected])
* @brief Implementation of linear solver base class.
*
*/

#include <resolve/matrix/Sparse.hpp>
#include <resolve/utilities/logger/Logger.hpp>

Expand All @@ -23,173 +31,14 @@ namespace ReSolve
return 1.0;
}

//
// Direct solver methods implementations
//

LinSolverDirect::LinSolverDirect()
{
L_ = nullptr;
U_ = nullptr;
P_ = nullptr;
Q_ = nullptr;
}

LinSolverDirect::~LinSolverDirect()
int LinSolver::getParamId(std::string id)
{
}

int LinSolverDirect::setup(matrix::Sparse* A,
matrix::Sparse* /* L */,
matrix::Sparse* /* U */,
index_type* /* P */,
index_type* /* Q */,
vector_type* /* rhs */)
{
if (A == nullptr) {
return 1;
auto it = params_list_.find(id);
if (it == params_list_.end()) {
out::error() << "Unknown parameter " << id << ".\n";
return 999;
}
this->A_ = A;
return 0;
}

int LinSolverDirect::analyze()
{
return 1;
} //the same as symbolic factorization

int LinSolverDirect::factorize()
{
return 1;
}

int LinSolverDirect::refactorize()
{
return 1;
}

matrix::Sparse* LinSolverDirect::getLFactor()
{
return nullptr;
}

matrix::Sparse* LinSolverDirect::getUFactor()
{
return nullptr;
}

index_type* LinSolverDirect::getPOrdering()
{
return nullptr;
}

index_type* LinSolverDirect::getQOrdering()
{
return nullptr;
}

void LinSolverDirect::setPivotThreshold(real_type tol)
{
pivot_threshold_tol_ = tol;
}

void LinSolverDirect::setOrdering(int ordering)
{
ordering_ = ordering;
}

void LinSolverDirect::setHaltIfSingular(bool is_halt)
{
halt_if_singular_ = is_halt;
}

real_type LinSolverDirect::getMatrixConditionNumber()
{
out::error() << "Solver does not implement returning system matrix condition number.\n";
return -1.0;
}

//
// Iterative solver methods implementations
//

LinSolverIterative::LinSolverIterative()
{
}

LinSolverIterative::~LinSolverIterative()
{
}

int LinSolverIterative::setup(matrix::Sparse* A)
{
if (A == nullptr) {
return 1;
}
this->A_ = A;
return 0;
}

real_type LinSolverIterative::getFinalResidualNorm() const
{
return final_residual_norm_;
}

real_type LinSolverIterative::getInitResidualNorm() const
{
return initial_residual_norm_;
}

index_type LinSolverIterative::getNumIter() const
{
return total_iters_;
}


real_type LinSolverIterative::getTol()
{
return tol_;
}

index_type LinSolverIterative::getMaxit()
{
return maxit_;
}

index_type LinSolverIterative::getRestart()
{
return restart_;
}

index_type LinSolverIterative::getConvCond()
{
return conv_cond_;
}

bool LinSolverIterative::getFlexible()
{
return flexible_;
}

int LinSolverIterative::setOrthogonalization(GramSchmidt* /* gs */)
{
out::error() << "Solver does not implement setting orthogonalization.\n";
return 1;
}

void LinSolverIterative::setTol(real_type new_tol)
{
this->tol_ = new_tol;
}

void LinSolverIterative::setMaxit(index_type new_maxit)
{
this->maxit_ = new_maxit;
}

void LinSolverIterative::setConvCond(index_type new_conv_cond)
{
this->conv_cond_ = new_conv_cond;
return (*it).second;
}
}

Expand Down
Loading