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 
80 {
82 
83  // Solver targets
86 
87  // Solver packages
92 
93  // Solver methods
114 
115  // Preconditioners
124 
125  // ODE solvers
129 
130  // Interpolation methods
134 
139 };
140 
142 inline bool isDirectSolver(const SolverOptions& method)
143 {
144  switch (method) {
145  case SO_METHOD_DIRECT:
150  return true;
151  default:
152  break;
153  }
154  return false;
155 }
156 
158 {
159 public:
160  SolverBuddy();
161  ~SolverBuddy();
162 
166  std::string getSummary() const;
167 
173  const char* getName(int key) const;
174 
181  void resetDiagnostics(bool all=false);
182 
191  void updateDiagnosticsPy(const std::string& key,
192  const boost::python::object& value);
193 
194  void updateDiagnostics(const std::string& key, bool value);
195  void updateDiagnostics(const std::string& key, int value);
196  void updateDiagnostics(const std::string& key, double value);
197 
226  double getDiagnostics(const std::string name) const;
227 
235  bool hasConverged() const;
236 
251  void setPreconditioner(int preconditioner);
252 
256  SolverOptions getPreconditioner() const;
257 
278  void setSolverMethod(int method);
279 
283  SolverOptions getSolverMethod() const;
284 
297  void setPackage(int package);
298 
302  SolverOptions getPackage() const;
303 
313  void setReordering(int ordering);
314 
319  SolverOptions getReordering() const;
320 
328  void setRestart(int restart);
329 
334  int getRestart() const;
335 
340  int _getRestartForC() const;
341 
347  void setTruncation(int truncation);
348 
353  int getTruncation() const;
354 
360  void setInnerIterMax(int iter_max);
361 
365  int getInnerIterMax() const;
366 
372  void setIterMax(int iter_max);
373 
377  int getIterMax() const;
378 
385  void setNumSweeps(int sweeps);
386 
391  int getNumSweeps() const;
392 
398  void setTolerance(double rtol);
399 
403  double getTolerance() const;
404 
410  void setAbsoluteTolerance(double atol);
411 
415  double getAbsoluteTolerance() const;
416 
423  void setInnerTolerance(double rtol);
424 
428  double getInnerTolerance() const;
429 
435  void setDropTolerance(double drop_tol);
436 
440  double getDropTolerance() const;
441 
449  void setDropStorage(double drop);
450 
454  double getDropStorage() const;
455 
463  void setRelaxationFactor(double factor);
464 
469  double getRelaxationFactor() const;
470 
476  bool isComplex() const;
477 
483  void setComplex(bool complex);
484 
490  bool isSymmetric() const;
491 
496  void setSymmetryOn();
497 
501  void setSymmetryOff();
502 
508  void setSymmetry(bool symmetry);
509 
515  bool isHermitian() const;
516 
521  void setHermitianOn();
522 
526  void setHermitianOff();
527 
533  void setHermitian(bool hermitian);
534 
540  bool isVerbose() const;
541 
545  void setVerbosityOn();
546 
550  void setVerbosityOff();
551 
557  void setVerbosity(bool verbose);
558 
566  bool adaptInnerTolerance() const;
567 
571  void setInnerToleranceAdaptionOn();
572 
576  void setInnerToleranceAdaptionOff();
577 
583  void setInnerToleranceAdaption(bool adaption);
584 
595  bool acceptConvergenceFailure() const;
596 
600  void setAcceptanceConvergenceFailureOn();
601 
605  void setAcceptanceConvergenceFailureOff();
606 
613  void setAcceptanceConvergenceFailure(bool acceptance);
614 
621  bool useLocalPreconditioner() const;
622 
626  void setLocalPreconditionerOn();
627 
631  void setLocalPreconditionerOff();
632 
639  void setLocalPreconditioner(bool local);
640 
647  void setNumRefinements(int refinements);
648 
653  int getNumRefinements() const;
654 
662  void setODESolver(int solver);
663 
667  SolverOptions getODESolver() const;
668 
678  void setTrilinosParameter(const std::string& name,
679  const boost::python::object& value);
680 
685  boost::python::dict getTrilinosParameters() const;
686 
690  void setDim(int dim);
691 
695  int getDim();
696 
700  bool using_default_method() const;
701 
702 
703 protected:
704  boost::python::dict trilinosParams;
705 
712  int sweeps;
713  double tolerance;
717  double drop_storage;
718  int iter_max;
721  int restart; //0 will have to be None in python, will get tricky
723  bool symmetric;
724  bool hermitian;
725  bool verbose;
728  double relaxation;
731  int dim; // Dimension of the problem, either 2 or 3. Used internally
732 
733  int num_iter;
736  double time;
737  double set_up_time;
738  double net_time;
740  bool converged;
747  double cum_time;
749  double cum_net_time;
750 
752 };
753 
754 typedef boost::shared_ptr<SolverBuddy> SB_ptr;
755 
756 } // namespace escript
757 
758 #endif // __ESCRIPT_SOLVEROPTIONS_H__
759 
Definition: SolverOptions.h:85
int refinements
Definition: SolverOptions.h:730
int restart
Definition: SolverOptions.h:721
boost::python::dict trilinosParams
Definition: SolverOptions.h:704
Definition: SolverOptions.h:157
Definition: SolverOptions.h:105
Definition: SolverOptions.h:88
bool adapt_inner_tolerance
Definition: SolverOptions.h:726
Definition: SolverOptions.h:135
double relaxation
Definition: SolverOptions.h:728
double tolerance
Definition: SolverOptions.h:713
int dim
Definition: SolverOptions.h:731
SolverOptions package
Definition: SolverOptions.h:707
Definition: SolverOptions.h:131
SolverOptions
Definition: SolverOptions.h:79
Definition: SolverOptions.h:109
Definition: AbstractContinuousDomain.cpp:22
double cum_set_up_time
Definition: SolverOptions.h:748
Definition: SolverOptions.h:101
Definition: SolverOptions.h:120
Definition: SolverOptions.h:123
Definition: SolverOptions.h:97
boost::shared_ptr< SolverBuddy > SB_ptr
Definition: SolverOptions.h:754
double inner_tolerance
Definition: SolverOptions.h:715
Definition: SolverOptions.h:94
Definition: SolverOptions.h:133
int truncation
Definition: SolverOptions.h:720
double residual_norm
Definition: SolverOptions.h:739
Definition: SolverOptions.h:126
Definition: SolverOptions.h:119
bool using_default_solver_method
Definition: SolverOptions.h:751
Definition: SolverOptions.h:90
Definition: SolverOptions.h:121
double cum_net_time
Definition: SolverOptions.h:749
Definition: SolverOptions.h:138
Definition: SolverOptions.h:84
bool converged
Definition: SolverOptions.h:740
Definition: SolverOptions.h:137
int cum_num_iter
Definition: SolverOptions.h:746
Definition: SolverOptions.h:110
Definition: SolverOptions.h:98
Definition: SolverOptions.h:95
Definition: SolverOptions.h:100
Definition: SolverOptions.h:122
int cum_num_inner_iter
Definition: SolverOptions.h:745
Definition: SolverOptions.h:104
Definition: SolverOptions.h:116
bool is_complex
Definition: SolverOptions.h:722
int iter_max
Definition: SolverOptions.h:718
double coarse_level_sparsity
Definition: SolverOptions.h:743
Definition: SolverOptions.h:106
int num_coarse_unknowns
Definition: SolverOptions.h:744
Definition: SolverOptions.h:117
bool symmetric
Definition: SolverOptions.h:723
bool accept_convergence_failure
Definition: SolverOptions.h:727
Definition: SolverOptions.h:112
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:915
bool time_step_backtracking_used
Definition: SolverOptions.h:742
Definition: SolverOptions.h:81
double cum_time
Definition: SolverOptions.h:747
double set_up_time
Definition: SolverOptions.h:737
Definition: SolverOptions.h:127
bool hermitian
Definition: SolverOptions.h:724
SolverOptions reordering
Definition: SolverOptions.h:711
Definition: SolverOptions.h:96
int inner_iter_max
Definition: SolverOptions.h:719
Definition: SolverOptions.h:108
double absolute_tolerance
Definition: SolverOptions.h:714
Definition: SolverOptions.h:91
SolverOptions target
Definition: SolverOptions.h:706
double drop_storage
Definition: SolverOptions.h:717
int num_iter
Definition: SolverOptions.h:733
Definition: SolverOptions.h:99
Definition: SolverOptions.h:118
int num_inner_iter
Definition: SolverOptions.h:735
Definition: SolverOptions.h:89
#define ESCRIPT_DLL_API
Definition: escriptcore/src/system_dep.h:29
double time
Definition: SolverOptions.h:736
bool verbose
Definition: SolverOptions.h:725
int sweeps
Definition: SolverOptions.h:712
SolverOptions preconditioner
Definition: SolverOptions.h:709
Definition: SolverOptions.h:113
bool isDirectSolver(const SolverOptions &method)
returns true if the passed solver method refers to a direct solver type
Definition: SolverOptions.h:142
bool use_local_preconditioner
Definition: SolverOptions.h:729
Definition: SolverOptions.h:128
Definition: SolverOptions.h:111
double drop_tolerance
Definition: SolverOptions.h:716
SolverOptions ode_solver
Definition: SolverOptions.h:710
Definition: SolverOptions.h:107
int preconditioner_size
Definition: SolverOptions.h:741
int num_level
Definition: SolverOptions.h:734
Definition: SolverOptions.h:136
double net_time
Definition: SolverOptions.h:738
Definition: SolverOptions.h:103
SolverOptions method
Definition: SolverOptions.h:708
Definition: SolverOptions.h:102