SolverOptions.h
Go to the documentation of this file.
/******************************************************************************
*
* Copyright (c) 2003-2020 by The University of Queensland
* http://www.uq.edu.au
*
* Primary Business: Queensland, Australia
* Licensed under the Apache License, version 2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Development until 2012 by Earth Systems Science Computational Center (ESSCC)
* Development 2012-2013 by School of Earth Sciences
* Development from 2014-2017 by Centre for Geoscience Computing (GeoComp)
* Development from 2019 by School of Earth and Environmental Sciences
**
*****************************************************************************/
#ifndef __ESCRIPT_SOLVEROPTIONS_H__
#define __ESCRIPT_SOLVEROPTIONS_H__
#include <boost/python/dict.hpp>
#include <boost/python/object.hpp>
#include "system_dep.h"
namespace escript {
enum SolverOptions
{
SO_DEFAULT,
// Solver targets
SO_TARGET_CPU,
SO_TARGET_GPU,
// Solver packages
SO_PACKAGE_MKL,
SO_PACKAGE_PASO,
SO_PACKAGE_TRILINOS,
SO_PACKAGE_UMFPACK,
SO_PACKAGE_MUMPS,
// Solver methods
SO_METHOD_BICGSTAB,
SO_METHOD_CGLS,
SO_METHOD_CGS,
SO_METHOD_CHOLEVSKY,
SO_METHOD_CR,
SO_METHOD_DIRECT,
SO_METHOD_DIRECT_MUMPS,
SO_METHOD_DIRECT_PARDISO,
SO_METHOD_DIRECT_SUPERLU,
SO_METHOD_DIRECT_TRILINOS,
SO_METHOD_GMRES,
SO_METHOD_HRZ_LUMPING,
SO_METHOD_ITERATIVE,
SO_METHOD_LSQR,
SO_METHOD_MINRES,
SO_METHOD_NONLINEAR_GMRES,
SO_METHOD_PCG,
SO_METHOD_PRES20,
SO_METHOD_ROWSUM_LUMPING,
SO_METHOD_TFQMR,
// Preconditioners
SO_PRECONDITIONER_AMG,
SO_PRECONDITIONER_GAUSS_SEIDEL,
SO_PRECONDITIONER_ILU0,
SO_PRECONDITIONER_ILUT,
SO_PRECONDITIONER_JACOBI,
SO_PRECONDITIONER_NONE,
SO_PRECONDITIONER_REC_ILU,
SO_PRECONDITIONER_RILU,
// ODE solvers
SO_ODESOLVER_BACKWARD_EULER,
SO_ODESOLVER_CRANK_NICOLSON,
SO_ODESOLVER_LINEAR_CRANK_NICOLSON,
// Interpolation methods
SO_INTERPOLATION_CLASSIC,
SO_INTERPOLATION_CLASSIC_WITH_FF_COUPLING,
SO_INTERPOLATION_DIRECT,
SO_REORDERING_DEFAULT,
SO_REORDERING_MINIMUM_FILL_IN,
SO_REORDERING_NESTED_DISSECTION,
SO_REORDERING_NONE
};
inline bool isDirectSolver(const SolverOptions& method)
{
switch (method) {
case SO_METHOD_DIRECT:
case SO_METHOD_DIRECT_MUMPS:
case SO_METHOD_DIRECT_PARDISO:
case SO_METHOD_DIRECT_SUPERLU:
case SO_METHOD_DIRECT_TRILINOS:
return true;
default:
break;
}
return false;
}
class ESCRIPT_DLL_API SolverBuddy
{
public:
SolverBuddy();
~SolverBuddy();
std::string getSummary() const;
const char* getName(int key) const;
void resetDiagnostics(bool all=false);
void updateDiagnosticsPy(const std::string& key,
const boost::python::object& value);
void updateDiagnostics(const std::string& key, bool value);
void updateDiagnostics(const std::string& key, int value);
void updateDiagnostics(const std::string& key, double value);
double getDiagnostics(const std::string name) const;
bool hasConverged() const;
void setPreconditioner(int preconditioner);
SolverOptions getPreconditioner() const;
void setSolverMethod(int method);
SolverOptions getSolverMethod() const;
void setPackage(int package);
SolverOptions getPackage() const;
void setReordering(int ordering);
SolverOptions getReordering() const;
void setRestart(int restart);
int getRestart() const;
int _getRestartForC() const;
void setTruncation(int truncation);
int getTruncation() const;
void setInnerIterMax(int iter_max);
int getInnerIterMax() const;
void setIterMax(int iter_max);
int getIterMax() const;
void setNumSweeps(int sweeps);
int getNumSweeps() const;
void setTolerance(double rtol);
double getTolerance() const;
void setAbsoluteTolerance(double atol);
double getAbsoluteTolerance() const;
void setInnerTolerance(double rtol);
double getInnerTolerance() const;
void setDropTolerance(double drop_tol);
double getDropTolerance() const;
void setDropStorage(double drop);
double getDropStorage() const;
void setRelaxationFactor(double factor);
double getRelaxationFactor() const;
bool isComplex() const;
void setComplex(bool complex);
bool isSymmetric() const;
void setSymmetryOn();
void setSymmetryOff();
void setSymmetry(bool symmetry);
bool isHermitian() const;
void setHermitianOn();
void setHermitianOff();
void setHermitian(bool hermitian);
bool isVerbose() const;
void setVerbosityOn();
void setVerbosityOff();
void setVerbosity(bool verbose);
bool adaptInnerTolerance() const;
void setInnerToleranceAdaptionOn();
void setInnerToleranceAdaptionOff();
void setInnerToleranceAdaption(bool adaption);
bool acceptConvergenceFailure() const;
void setAcceptanceConvergenceFailureOn();
void setAcceptanceConvergenceFailureOff();
void setAcceptanceConvergenceFailure(bool acceptance);
bool useLocalPreconditioner() const;
void setLocalPreconditionerOn();
void setLocalPreconditionerOff();
void setLocalPreconditioner(bool local);
void setNumRefinements(int refinements);
int getNumRefinements() const;
void setODESolver(int solver);
SolverOptions getODESolver() const;
void setTrilinosParameter(const std::string& name,
const boost::python::object& value);
boost::python::dict getTrilinosParameters() const;
void setDim(int dim);
int getDim();
bool using_default_method() const;
protected:
boost::python::dict trilinosParams;
SolverOptions target;
SolverOptions package;
SolverOptions method;
SolverOptions preconditioner;
SolverOptions ode_solver;
SolverOptions reordering;
int sweeps;
double tolerance;
double absolute_tolerance;
double inner_tolerance;
double drop_tolerance;
double drop_storage;
int iter_max;
int inner_iter_max;
int truncation;
int restart; //0 will have to be None in python, will get tricky
bool is_complex;
bool symmetric;
bool hermitian;
bool verbose;
bool adapt_inner_tolerance;
bool accept_convergence_failure;
double relaxation;
bool use_local_preconditioner;
int refinements;
int dim; // Dimension of the problem, either 2 or 3. Used internally
int num_iter;
int num_level;
int num_inner_iter;
double time;
double set_up_time;
double net_time;
double residual_norm;
bool converged;
int preconditioner_size;
bool time_step_backtracking_used;
double coarse_level_sparsity;
int num_coarse_unknowns;
int cum_num_inner_iter;
int cum_num_iter;
double cum_time;
double cum_set_up_time;
double cum_net_time;
bool using_default_solver_method;
};
typedef boost::shared_ptr<SolverBuddy> SB_ptr;
} // namespace escript
#endif // __ESCRIPT_SOLVEROPTIONS_H__
escript::SolverBuddy
Definition: SolverOptions.h:161
escript::SolverBuddy::is_complex
bool is_complex
Definition: SolverOptions.h:725
escript::SolverBuddy::converged
bool converged
Definition: SolverOptions.h:743
escript::SolverBuddy::residual_norm
double residual_norm
Definition: SolverOptions.h:742
escript::SolverBuddy::time_step_backtracking_used
bool time_step_backtracking_used
Definition: SolverOptions.h:745
escript::SolverBuddy::accept_convergence_failure
bool accept_convergence_failure
Definition: SolverOptions.h:730
escript::SolverBuddy::time
double time
Definition: SolverOptions.h:739
escript::SolverBuddy::reordering
SolverOptions reordering
Definition: SolverOptions.h:714
escript::SolverBuddy::num_iter
int num_iter
Definition: SolverOptions.h:736
escript::SolverBuddy::method
SolverOptions method
Definition: SolverOptions.h:711
escript::SolverBuddy::truncation
int truncation
Definition: SolverOptions.h:723
escript::SolverBuddy::set_up_time
double set_up_time
Definition: SolverOptions.h:740
escript::SolverBuddy::verbose
bool verbose
Definition: SolverOptions.h:728
escript::SolverBuddy::drop_tolerance
double drop_tolerance
Definition: SolverOptions.h:719
escript::SolverBuddy::cum_num_inner_iter
int cum_num_inner_iter
Definition: SolverOptions.h:748
escript::SolverBuddy::cum_net_time
double cum_net_time
Definition: SolverOptions.h:752
escript::SolverBuddy::num_inner_iter
int num_inner_iter
Definition: SolverOptions.h:738
escript::SolverBuddy::cum_num_iter
int cum_num_iter
Definition: SolverOptions.h:749
escript::SolverBuddy::tolerance
double tolerance
Definition: SolverOptions.h:716
escript::SolverBuddy::sweeps
int sweeps
Definition: SolverOptions.h:715
escript::SolverBuddy::drop_storage
double drop_storage
Definition: SolverOptions.h:720
escript::SolverBuddy::dim
int dim
Definition: SolverOptions.h:734
escript::SolverBuddy::preconditioner
SolverOptions preconditioner
Definition: SolverOptions.h:712
escript::SolverBuddy::use_local_preconditioner
bool use_local_preconditioner
Definition: SolverOptions.h:732
escript::SolverBuddy::using_default_solver_method
bool using_default_solver_method
Definition: SolverOptions.h:754
escript::SolverBuddy::absolute_tolerance
double absolute_tolerance
Definition: SolverOptions.h:717
escript::SolverBuddy::hermitian
bool hermitian
Definition: SolverOptions.h:727
escript::SolverBuddy::inner_tolerance
double inner_tolerance
Definition: SolverOptions.h:718
escript::SolverBuddy::iter_max
int iter_max
Definition: SolverOptions.h:721
escript::SolverBuddy::inner_iter_max
int inner_iter_max
Definition: SolverOptions.h:722
escript::SolverBuddy::target
SolverOptions target
Definition: SolverOptions.h:709
escript::SolverBuddy::coarse_level_sparsity
double coarse_level_sparsity
Definition: SolverOptions.h:746
escript::SolverBuddy::adapt_inner_tolerance
bool adapt_inner_tolerance
Definition: SolverOptions.h:729
escript::SolverBuddy::num_level
int num_level
Definition: SolverOptions.h:737
escript::SolverBuddy::relaxation
double relaxation
Definition: SolverOptions.h:731
escript::SolverBuddy::preconditioner_size
int preconditioner_size
Definition: SolverOptions.h:744
escript::SolverBuddy::package
SolverOptions package
Definition: SolverOptions.h:710
escript::SolverBuddy::num_coarse_unknowns
int num_coarse_unknowns
Definition: SolverOptions.h:747
escript::SolverBuddy::cum_time
double cum_time
Definition: SolverOptions.h:750
escript::SolverBuddy::restart
int restart
Definition: SolverOptions.h:724
escript::SolverBuddy::ode_solver
SolverOptions ode_solver
Definition: SolverOptions.h:713
escript::SolverBuddy::cum_set_up_time
double cum_set_up_time
Definition: SolverOptions.h:751
escript::SolverBuddy::symmetric
bool symmetric
Definition: SolverOptions.h:726
escript::SolverBuddy::trilinosParams
boost::python::dict trilinosParams
Definition: SolverOptions.h:707
escript::SolverBuddy::refinements
int refinements
Definition: SolverOptions.h:733
escript::SolverBuddy::net_time
double net_time
Definition: SolverOptions.h:741
ESCRIPT_DLL_API
#define ESCRIPT_DLL_API
Definition: escriptcore/src/system_dep.h:30
escript
Definition: AbstractContinuousDomain.cpp:23
escript::isDirectSolver
bool isDirectSolver(const SolverOptions &method)
returns true if the passed solver method refers to a direct solver type
Definition: SolverOptions.h:145
escript::SB_ptr
boost::shared_ptr< SolverBuddy > SB_ptr
Definition: SolverOptions.h:757
escript::SolverOptions
SolverOptions
Definition: SolverOptions.h:82
escript::SO_ODESOLVER_BACKWARD_EULER
@ SO_ODESOLVER_BACKWARD_EULER
Definition: SolverOptions.h:129
escript::SO_PRECONDITIONER_GAUSS_SEIDEL
@ SO_PRECONDITIONER_GAUSS_SEIDEL
Definition: SolverOptions.h:120
escript::SO_METHOD_DIRECT_MUMPS
@ SO_METHOD_DIRECT_MUMPS
Definition: SolverOptions.h:103
escript::SO_PACKAGE_PASO
@ SO_PACKAGE_PASO
Definition: SolverOptions.h:91
escript::SO_METHOD_NONLINEAR_GMRES
@ SO_METHOD_NONLINEAR_GMRES
Definition: SolverOptions.h:112
escript::SO_TARGET_GPU
@ SO_TARGET_GPU
Definition: SolverOptions.h:87
escript::SO_INTERPOLATION_CLASSIC
@ SO_INTERPOLATION_CLASSIC
Definition: SolverOptions.h:134
escript::SO_INTERPOLATION_CLASSIC_WITH_FF_COUPLING
@ SO_INTERPOLATION_CLASSIC_WITH_FF_COUPLING
Definition: SolverOptions.h:135
escript::SO_PACKAGE_MUMPS
@ SO_PACKAGE_MUMPS
Definition: SolverOptions.h:94
escript::SO_DEFAULT
@ SO_DEFAULT
Definition: SolverOptions.h:83
escript::SO_METHOD_DIRECT_PARDISO
@ SO_METHOD_DIRECT_PARDISO
Definition: SolverOptions.h:104
escript::SO_PACKAGE_TRILINOS
@ SO_PACKAGE_TRILINOS
Definition: SolverOptions.h:92
escript::SO_METHOD_TFQMR
@ SO_METHOD_TFQMR
Definition: SolverOptions.h:116
escript::SO_ODESOLVER_CRANK_NICOLSON
@ SO_ODESOLVER_CRANK_NICOLSON
Definition: SolverOptions.h:130
escript::SO_PRECONDITIONER_ILU0
@ SO_PRECONDITIONER_ILU0
Definition: SolverOptions.h:121
escript::SO_METHOD_ROWSUM_LUMPING
@ SO_METHOD_ROWSUM_LUMPING
Definition: SolverOptions.h:115
escript::SO_PACKAGE_UMFPACK
@ SO_PACKAGE_UMFPACK
Definition: SolverOptions.h:93
escript::SO_METHOD_DIRECT_TRILINOS
@ SO_METHOD_DIRECT_TRILINOS
Definition: SolverOptions.h:106
escript::SO_METHOD_PCG
@ SO_METHOD_PCG
Definition: SolverOptions.h:113
escript::SO_REORDERING_NESTED_DISSECTION
@ SO_REORDERING_NESTED_DISSECTION
Definition: SolverOptions.h:140
escript::SO_PRECONDITIONER_AMG
@ SO_PRECONDITIONER_AMG
Definition: SolverOptions.h:119
escript::SO_ODESOLVER_LINEAR_CRANK_NICOLSON
@ SO_ODESOLVER_LINEAR_CRANK_NICOLSON
Definition: SolverOptions.h:131
escript::SO_REORDERING_DEFAULT
@ SO_REORDERING_DEFAULT
Definition: SolverOptions.h:138
escript::SO_METHOD_GMRES
@ SO_METHOD_GMRES
Definition: SolverOptions.h:107
escript::SO_METHOD_MINRES
@ SO_METHOD_MINRES
Definition: SolverOptions.h:111
escript::SO_METHOD_LSQR
@ SO_METHOD_LSQR
Definition: SolverOptions.h:110
escript::SO_PACKAGE_MKL
@ SO_PACKAGE_MKL
Definition: SolverOptions.h:90
escript::SO_METHOD_ITERATIVE
@ SO_METHOD_ITERATIVE
Definition: SolverOptions.h:109
escript::SO_PRECONDITIONER_RILU
@ SO_PRECONDITIONER_RILU
Definition: SolverOptions.h:126
escript::SO_PRECONDITIONER_ILUT
@ SO_PRECONDITIONER_ILUT
Definition: SolverOptions.h:122
escript::SO_PRECONDITIONER_REC_ILU
@ SO_PRECONDITIONER_REC_ILU
Definition: SolverOptions.h:125
escript::SO_METHOD_DIRECT
@ SO_METHOD_DIRECT
Definition: SolverOptions.h:102
escript::SO_METHOD_DIRECT_SUPERLU
@ SO_METHOD_DIRECT_SUPERLU
Definition: SolverOptions.h:105
escript::SO_INTERPOLATION_DIRECT
@ SO_INTERPOLATION_DIRECT
Definition: SolverOptions.h:136
escript::SO_PRECONDITIONER_JACOBI
@ SO_PRECONDITIONER_JACOBI
Definition: SolverOptions.h:123
escript::SO_TARGET_CPU
@ SO_TARGET_CPU
Definition: SolverOptions.h:86
escript::SO_METHOD_PRES20
@ SO_METHOD_PRES20
Definition: SolverOptions.h:114
escript::SO_METHOD_HRZ_LUMPING
@ SO_METHOD_HRZ_LUMPING
Definition: SolverOptions.h:108
escript::SO_METHOD_CR
@ SO_METHOD_CR
Definition: SolverOptions.h:101
escript::SO_METHOD_CGLS
@ SO_METHOD_CGLS
Definition: SolverOptions.h:98
escript::SO_METHOD_CGS
@ SO_METHOD_CGS
Definition: SolverOptions.h:99
escript::SO_REORDERING_MINIMUM_FILL_IN
@ SO_REORDERING_MINIMUM_FILL_IN
Definition: SolverOptions.h:139
escript::SO_METHOD_BICGSTAB
@ SO_METHOD_BICGSTAB
Definition: SolverOptions.h:97
escript::SO_REORDERING_NONE
@ SO_REORDERING_NONE
Definition: SolverOptions.h:141
escript::SO_METHOD_CHOLEVSKY
@ SO_METHOD_CHOLEVSKY
Definition: SolverOptions.h:100
escript::SO_PRECONDITIONER_NONE
@ SO_PRECONDITIONER_NONE
Definition: SolverOptions.h:124
escript::hermitian
void hermitian(const DataTypes::CplxVectorType &in, const DataTypes::ShapeType &inShape, DataTypes::CplxVectorType::size_type inOffset, DataTypes::CplxVectorType &ev, const DataTypes::ShapeType &evShape, DataTypes::CplxVectorType::size_type evOffset)
computes an hermitian matrix from your square matrix A: (A + adjoint(A)) / 2
Definition: DataVectorOps.cpp:916
system_dep.h