SolverOptions.h
Go to the documentation of this file.
/******************************************************************************
*
* Copyright (c) 2003-2017 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 by Centre for Geoscience Computing (GeoComp)
*
*****************************************************************************/
#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_CUSP,
SO_PACKAGE_MKL,
SO_PACKAGE_PASO,
SO_PACKAGE_TRILINOS,
SO_PACKAGE_UMFPACK,
// 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_AMLI,
SO_PRECONDITIONER_BOOMERAMG,
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,
// Coarsening methods
SO_COARSENING_AGGREGATION,
SO_COARSENING_CIJP,
SO_COARSENING_CIJP_FIXED_RANDOM,
SO_COARSENING_FALGOUT,
SO_COARSENING_HMIS,
SO_COARSENING_PMIS,
SO_COARSENING_RUGE_STUEBEN,
SO_COARSENING_STANDARD,
SO_COARSENING_YAIR_SHAPIRA,
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 setCoarsening(int coarsening);
SolverOptions getCoarsening() const;
void setMinCoarseMatrixSize(int size);
int getMinCoarseMatrixSize() const;
void setPreconditioner(int preconditioner);
SolverOptions getPreconditioner() const;
void setSmoother(int smoother);
SolverOptions getSmoother() const;
void setSolverMethod(int method);
SolverOptions getSolverMethod() const;
void setSolverTarget(int target);
SolverOptions getSolverTarget() 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 setDiagonalDominanceThreshold(double threshold);
double getDiagonalDominanceThreshold() 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 setLevelMax(int level_max);
int getLevelMax() const;
void setCycleType(int cycle_type);
int getCycleType() const;
void setCoarseningThreshold(double theta);
double getCoarseningThreshold() const;
void setNumSweeps(int sweeps);
int getNumSweeps() const;
void setNumPreSweeps(int sweeps);
int getNumPreSweeps() const;
void setNumPostSweeps(int sweeps);
int getNumPostSweeps() 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 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 setMinCoarseMatrixSparsity(double sparsity);
double getMinCoarseMatrixSparsity() const;
void setNumRefinements(int refinements);
int getNumRefinements() const;
void setNumCoarseMatrixRefinements(int refinements);
int getNumCoarseMatrixRefinements() const;
bool usePanel() const;
void setUsePanelOn();
void setUsePanelOff();
void setUsePanel(bool use);
void setAMGInterpolation(int interpolation);
SolverOptions getAMGInterpolation() const;
void setODESolver(int solver);
SolverOptions getODESolver() const;
void setTrilinosParameter(const std::string& name,
const boost::python::object& value);
boost::python::dict getTrilinosParameters() const;
protected:
boost::python::dict trilinosParams;
SolverOptions target;
SolverOptions package;
SolverOptions method;
SolverOptions preconditioner;
SolverOptions ode_solver;
SolverOptions smoother;
SolverOptions reordering;
SolverOptions coarsening;
SolverOptions amg_interpolation_method;
int level_max;
double coarsening_threshold;
int sweeps;
int pre_sweeps;
int post_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 verbose;
bool adapt_inner_tolerance;
bool accept_convergence_failure;
int min_coarse_matrix_size;
double relaxation;
bool use_local_preconditioner;
double min_sparsity;
int refinements;
int coarse_refinements;
bool use_panel;
double diagonal_dominance_threshold;
int cycle_type;
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;
};
typedef boost::shared_ptr<SolverBuddy> SB_ptr;
} // namespace escript
#endif // __ESCRIPT_SOLVEROPTIONS_H__
escript::SO_COARSENING_FALGOUT
Definition: SolverOptions.h:155
escript::SO_TARGET_GPU
Definition: SolverOptions.h:98
escript::SolverBuddy::refinements
int refinements
Definition: SolverOptions.h:942
escript::SolverBuddy::restart
int restart
Definition: SolverOptions.h:932
escript::SolverBuddy::trilinosParams
boost::python::dict trilinosParams
Definition: SolverOptions.h:908
escript::SolverBuddy
Definition: SolverOptions.h:184
escript::SO_METHOD_HRZ_LUMPING
Definition: SolverOptions.h:119
escript::SO_PACKAGE_MKL
Definition: SolverOptions.h:102
escript::SolverBuddy::adapt_inner_tolerance
bool adapt_inner_tolerance
Definition: SolverOptions.h:936
escript::SO_REORDERING_DEFAULT
Definition: SolverOptions.h:162
escript::SolverBuddy::relaxation
double relaxation
Definition: SolverOptions.h:939
escript::SolverBuddy::tolerance
double tolerance
Definition: SolverOptions.h:924
escript::SolverBuddy::package
SolverOptions package
Definition: SolverOptions.h:911
escript::SO_INTERPOLATION_CLASSIC
Definition: SolverOptions.h:147
escript::SolverOptions
SolverOptions
Definition: SolverOptions.h:92
escript::SO_METHOD_NONLINEAR_GMRES
Definition: SolverOptions.h:123
escript::SO_PRECONDITIONER_AMLI
Definition: SolverOptions.h:131
escript::SolverBuddy::smoother
SolverOptions smoother
Definition: SolverOptions.h:915
escript
Definition: AbstractContinuousDomain.cpp:22
escript::SolverBuddy::level_max
int level_max
Definition: SolverOptions.h:919
escript::SolverBuddy::cum_set_up_time
double cum_set_up_time
Definition: SolverOptions.h:963
escript::SO_METHOD_DIRECT_PARDISO
Definition: SolverOptions.h:115
escript::SO_PRECONDITIONER_JACOBI
Definition: SolverOptions.h:136
escript::SolverBuddy::post_sweeps
int post_sweeps
Definition: SolverOptions.h:923
escript::SO_PRECONDITIONER_RILU
Definition: SolverOptions.h:139
escript::SO_COARSENING_STANDARD
Definition: SolverOptions.h:159
escript::SO_METHOD_CHOLEVSKY
Definition: SolverOptions.h:111
escript::SB_ptr
boost::shared_ptr< SolverBuddy > SB_ptr
Definition: SolverOptions.h:967
escript::SolverBuddy::inner_tolerance
double inner_tolerance
Definition: SolverOptions.h:926
escript::SO_METHOD_BICGSTAB
Definition: SolverOptions.h:108
escript::SO_INTERPOLATION_DIRECT
Definition: SolverOptions.h:149
escript::SolverBuddy::truncation
int truncation
Definition: SolverOptions.h:931
escript::SolverBuddy::residual_norm
double residual_norm
Definition: SolverOptions.h:954
escript::SO_ODESOLVER_BACKWARD_EULER
Definition: SolverOptions.h:142
escript::SO_COARSENING_PMIS
Definition: SolverOptions.h:157
escript::SolverBuddy::coarse_refinements
int coarse_refinements
Definition: SolverOptions.h:943
escript::SO_PRECONDITIONER_ILUT
Definition: SolverOptions.h:135
escript::SO_COARSENING_CIJP_FIXED_RANDOM
Definition: SolverOptions.h:154
escript::SO_PACKAGE_TRILINOS
Definition: SolverOptions.h:104
escript::SolverBuddy::min_coarse_matrix_size
int min_coarse_matrix_size
Definition: SolverOptions.h:938
escript::SO_PRECONDITIONER_NONE
Definition: SolverOptions.h:137
escript::SolverBuddy::cum_net_time
double cum_net_time
Definition: SolverOptions.h:964
escript::SO_REORDERING_NONE
Definition: SolverOptions.h:165
escript::SO_TARGET_CPU
Definition: SolverOptions.h:97
escript::SolverBuddy::converged
bool converged
Definition: SolverOptions.h:955
escript::SO_REORDERING_NESTED_DISSECTION
Definition: SolverOptions.h:164
escript::SolverBuddy::cum_num_iter
int cum_num_iter
Definition: SolverOptions.h:961
escript::SO_METHOD_PCG
Definition: SolverOptions.h:124
escript::SO_METHOD_CR
Definition: SolverOptions.h:112
escript::SO_PACKAGE_CUSP
Definition: SolverOptions.h:101
system_dep.h
escript::SO_METHOD_CGLS
Definition: SolverOptions.h:109
escript::SO_METHOD_DIRECT_MUMPS
Definition: SolverOptions.h:114
escript::SO_PRECONDITIONER_REC_ILU
Definition: SolverOptions.h:138
escript::SolverBuddy::cum_num_inner_iter
int cum_num_inner_iter
Definition: SolverOptions.h:960
escript::SolverBuddy::amg_interpolation_method
SolverOptions amg_interpolation_method
Definition: SolverOptions.h:918
escript::SO_METHOD_GMRES
Definition: SolverOptions.h:118
escript::SolverBuddy::use_panel
bool use_panel
Definition: SolverOptions.h:944
escript::SO_PRECONDITIONER_AMG
Definition: SolverOptions.h:130
escript::SolverBuddy::is_complex
bool is_complex
Definition: SolverOptions.h:933
escript::SolverBuddy::iter_max
int iter_max
Definition: SolverOptions.h:929
escript::SolverBuddy::coarse_level_sparsity
double coarse_level_sparsity
Definition: SolverOptions.h:958
escript::SO_METHOD_ITERATIVE
Definition: SolverOptions.h:120
escript::SolverBuddy::num_coarse_unknowns
int num_coarse_unknowns
Definition: SolverOptions.h:959
escript::SO_COARSENING_AGGREGATION
Definition: SolverOptions.h:152
escript::SO_PRECONDITIONER_GAUSS_SEIDEL
Definition: SolverOptions.h:133
escript::SolverBuddy::symmetric
bool symmetric
Definition: SolverOptions.h:934
escript::SolverBuddy::accept_convergence_failure
bool accept_convergence_failure
Definition: SolverOptions.h:937
escript::SO_PRECONDITIONER_BOOMERAMG
Definition: SolverOptions.h:132
escript::SO_METHOD_ROWSUM_LUMPING
Definition: SolverOptions.h:126
escript::SolverBuddy::time_step_backtracking_used
bool time_step_backtracking_used
Definition: SolverOptions.h:957
escript::SO_DEFAULT
Definition: SolverOptions.h:94
escript::SolverBuddy::cum_time
double cum_time
Definition: SolverOptions.h:962
escript::SolverBuddy::set_up_time
double set_up_time
Definition: SolverOptions.h:952
escript::SO_COARSENING_CIJP
Definition: SolverOptions.h:153
escript::SO_ODESOLVER_CRANK_NICOLSON
Definition: SolverOptions.h:143
escript::SolverBuddy::reordering
SolverOptions reordering
Definition: SolverOptions.h:916
escript::SO_METHOD_CGS
Definition: SolverOptions.h:110
escript::SolverBuddy::inner_iter_max
int inner_iter_max
Definition: SolverOptions.h:930
escript::SO_METHOD_MINRES
Definition: SolverOptions.h:122
escript::SolverBuddy::absolute_tolerance
double absolute_tolerance
Definition: SolverOptions.h:925
escript::SO_PACKAGE_UMFPACK
Definition: SolverOptions.h:105
escript::SolverBuddy::target
SolverOptions target
Definition: SolverOptions.h:910
escript::SolverBuddy::drop_storage
double drop_storage
Definition: SolverOptions.h:928
escript::SolverBuddy::coarsening
SolverOptions coarsening
Definition: SolverOptions.h:917
escript::SolverBuddy::num_iter
int num_iter
Definition: SolverOptions.h:948
escript::SO_METHOD_DIRECT
Definition: SolverOptions.h:113
escript::SO_PRECONDITIONER_ILU0
Definition: SolverOptions.h:134
escript::SolverBuddy::num_inner_iter
int num_inner_iter
Definition: SolverOptions.h:950
escript::SO_PACKAGE_PASO
Definition: SolverOptions.h:103
escript::SO_COARSENING_HMIS
Definition: SolverOptions.h:156
escript::SolverBuddy::pre_sweeps
int pre_sweeps
Definition: SolverOptions.h:922
ESCRIPT_DLL_API
#define ESCRIPT_DLL_API
Definition: escriptcore/src/system_dep.h:29
escript::SolverBuddy::time
double time
Definition: SolverOptions.h:951
escript::SolverBuddy::verbose
bool verbose
Definition: SolverOptions.h:935
escript::SO_COARSENING_YAIR_SHAPIRA
Definition: SolverOptions.h:160
escript::SO_INTERPOLATION_CLASSIC_WITH_FF_COUPLING
Definition: SolverOptions.h:148
escript::SolverBuddy::sweeps
int sweeps
Definition: SolverOptions.h:921
escript::SolverBuddy::preconditioner
SolverOptions preconditioner
Definition: SolverOptions.h:913
escript::SolverBuddy::diagonal_dominance_threshold
double diagonal_dominance_threshold
Definition: SolverOptions.h:945
escript::SO_METHOD_TFQMR
Definition: SolverOptions.h:127
escript::isDirectSolver
bool isDirectSolver(const SolverOptions &method)
returns true if the passed solver method refers to a direct solver type
Definition: SolverOptions.h:169
escript::SolverBuddy::use_local_preconditioner
bool use_local_preconditioner
Definition: SolverOptions.h:940
escript::SO_ODESOLVER_LINEAR_CRANK_NICOLSON
Definition: SolverOptions.h:144
escript::SO_METHOD_PRES20
Definition: SolverOptions.h:125
escript::SolverBuddy::drop_tolerance
double drop_tolerance
Definition: SolverOptions.h:927
escript::SolverBuddy::min_sparsity
double min_sparsity
Definition: SolverOptions.h:941
escript::SolverBuddy::ode_solver
SolverOptions ode_solver
Definition: SolverOptions.h:914
escript::SO_METHOD_LSQR
Definition: SolverOptions.h:121
escript::SolverBuddy::coarsening_threshold
double coarsening_threshold
Definition: SolverOptions.h:920
escript::SO_COARSENING_RUGE_STUEBEN
Definition: SolverOptions.h:158
escript::SolverBuddy::preconditioner_size
int preconditioner_size
Definition: SolverOptions.h:956
escript::SolverBuddy::num_level
int num_level
Definition: SolverOptions.h:949
escript::SO_REORDERING_MINIMUM_FILL_IN
Definition: SolverOptions.h:163
escript::SolverBuddy::net_time
double net_time
Definition: SolverOptions.h:953
escript::SO_METHOD_DIRECT_TRILINOS
Definition: SolverOptions.h:117
escript::SolverBuddy::method
SolverOptions method
Definition: SolverOptions.h:912
escript::SO_METHOD_DIRECT_SUPERLU
Definition: SolverOptions.h:116
escript::SolverBuddy::cycle_type
int cycle_type
Definition: SolverOptions.h:946