openCARP
Doxygen code documentation for the open cardiac electrophysiology simulator openCARP
SF_abstract_lin_solver.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) NumeriCor GmbH
2 // SPDX-License-Identifier: Apache-2.0
3 
4 #ifndef _SF_ABSTRACT_LIN_SOLVER_H
5 #define _SF_ABSTRACT_LIN_SOLVER_H
6 
7 #include "SF_abstract_matrix.h"
8 #include "SF_abstract_vector.h"
9 
10 namespace SF {
11 
24 template<class T, class S>
26 {
27  std::string name;
28  const char* options_file;
29 
33 
34  // solver statistics
36  SF_real time = 0.0;
37  SF_int niter = -1;
38  SF_int max_it = 0;
39  SF_int reason = 0;
40 
47  virtual void operator() (abstract_vector<T,S> & x, const abstract_vector<T,S> & b) = 0;
48 
50  virtual ~abstract_linear_solver() = default;
51 
63  virtual void setup_solver(abstract_matrix<T, S>& mat, double tol, int max_it,
64  short norm, std::string name, bool has_nullspace,
65  void* logger, // TODO: maybe solver logging needs to be revisited
66  const char* solver_opts_file,
67  const char* default_opts) = 0;
68 
69  protected:
79  virtual void set_stopping_criterion(norm_t normtype, double tol, int max_it,
80  bool verbose, void* logger) = 0;
81 
89  norm_t convert_param_norm_type(short param_norm_type) const
90  {
91  norm_t normtype = absPreResidual;
92 
93  switch (param_norm_type) {
94  default:
95  case 0: normtype = absPreResidual; break;
96  case 1: normtype = absUnpreResidual; break;
97  case 2: normtype = relResidual; break;
98  case 3: normtype = absPreRelResidual; break;
99  }
100 
101  return normtype;
102  }
103 };
104 
105 } // namespace SF
106 
107 
108 #endif // _SF_ABSTRACT_LIN_SOLVER_H
opencarp::real_t SF_real
Global scalar type.
Definition: SF_globals.h:18
opencarp::global_index_t SF_int
Global algebraic index type.
Definition: SF_globals.h:17
Definition: dense_mat.hpp:19
SF_int max_it
max number of iterations
norm_t convert_param_norm_type(short param_norm_type) const
SF_int niter
number of iterations
SF_real final_residual
Holds the residual after convergence.
virtual void set_stopping_criterion(norm_t normtype, double tol, int max_it, bool verbose, void *logger)=0
const char * options_file
the file containing the solver options
virtual ~abstract_linear_solver()=default
SF_int reason
number of iterations
std::string name
the solver name
virtual void setup_solver(abstract_matrix< T, S > &mat, double tol, int max_it, short norm, std::string name, bool has_nullspace, void *logger, const char *solver_opts_file, const char *default_opts)=0
virtual void operator()(abstract_vector< T, S > &x, const abstract_vector< T, S > &b)=0