escript  Revision_
SolverOptions.h
Go to the documentation of this file.
1 
2 /******************************************************************************
3 *
4 * Copyright (c) 2003-2020 by The University of Queensland
5 * http://www.uq.edu.au
6 *
7 * Primary Business: Queensland, Australia
8 * Licensed under the Apache License, version 2.0
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 * Development 2012-2013 by School of Earth Sciences
13 * Development from 2014-2017 by Centre for Geoscience Computing (GeoComp)
14 * Development from 2019 by School of Earth and Environmental Sciences
15 **
16 *****************************************************************************/
17 
18 #ifndef __ESCRIPT_SOLVEROPTIONS_H__
19 #define __ESCRIPT_SOLVEROPTIONS_H__
20 
21 #include <boost/python/dict.hpp>
22 #include <boost/python/object.hpp>
23 #include "system_dep.h"
24 
25 namespace escript {
26 
82 {
84 
85  // Solver targets
88 
89  // Solver packages
95 
96  // Solver methods
117 
118  // Preconditioners
127 
128  // ODE solvers
132 
133  // Interpolation methods
137 
142 };
143 
145 inline bool isDirectSolver(const SolverOptions& method)
146 {
147  switch (method) {
148  case SO_METHOD_DIRECT:
153  return true;
154  default:
155  break;
156  }
157  return false;
158 }
159 
161 {
162 public:
163  SolverBuddy();
164  ~SolverBuddy();
165 
169  std::string getSummary() const;
170 
176  const char* getName(int key) const;
177 
184  void resetDiagnostics(bool all=false);
185 
194  void updateDiagnosticsPy(const std::string& key,
195  const boost::python::object& value);
196 
197  void updateDiagnostics(const std::string& key, bool value);
198  void updateDiagnostics(const std::string& key, int value);
199  void updateDiagnostics(const std::string& key, double value);
200 
229  double getDiagnostics(const std::string name) const;
230 
238  bool hasConverged() const;
239 
254  void setPreconditioner(int preconditioner);
255 
259  SolverOptions getPreconditioner() const;
260 
281  void setSolverMethod(int method);
282 
286  SolverOptions getSolverMethod() const;
287 
300  void setPackage(int package);
301 
305  SolverOptions getPackage() const;
306 
316  void setReordering(int ordering);
317 
322  SolverOptions getReordering() const;
323 
331  void setRestart(int restart);
332 
337  int getRestart() const;
338 
343  int _getRestartForC() const;
344 
350  void setTruncation(int truncation);
351 
356  int getTruncation() const;
357 
363  void setInnerIterMax(int iter_max);
364 
368  int getInnerIterMax() const;
369 
375  void setIterMax(int iter_max);
376 
380  int getIterMax() const;
381 
388  void setNumSweeps(int sweeps);
389 
394  int getNumSweeps() const;
395 
401  void setTolerance(double rtol);
402 
406  double getTolerance() const;
407 
413  void setAbsoluteTolerance(double atol);
414 
418  double getAbsoluteTolerance() const;
419 
426  void setInnerTolerance(double rtol);
427 
431  double getInnerTolerance() const;
432 
438  void setDropTolerance(double drop_tol);
439 
443  double getDropTolerance() const;
444 
452  void setDropStorage(double drop);
453 
457  double getDropStorage() const;
458 
466  void setRelaxationFactor(double factor);
467 
472  double getRelaxationFactor() const;
473 
479  bool isComplex() const;
480 
486  void setComplex(bool complex);
487 
493  bool isSymmetric() const;
494 
499  void setSymmetryOn();
500 
504  void setSymmetryOff();
505 
511  void setSymmetry(bool symmetry);
512 
518  bool isHermitian() const;
519 
524  void setHermitianOn();
525 
529  void setHermitianOff();
530 
536  void setHermitian(bool hermitian);
537 
543  bool isVerbose() const;
544 
548  void setVerbosityOn();
549 
553  void setVerbosityOff();
554 
560  void setVerbosity(bool verbose);
561 
569  bool adaptInnerTolerance() const;
570 
574  void setInnerToleranceAdaptionOn();
575 
579  void setInnerToleranceAdaptionOff();
580 
586  void setInnerToleranceAdaption(bool adaption);
587 
598  bool acceptConvergenceFailure() const;
599 
603  void setAcceptanceConvergenceFailureOn();
604 
608  void setAcceptanceConvergenceFailureOff();
609 
616  void setAcceptanceConvergenceFailure(bool acceptance);
617 
624  bool useLocalPreconditioner() const;
625 
629  void setLocalPreconditionerOn();
630 
634  void setLocalPreconditionerOff();
635 
642  void setLocalPreconditioner(bool local);
643 
650  void setNumRefinements(int refinements);
651 
656  int getNumRefinements() const;
657 
665  void setODESolver(int solver);
666 
670  SolverOptions getODESolver() const;
671 
681  void setTrilinosParameter(const std::string& name,
682  const boost::python::object& value);
683 
688  boost::python::dict getTrilinosParameters() const;
689 
693  void setDim(int dim);
694 
698  int getDim();
699 
703  bool using_default_method() const;
704 
705 
706 protected:
707  boost::python::dict trilinosParams;
708 
715  int sweeps;
716  double tolerance;
720  double drop_storage;
721  int iter_max;
724  int restart; //0 will have to be None in python, will get tricky
726  bool symmetric;
727  bool hermitian;
728  bool verbose;
731  double relaxation;
734  int dim; // Dimension of the problem, either 2 or 3. Used internally
735 
736  int num_iter;
739  double time;
740  double set_up_time;
741  double net_time;
743  bool converged;
750  double cum_time;
752  double cum_net_time;
753 
755 };
756 
757 typedef boost::shared_ptr<SolverBuddy> SB_ptr;
758 
759 } // namespace escript
760 
761 #endif // __ESCRIPT_SOLVEROPTIONS_H__
762 
Definition: SolverOptions.h:161
bool is_complex
Definition: SolverOptions.h:725
bool converged
Definition: SolverOptions.h:743
double residual_norm
Definition: SolverOptions.h:742
bool time_step_backtracking_used
Definition: SolverOptions.h:745
bool accept_convergence_failure
Definition: SolverOptions.h:730
double time
Definition: SolverOptions.h:739
SolverOptions reordering
Definition: SolverOptions.h:714
int num_iter
Definition: SolverOptions.h:736
SolverOptions method
Definition: SolverOptions.h:711
int truncation
Definition: SolverOptions.h:723
double set_up_time
Definition: SolverOptions.h:740
bool verbose
Definition: SolverOptions.h:728
double drop_tolerance
Definition: SolverOptions.h:719
int cum_num_inner_iter
Definition: SolverOptions.h:748
double cum_net_time
Definition: SolverOptions.h:752
int num_inner_iter
Definition: SolverOptions.h:738
int cum_num_iter
Definition: SolverOptions.h:749
double tolerance
Definition: SolverOptions.h:716
int sweeps
Definition: SolverOptions.h:715
double drop_storage
Definition: SolverOptions.h:720
int dim
Definition: SolverOptions.h:734
SolverOptions preconditioner
Definition: SolverOptions.h:712
bool use_local_preconditioner
Definition: SolverOptions.h:732
bool using_default_solver_method
Definition: SolverOptions.h:754
double absolute_tolerance
Definition: SolverOptions.h:717
bool hermitian
Definition: SolverOptions.h:727
double inner_tolerance
Definition: SolverOptions.h:718
int iter_max
Definition: SolverOptions.h:721
int inner_iter_max
Definition: SolverOptions.h:722
SolverOptions target
Definition: SolverOptions.h:709
double coarse_level_sparsity
Definition: SolverOptions.h:746
bool adapt_inner_tolerance
Definition: SolverOptions.h:729
int num_level
Definition: SolverOptions.h:737
double relaxation
Definition: SolverOptions.h:731
int preconditioner_size
Definition: SolverOptions.h:744
SolverOptions package
Definition: SolverOptions.h:710
int num_coarse_unknowns
Definition: SolverOptions.h:747
double cum_time
Definition: SolverOptions.h:750
int restart
Definition: SolverOptions.h:724
SolverOptions ode_solver
Definition: SolverOptions.h:713
double cum_set_up_time
Definition: SolverOptions.h:751
bool symmetric
Definition: SolverOptions.h:726
boost::python::dict trilinosParams
Definition: SolverOptions.h:707
int refinements
Definition: SolverOptions.h:733
double net_time
Definition: SolverOptions.h:741
#define ESCRIPT_DLL_API
Definition: escriptcore/src/system_dep.h:30
Definition: AbstractContinuousDomain.cpp:23
bool isDirectSolver(const SolverOptions &method)
returns true if the passed solver method refers to a direct solver type
Definition: SolverOptions.h:145
boost::shared_ptr< SolverBuddy > SB_ptr
Definition: SolverOptions.h:757
SolverOptions
Definition: SolverOptions.h:82
@ SO_ODESOLVER_BACKWARD_EULER
Definition: SolverOptions.h:129
@ SO_PRECONDITIONER_GAUSS_SEIDEL
Definition: SolverOptions.h:120
@ SO_METHOD_DIRECT_MUMPS
Definition: SolverOptions.h:103
@ SO_PACKAGE_PASO
Definition: SolverOptions.h:91
@ SO_METHOD_NONLINEAR_GMRES
Definition: SolverOptions.h:112
@ SO_TARGET_GPU
Definition: SolverOptions.h:87
@ SO_INTERPOLATION_CLASSIC
Definition: SolverOptions.h:134
@ SO_INTERPOLATION_CLASSIC_WITH_FF_COUPLING
Definition: SolverOptions.h:135
@ SO_PACKAGE_MUMPS
Definition: SolverOptions.h:94
@ SO_DEFAULT
Definition: SolverOptions.h:83
@ SO_METHOD_DIRECT_PARDISO
Definition: SolverOptions.h:104
@ SO_PACKAGE_TRILINOS
Definition: SolverOptions.h:92
@ SO_METHOD_TFQMR
Definition: SolverOptions.h:116
@ SO_ODESOLVER_CRANK_NICOLSON
Definition: SolverOptions.h:130
@ SO_PRECONDITIONER_ILU0
Definition: SolverOptions.h:121
@ SO_METHOD_ROWSUM_LUMPING
Definition: SolverOptions.h:115
@ SO_PACKAGE_UMFPACK
Definition: SolverOptions.h:93
@ SO_METHOD_DIRECT_TRILINOS
Definition: SolverOptions.h:106
@ SO_METHOD_PCG
Definition: SolverOptions.h:113
@ SO_REORDERING_NESTED_DISSECTION
Definition: SolverOptions.h:140
@ SO_PRECONDITIONER_AMG
Definition: SolverOptions.h:119
@ SO_ODESOLVER_LINEAR_CRANK_NICOLSON
Definition: SolverOptions.h:131
@ SO_REORDERING_DEFAULT
Definition: SolverOptions.h:138
@ SO_METHOD_GMRES
Definition: SolverOptions.h:107
@ SO_METHOD_MINRES
Definition: SolverOptions.h:111
@ SO_METHOD_LSQR
Definition: SolverOptions.h:110
@ SO_PACKAGE_MKL
Definition: SolverOptions.h:90
@ SO_METHOD_ITERATIVE
Definition: SolverOptions.h:109
@ SO_PRECONDITIONER_RILU
Definition: SolverOptions.h:126
@ SO_PRECONDITIONER_ILUT
Definition: SolverOptions.h:122
@ SO_PRECONDITIONER_REC_ILU
Definition: SolverOptions.h:125
@ SO_METHOD_DIRECT
Definition: SolverOptions.h:102
@ SO_METHOD_DIRECT_SUPERLU
Definition: SolverOptions.h:105
@ SO_INTERPOLATION_DIRECT
Definition: SolverOptions.h:136
@ SO_PRECONDITIONER_JACOBI
Definition: SolverOptions.h:123
@ SO_TARGET_CPU
Definition: SolverOptions.h:86
@ SO_METHOD_PRES20
Definition: SolverOptions.h:114
@ SO_METHOD_HRZ_LUMPING
Definition: SolverOptions.h:108
@ SO_METHOD_CR
Definition: SolverOptions.h:101
@ SO_METHOD_CGLS
Definition: SolverOptions.h:98
@ SO_METHOD_CGS
Definition: SolverOptions.h:99
@ SO_REORDERING_MINIMUM_FILL_IN
Definition: SolverOptions.h:139
@ SO_METHOD_BICGSTAB
Definition: SolverOptions.h:97
@ SO_REORDERING_NONE
Definition: SolverOptions.h:141
@ SO_METHOD_CHOLEVSKY
Definition: SolverOptions.h:100
@ SO_PRECONDITIONER_NONE
Definition: SolverOptions.h:124
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