escript  Revision_
SolverOptions.h
Go to the documentation of this file.
1 
2 /******************************************************************************
3 *
4 * Copyright (c) 2003-2018 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 by Centre for Geoscience Computing (GeoComp)
14 *
15 *****************************************************************************/
16 
17 #ifndef __ESCRIPT_SOLVEROPTIONS_H__
18 #define __ESCRIPT_SOLVEROPTIONS_H__
19 
20 #include <boost/python/dict.hpp>
21 #include <boost/python/object.hpp>
22 #include "system_dep.h"
23 
24 namespace escript {
25 
92 {
94 
95  // Solver targets
98 
99  // Solver packages
105 
106  // Solver methods
127 
128  // Preconditioners
138 
139  // ODE solvers
143 
144  // Interpolation methods
148 
149  // Coarsening methods
159 
164 };
165 
167 inline bool isDirectSolver(const SolverOptions& method)
168 {
169  switch (method) {
170  case SO_METHOD_DIRECT:
175  return true;
176  default:
177  break;
178  }
179  return false;
180 }
181 
183 {
184 public:
185  SolverBuddy();
186  ~SolverBuddy();
187 
191  std::string getSummary() const;
192 
198  const char* getName(int key) const;
199 
206  void resetDiagnostics(bool all=false);
207 
216  void updateDiagnosticsPy(const std::string& key,
217  const boost::python::object& value);
218 
219  void updateDiagnostics(const std::string& key, bool value);
220  void updateDiagnostics(const std::string& key, int value);
221  void updateDiagnostics(const std::string& key, double value);
222 
251  double getDiagnostics(const std::string name) const;
252 
260  bool hasConverged() const;
261 
272  void setCoarsening(int coarsening);
273 
277  SolverOptions getCoarsening() const;
278 
284  void setMinCoarseMatrixSize(int size);
285 
289  int getMinCoarseMatrixSize() const;
290 
305  void setPreconditioner(int preconditioner);
306 
310  SolverOptions getPreconditioner() const;
311 
322  void setSmoother(int smoother);
323 
327  SolverOptions getSmoother() const;
328 
349  void setSolverMethod(int method);
350 
354  SolverOptions getSolverMethod() const;
355 
366  void setSolverTarget(int target);
367 
371  SolverOptions getSolverTarget() const;
372 
385  void setPackage(int package);
386 
390  SolverOptions getPackage() const;
391 
401  void setReordering(int ordering);
402 
407  SolverOptions getReordering() const;
408 
416  void setRestart(int restart);
417 
422  int getRestart() const;
423 
428  int _getRestartForC() const;
429 
434  void setDiagonalDominanceThreshold(double threshold);
435 
440  double getDiagonalDominanceThreshold() const;
441 
447  void setTruncation(int truncation);
448 
453  int getTruncation() const;
454 
460  void setInnerIterMax(int iter_max);
461 
465  int getInnerIterMax() const;
466 
472  void setIterMax(int iter_max);
473 
477  int getIterMax() const;
478 
485  void setLevelMax(int level_max);
486 
491  int getLevelMax() const;
492 
499  void setCycleType(int cycle_type);
500 
505  int getCycleType() const;
506 
513  void setCoarseningThreshold(double theta);
514 
519  double getCoarseningThreshold() const;
520 
527  void setNumSweeps(int sweeps);
528 
533  int getNumSweeps() const;
534 
541  void setNumPreSweeps(int sweeps);
542 
547  int getNumPreSweeps() const;
548 
555  void setNumPostSweeps(int sweeps);
556 
561  int getNumPostSweeps() const;
562 
568  void setTolerance(double rtol);
569 
573  double getTolerance() const;
574 
580  void setAbsoluteTolerance(double atol);
581 
585  double getAbsoluteTolerance() const;
586 
593  void setInnerTolerance(double rtol);
594 
598  double getInnerTolerance() const;
599 
605  void setDropTolerance(double drop_tol);
606 
610  double getDropTolerance() const;
611 
619  void setDropStorage(double drop);
620 
624  double getDropStorage() const;
625 
633  void setRelaxationFactor(double factor);
634 
639  double getRelaxationFactor() const;
640 
646  bool isComplex() const;
647 
653  void setComplex(bool complex);
654 
660  bool isSymmetric() const;
661 
666  void setSymmetryOn();
667 
671  void setSymmetryOff();
672 
678  void setSymmetry(bool symmetry);
679 
685  bool isVerbose() const;
686 
690  void setVerbosityOn();
691 
695  void setVerbosityOff();
696 
702  void setVerbosity(bool verbose);
703 
711  bool adaptInnerTolerance() const;
712 
716  void setInnerToleranceAdaptionOn();
717 
721  void setInnerToleranceAdaptionOff();
722 
728  void setInnerToleranceAdaption(bool adaption);
729 
740  bool acceptConvergenceFailure() const;
741 
745  void setAcceptanceConvergenceFailureOn();
746 
750  void setAcceptanceConvergenceFailureOff();
751 
758  void setAcceptanceConvergenceFailure(bool acceptance);
759 
766  bool useLocalPreconditioner() const;
767 
771  void setLocalPreconditionerOn();
772 
776  void setLocalPreconditionerOff();
777 
784  void setLocalPreconditioner(bool local);
785 
792  void setMinCoarseMatrixSparsity(double sparsity);
793 
801  double getMinCoarseMatrixSparsity() const;
802 
809  void setNumRefinements(int refinements);
810 
815  int getNumRefinements() const;
816 
823  void setNumCoarseMatrixRefinements(int refinements);
824 
829  int getNumCoarseMatrixRefinements() const;
830 
836  bool usePanel() const;
837 
841  void setUsePanelOn();
842 
846  void setUsePanelOff();
847 
854  void setUsePanel(bool use);
855 
864  void setAMGInterpolation(int interpolation);
865 
869  SolverOptions getAMGInterpolation() const;
870 
878  void setODESolver(int solver);
879 
883  SolverOptions getODESolver() const;
884 
894  void setTrilinosParameter(const std::string& name,
895  const boost::python::object& value);
896 
901  boost::python::dict getTrilinosParameters() const;
902 
903 protected:
904  boost::python::dict trilinosParams;
905 
917  int sweeps;
920  double tolerance;
924  double drop_storage;
925  int iter_max;
928  int restart; //0 will have to be None in python, will get tricky
930  bool symmetric;
931  bool verbose;
935  double relaxation;
937  double min_sparsity;
940  bool use_panel;
943 
944  int num_iter;
947  double time;
948  double set_up_time;
949  double net_time;
951  bool converged;
958  double cum_time;
960  double cum_net_time;
961 };
962 
963 typedef boost::shared_ptr<SolverBuddy> SB_ptr;
964 
965 } // namespace escript
966 
967 #endif // __ESCRIPT_SOLVEROPTIONS_H__
968 
Definition: SolverOptions.h:153
Definition: SolverOptions.h:97
int refinements
Definition: SolverOptions.h:938
int restart
Definition: SolverOptions.h:928
boost::python::dict trilinosParams
Definition: SolverOptions.h:904
Definition: SolverOptions.h:182
Definition: SolverOptions.h:118
Definition: SolverOptions.h:101
bool adapt_inner_tolerance
Definition: SolverOptions.h:932
Definition: SolverOptions.h:160
double relaxation
Definition: SolverOptions.h:935
double tolerance
Definition: SolverOptions.h:920
SolverOptions package
Definition: SolverOptions.h:907
Definition: SolverOptions.h:145
SolverOptions
Definition: SolverOptions.h:91
Definition: SolverOptions.h:122
Definition: SolverOptions.h:130
SolverOptions smoother
Definition: SolverOptions.h:911
Definition: AbstractContinuousDomain.cpp:22
int level_max
Definition: SolverOptions.h:915
double cum_set_up_time
Definition: SolverOptions.h:959
Definition: SolverOptions.h:114
Definition: SolverOptions.h:134
int post_sweeps
Definition: SolverOptions.h:919
Definition: SolverOptions.h:137
Definition: SolverOptions.h:157
Definition: SolverOptions.h:110
boost::shared_ptr< SolverBuddy > SB_ptr
Definition: SolverOptions.h:963
double inner_tolerance
Definition: SolverOptions.h:922
Definition: SolverOptions.h:107
Definition: SolverOptions.h:147
int truncation
Definition: SolverOptions.h:927
double residual_norm
Definition: SolverOptions.h:950
Definition: SolverOptions.h:140
Definition: SolverOptions.h:155
int coarse_refinements
Definition: SolverOptions.h:939
Definition: SolverOptions.h:133
Definition: SolverOptions.h:152
Definition: SolverOptions.h:103
int min_coarse_matrix_size
Definition: SolverOptions.h:934
Definition: SolverOptions.h:135
double cum_net_time
Definition: SolverOptions.h:960
Definition: SolverOptions.h:163
Definition: SolverOptions.h:96
bool converged
Definition: SolverOptions.h:951
Definition: SolverOptions.h:162
int cum_num_iter
Definition: SolverOptions.h:957
Definition: SolverOptions.h:123
Definition: SolverOptions.h:111
Definition: SolverOptions.h:100
Definition: SolverOptions.h:108
Definition: SolverOptions.h:113
Definition: SolverOptions.h:136
int cum_num_inner_iter
Definition: SolverOptions.h:956
SolverOptions amg_interpolation_method
Definition: SolverOptions.h:914
Definition: SolverOptions.h:117
bool use_panel
Definition: SolverOptions.h:940
Definition: SolverOptions.h:129
bool is_complex
Definition: SolverOptions.h:929
int iter_max
Definition: SolverOptions.h:925
double coarse_level_sparsity
Definition: SolverOptions.h:954
Definition: SolverOptions.h:119
int num_coarse_unknowns
Definition: SolverOptions.h:955
Definition: SolverOptions.h:150
Definition: SolverOptions.h:131
bool symmetric
Definition: SolverOptions.h:930
bool accept_convergence_failure
Definition: SolverOptions.h:933
Definition: SolverOptions.h:125
bool time_step_backtracking_used
Definition: SolverOptions.h:953
Definition: SolverOptions.h:93
double cum_time
Definition: SolverOptions.h:958
double set_up_time
Definition: SolverOptions.h:948
Definition: SolverOptions.h:151
Definition: SolverOptions.h:141
SolverOptions reordering
Definition: SolverOptions.h:912
Definition: SolverOptions.h:109
int inner_iter_max
Definition: SolverOptions.h:926
Definition: SolverOptions.h:121
double absolute_tolerance
Definition: SolverOptions.h:921
Definition: SolverOptions.h:104
SolverOptions target
Definition: SolverOptions.h:906
double drop_storage
Definition: SolverOptions.h:924
SolverOptions coarsening
Definition: SolverOptions.h:913
int num_iter
Definition: SolverOptions.h:944
Definition: SolverOptions.h:112
Definition: SolverOptions.h:132
int num_inner_iter
Definition: SolverOptions.h:946
Definition: SolverOptions.h:102
Definition: SolverOptions.h:154
int pre_sweeps
Definition: SolverOptions.h:918
#define ESCRIPT_DLL_API
Definition: escriptcore/src/system_dep.h:29
double time
Definition: SolverOptions.h:947
bool verbose
Definition: SolverOptions.h:931
Definition: SolverOptions.h:158
int sweeps
Definition: SolverOptions.h:917
SolverOptions preconditioner
Definition: SolverOptions.h:909
double diagonal_dominance_threshold
Definition: SolverOptions.h:941
Definition: SolverOptions.h:126
bool isDirectSolver(const SolverOptions &method)
returns true if the passed solver method refers to a direct solver type
Definition: SolverOptions.h:167
bool use_local_preconditioner
Definition: SolverOptions.h:936
Definition: SolverOptions.h:142
Definition: SolverOptions.h:124
double drop_tolerance
Definition: SolverOptions.h:923
double min_sparsity
Definition: SolverOptions.h:937
SolverOptions ode_solver
Definition: SolverOptions.h:910
Definition: SolverOptions.h:120
double coarsening_threshold
Definition: SolverOptions.h:916
Definition: SolverOptions.h:156
int preconditioner_size
Definition: SolverOptions.h:952
int num_level
Definition: SolverOptions.h:945
Definition: SolverOptions.h:161
double net_time
Definition: SolverOptions.h:949
Definition: SolverOptions.h:116
SolverOptions method
Definition: SolverOptions.h:908
Definition: SolverOptions.h:115
int cycle_type
Definition: SolverOptions.h:942