openCARP
Doxygen code documentation for the open cardiac electrophysiology simulator openCARP
fem
slimfem
src
SF_abstract_lin_solver.h
Go to the documentation of this file.
1
// ----------------------------------------------------------------------------
2
// openCARP is an open cardiac electrophysiology simulator.
3
//
4
// Copyright (C) 2020 openCARP project
5
//
6
// This program is licensed under the openCARP Academic Public License (APL)
7
// v1.0: You can use and redistribute it and/or modify it in non-commercial
8
// academic environments under the terms of APL as published by the openCARP
9
// project v1.0, or (at your option) any later version. Commercial use requires
10
// a commercial license (info@opencarp.org).
11
//
12
// This program is distributed without any warranty; see the openCARP APL for
13
// more details.
14
//
15
// You should have received a copy of the openCARP APL along with this program
16
// and can find it online: http://www.opencarp.org/license
17
// ----------------------------------------------------------------------------
18
19
#ifndef _SF_ABSTRACT_LIN_SOLVER_H
20
#define _SF_ABSTRACT_LIN_SOLVER_H
21
22
#include "
SF_abstract_matrix.h
"
23
#include "
SF_abstract_vector.h
"
24
25
namespace
SF
{
26
39
template
<
class
T,
class
S>
40
struct
abstract_linear_solver
41
{
42
std::string
name
;
43
const
char
*
options_file
;
44
46
enum
norm_t
{
absPreResidual
,
absUnpreResidual
,
relResidual
,
absPreRelResidual
,
norm_unset
};
47
norm_t
norm
=
norm_unset
;
48
49
// solver statistics
50
SF_real
final_residual
= -1.0;
51
SF_real
time
= 0.0;
52
SF_int
niter
= -1;
53
SF_int
max_it
= 0;
54
SF_int
reason
= 0;
55
62
virtual
void
operator()
(
abstract_vector<T,S>
& x,
const
abstract_vector<T,S>
& b) = 0;
63
65
virtual
~abstract_linear_solver
() =
default
;
66
78
virtual
void
setup_solver
(
abstract_matrix<T, S>
& mat,
double
tol,
int
max_it,
79
short
norm, std::string name,
bool
has_nullspace,
80
void
* logger,
// TODO: maybe solver logging needs to be revisited
81
const
char
* solver_opts_file,
82
const
char
* default_opts) = 0;
83
84
protected
:
94
virtual
void
set_stopping_criterion
(
norm_t
normtype,
double
tol,
int
max_it,
95
bool
verbose,
void
* logger) = 0;
96
104
norm_t
convert_param_norm_type
(
short
param_norm_type)
const
105
{
106
norm_t
normtype =
absPreResidual
;
107
108
switch
(param_norm_type) {
109
default
:
110
case
0: normtype =
absPreResidual
;
break
;
111
case
1: normtype =
absUnpreResidual
;
break
;
112
case
2: normtype =
relResidual
;
break
;
113
case
3: normtype =
absPreRelResidual
;
break
;
114
}
115
116
return
normtype;
117
}
118
};
119
120
}
// namespace SF
121
122
123
#endif // _SF_ABSTRACT_LIN_SOLVER_H
SF::abstract_linear_solver::norm_t
norm_t
Definition:
SF_abstract_lin_solver.h:46
SF
Definition:
dense_mat.hpp:34
SF::abstract_linear_solver::niter
SF_int niter
number of iterations
Definition:
SF_abstract_lin_solver.h:52
SF::abstract_linear_solver::set_stopping_criterion
virtual void set_stopping_criterion(norm_t normtype, double tol, int max_it, bool verbose, void *logger)=0
SF::abstract_linear_solver::convert_param_norm_type
norm_t convert_param_norm_type(short param_norm_type) const
Definition:
SF_abstract_lin_solver.h:104
SF::abstract_linear_solver::max_it
SF_int max_it
max number of iterations
Definition:
SF_abstract_lin_solver.h:53
SF::abstract_linear_solver::absPreResidual
Definition:
SF_abstract_lin_solver.h:46
SF::abstract_linear_solver::absPreRelResidual
Definition:
SF_abstract_lin_solver.h:46
SF::abstract_linear_solver
Definition:
SF_abstract_lin_solver.h:40
SF_abstract_matrix.h
SF::abstract_linear_solver::name
std::string name
the solver name
Definition:
SF_abstract_lin_solver.h:42
SF_abstract_vector.h
SF::abstract_linear_solver::time
SF_real time
solver runtime
Definition:
SF_abstract_lin_solver.h:51
SF::abstract_linear_solver::setup_solver
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
SF::abstract_linear_solver::norm
norm_t norm
Definition:
SF_abstract_lin_solver.h:47
SF::abstract_linear_solver::final_residual
SF_real final_residual
Holds the residual after convergence.
Definition:
SF_abstract_lin_solver.h:50
SF::abstract_linear_solver::absUnpreResidual
Definition:
SF_abstract_lin_solver.h:46
SF::abstract_linear_solver::operator()
virtual void operator()(abstract_vector< T, S > &x, const abstract_vector< T, S > &b)=0
SF::abstract_linear_solver::norm_unset
Definition:
SF_abstract_lin_solver.h:46
SF::abstract_linear_solver::relResidual
Definition:
SF_abstract_lin_solver.h:46
SF::abstract_linear_solver::reason
SF_int reason
number of iterations
Definition:
SF_abstract_lin_solver.h:54
SF::abstract_linear_solver::~abstract_linear_solver
virtual ~abstract_linear_solver()=default
SF::abstract_matrix
Definition:
SF_abstract_matrix.h:44
SF::abstract_vector
Definition:
SF_abstract_vector.h:54
SF::abstract_linear_solver::options_file
const char * options_file
the file containing the solver options
Definition:
SF_abstract_lin_solver.h:43
SF_int
std::int32_t SF_int
Use the general std::int32_t as int type.
Definition:
SF_globals.h:37
SF_real
double SF_real
Use the general double as real type.
Definition:
SF_globals.h:38
Generated by
1.8.13