escript  Revision_
SolverOptions.h
Go to the documentation of this file.
1 
2 /******************************************************************************
3 *
4 * Copyright (c) 2003-2016 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 
93 {
95 
96  // Solver targets
99 
100  // Solver packages
106 
107  // Solver methods
128 
129  // Preconditioners
140 
141  // ODE solvers
145 
146  // Interpolation methods
150 
151  // Coarsening methods
161 
166 };
167 
169 inline bool isDirectSolver(const SolverOptions& method)
170 {
171  switch (method) {
172  case SO_METHOD_DIRECT:
177  return true;
178  default:
179  break;
180  }
181  return false;
182 }
183 
185 {
186 public:
187  SolverBuddy();
188  ~SolverBuddy();
189 
193  std::string getSummary() const;
194 
200  const char* getName(int key) const;
201 
208  void resetDiagnostics(bool all=false);
209 
218  void updateDiagnosticsPy(const std::string& key,
219  const boost::python::object& value);
220 
221  void updateDiagnostics(const std::string& key, bool value);
222  void updateDiagnostics(const std::string& key, int value);
223  void updateDiagnostics(const std::string& key, double value);
224 
253  double getDiagnostics(const std::string name) const;
254 
262  bool hasConverged() const;
263 
275  void setCoarsening(int coarsening);
276 
281  SolverOptions getCoarsening() const;
282 
288  void setMinCoarseMatrixSize(int size);
289 
293  int getMinCoarseMatrixSize() const;
294 
309  void setPreconditioner(int preconditioner);
310 
314  SolverOptions getPreconditioner() const;
315 
326  void setSmoother(int smoother);
327 
331  SolverOptions getSmoother() const;
332 
353  void setSolverMethod(int method);
354 
358  SolverOptions getSolverMethod() const;
359 
370  void setSolverTarget(int target);
371 
375  SolverOptions getSolverTarget() const;
376 
389  void setPackage(int package);
390 
394  SolverOptions getPackage() const;
395 
405  void setReordering(int ordering);
406 
411  SolverOptions getReordering() const;
412 
420  void setRestart(int restart);
421 
426  int getRestart() const;
427 
432  int _getRestartForC() const;
433 
438  void setDiagonalDominanceThreshold(double threshold);
439 
444  double getDiagonalDominanceThreshold() const;
445 
451  void setTruncation(int truncation);
452 
457  int getTruncation() const;
458 
464  void setInnerIterMax(int iter_max);
465 
469  int getInnerIterMax() const;
470 
476  void setIterMax(int iter_max);
477 
481  int getIterMax() const;
482 
489  void setLevelMax(int level_max);
490 
495  int getLevelMax() const;
496 
503  void setCycleType(int cycle_type);
504 
509  int getCycleType() const;
510 
517  void setCoarseningThreshold(double theta);
518 
523  double getCoarseningThreshold() const;
524 
531  void setNumSweeps(int sweeps);
532 
537  int getNumSweeps() const;
538 
545  void setNumPreSweeps(int sweeps);
546 
551  int getNumPreSweeps() const;
552 
559  void setNumPostSweeps(int sweeps);
560 
565  int getNumPostSweeps() const;
566 
572  void setTolerance(double rtol);
573 
577  double getTolerance() const;
578 
584  void setAbsoluteTolerance(double atol);
585 
589  double getAbsoluteTolerance() const;
590 
597  void setInnerTolerance(double rtol);
598 
602  double getInnerTolerance() const;
603 
609  void setDropTolerance(double drop_tol);
610 
614  double getDropTolerance() const;
615 
623  void setDropStorage(double drop);
624 
628  double getDropStorage() const;
629 
637  void setRelaxationFactor(double factor);
638 
643  double getRelaxationFactor() const;
644 
650  bool isComplex() const;
651 
657  void setComplex(bool complex);
658 
664  bool isSymmetric() const;
665 
670  void setSymmetryOn();
671 
675  void setSymmetryOff();
676 
682  void setSymmetry(bool symmetry);
683 
689  bool isVerbose() const;
690 
694  void setVerbosityOn();
695 
699  void setVerbosityOff();
700 
706  void setVerbosity(bool verbose);
707 
715  bool adaptInnerTolerance() const;
716 
720  void setInnerToleranceAdaptionOn();
721 
725  void setInnerToleranceAdaptionOff();
726 
732  void setInnerToleranceAdaption(bool adaption);
733 
744  bool acceptConvergenceFailure() const;
745 
749  void setAcceptanceConvergenceFailureOn();
750 
754  void setAcceptanceConvergenceFailureOff();
755 
762  void setAcceptanceConvergenceFailure(bool acceptance);
763 
770  bool useLocalPreconditioner() const;
771 
775  void setLocalPreconditionerOn();
776 
780  void setLocalPreconditionerOff();
781 
788  void setLocalPreconditioner(bool local);
789 
796  void setMinCoarseMatrixSparsity(double sparsity);
797 
805  double getMinCoarseMatrixSparsity() const;
806 
813  void setNumRefinements(int refinements);
814 
819  int getNumRefinements() const;
820 
827  void setNumCoarseMatrixRefinements(int refinements);
828 
833  int getNumCoarseMatrixRefinements() const;
834 
840  bool usePanel() const;
841 
845  void setUsePanelOn();
846 
850  void setUsePanelOff();
851 
858  void setUsePanel(bool use);
859 
868  void setAMGInterpolation(int interpolation);
869 
873  SolverOptions getAMGInterpolation() const;
874 
882  void setODESolver(int solver);
883 
887  SolverOptions getODESolver() const;
888 
898  void setTrilinosParameter(const std::string& name,
899  const boost::python::object& value);
900 
905  boost::python::dict getTrilinosParameters() const;
906 
907 protected:
908  boost::python::dict trilinosParams;
909 
921  int sweeps;
924  double tolerance;
928  double drop_storage;
929  int iter_max;
932  int restart; //0 will have to be None in python, will get tricky
934  bool symmetric;
935  bool verbose;
939  double relaxation;
941  double min_sparsity;
944  bool use_panel;
947 
948  int num_iter;
951  double time;
952  double set_up_time;
953  double net_time;
955  bool converged;
962  double cum_time;
964  double cum_net_time;
965 };
966 
967 typedef boost::shared_ptr<SolverBuddy> SB_ptr;
968 
969 } // namespace escript
970 
971 #endif // __ESCRIPT_SOLVEROPTIONS_H__
972 
Definition: SolverOptions.h:155
Definition: SolverOptions.h:98
int refinements
Definition: SolverOptions.h:942
int restart
Definition: SolverOptions.h:932
boost::python::dict trilinosParams
Definition: SolverOptions.h:908
Definition: SolverOptions.h:184
Definition: SolverOptions.h:119
Definition: SolverOptions.h:102
bool adapt_inner_tolerance
Definition: SolverOptions.h:936
Definition: SolverOptions.h:162
double relaxation
Definition: SolverOptions.h:939
double tolerance
Definition: SolverOptions.h:924
SolverOptions package
Definition: SolverOptions.h:911
Definition: SolverOptions.h:147
SolverOptions
Definition: SolverOptions.h:92
Definition: SolverOptions.h:123
Definition: SolverOptions.h:131
SolverOptions smoother
Definition: SolverOptions.h:915
Definition: AbstractContinuousDomain.cpp:22
int level_max
Definition: SolverOptions.h:919
double cum_set_up_time
Definition: SolverOptions.h:963
Definition: SolverOptions.h:115
Definition: SolverOptions.h:136
int post_sweeps
Definition: SolverOptions.h:923
Definition: SolverOptions.h:139
Definition: SolverOptions.h:159
Definition: SolverOptions.h:111
boost::shared_ptr< SolverBuddy > SB_ptr
Definition: SolverOptions.h:967
double inner_tolerance
Definition: SolverOptions.h:926
Definition: SolverOptions.h:108
Definition: SolverOptions.h:149
int truncation
Definition: SolverOptions.h:931
double residual_norm
Definition: SolverOptions.h:954
Definition: SolverOptions.h:142
Definition: SolverOptions.h:157
int coarse_refinements
Definition: SolverOptions.h:943
Definition: SolverOptions.h:135
Definition: SolverOptions.h:154
Definition: SolverOptions.h:104
int min_coarse_matrix_size
Definition: SolverOptions.h:938
Definition: SolverOptions.h:137
double cum_net_time
Definition: SolverOptions.h:964
Definition: SolverOptions.h:165
Definition: SolverOptions.h:97
bool converged
Definition: SolverOptions.h:955
Definition: SolverOptions.h:164
int cum_num_iter
Definition: SolverOptions.h:961
Definition: SolverOptions.h:124
Definition: SolverOptions.h:112
Definition: SolverOptions.h:101
Definition: SolverOptions.h:109
Definition: SolverOptions.h:114
Definition: SolverOptions.h:138
int cum_num_inner_iter
Definition: SolverOptions.h:960
SolverOptions amg_interpolation_method
Definition: SolverOptions.h:918
Definition: SolverOptions.h:118
bool use_panel
Definition: SolverOptions.h:944
Definition: SolverOptions.h:130
bool is_complex
Definition: SolverOptions.h:933
int iter_max
Definition: SolverOptions.h:929
double coarse_level_sparsity
Definition: SolverOptions.h:958
Definition: SolverOptions.h:120
int num_coarse_unknowns
Definition: SolverOptions.h:959
Definition: SolverOptions.h:152
Definition: SolverOptions.h:133
bool symmetric
Definition: SolverOptions.h:934
bool accept_convergence_failure
Definition: SolverOptions.h:937
Definition: SolverOptions.h:132
Definition: SolverOptions.h:126
bool time_step_backtracking_used
Definition: SolverOptions.h:957
Definition: SolverOptions.h:94
double cum_time
Definition: SolverOptions.h:962
double set_up_time
Definition: SolverOptions.h:952
Definition: SolverOptions.h:153
Definition: SolverOptions.h:143
SolverOptions reordering
Definition: SolverOptions.h:916
Definition: SolverOptions.h:110
int inner_iter_max
Definition: SolverOptions.h:930
Definition: SolverOptions.h:122
double absolute_tolerance
Definition: SolverOptions.h:925
Definition: SolverOptions.h:105
SolverOptions target
Definition: SolverOptions.h:910
double drop_storage
Definition: SolverOptions.h:928
SolverOptions coarsening
Definition: SolverOptions.h:917
int num_iter
Definition: SolverOptions.h:948
Definition: SolverOptions.h:113
Definition: SolverOptions.h:134
int num_inner_iter
Definition: SolverOptions.h:950
Definition: SolverOptions.h:103
Definition: SolverOptions.h:156
int pre_sweeps
Definition: SolverOptions.h:922
#define ESCRIPT_DLL_API
Definition: escriptcore/src/system_dep.h:29
double time
Definition: SolverOptions.h:951
bool verbose
Definition: SolverOptions.h:935
Definition: SolverOptions.h:160
int sweeps
Definition: SolverOptions.h:921
SolverOptions preconditioner
Definition: SolverOptions.h:913
double diagonal_dominance_threshold
Definition: SolverOptions.h:945
Definition: SolverOptions.h:127
bool isDirectSolver(const SolverOptions &method)
returns true if the passed solver method refers to a direct solver type
Definition: SolverOptions.h:169
bool use_local_preconditioner
Definition: SolverOptions.h:940
Definition: SolverOptions.h:144
Definition: SolverOptions.h:125
double drop_tolerance
Definition: SolverOptions.h:927
double min_sparsity
Definition: SolverOptions.h:941
SolverOptions ode_solver
Definition: SolverOptions.h:914
Definition: SolverOptions.h:121
double coarsening_threshold
Definition: SolverOptions.h:920
Definition: SolverOptions.h:158
int preconditioner_size
Definition: SolverOptions.h:956
int num_level
Definition: SolverOptions.h:949
Definition: SolverOptions.h:163
double net_time
Definition: SolverOptions.h:953
Definition: SolverOptions.h:117
SolverOptions method
Definition: SolverOptions.h:912
Definition: SolverOptions.h:116
int cycle_type
Definition: SolverOptions.h:946