1
1
#include " options.hpp"
2
+ #include < stdexcept>
3
+
4
+
5
+ using namespace std ::string_literals;
2
6
3
7
Options::Options (py::dict options)
4
8
: print_stats(options[" print_stats" ].cast<bool >()),
@@ -23,8 +27,10 @@ Options::Options(py::dict options)
23
27
}
24
28
else
25
29
{
26
- py::print (" Unknown jacobian type, using sparse by default" );
27
- jacobian = " sparse" ;
30
+ throw std::domain_error (
31
+ " Unknown jacobian type \" " s + jacobian +
32
+ " \" . Should be one of \" sparse\" , \" dense\" , \" matrix-free\" or \" none\" ." s
33
+ );
28
34
}
29
35
30
36
using_iterative_solver = false ;
@@ -47,30 +53,37 @@ Options::Options(py::dict options)
47
53
}
48
54
else if (jacobian == " sparse" )
49
55
{
50
- py::print (" Unknown linear solver or incompatible options using "
51
- " SUNLinSol_KLU by default" );
52
- linear_solver = " SUNLinSol_KLU" ;
56
+ throw std::domain_error (
57
+ " Unknown linear solver or incompatible options. For a sparse jacobian "
58
+ " please use the SUNLinSol_KLU linear solver"
59
+ );
53
60
}
54
61
else if (jacobian == " matrix-free" )
55
62
{
56
- py::print (" Unknown linear solver or incompatible options using "
57
- " SUNLinSol_SPBCGS by default" );
58
- linear_solver = " SUNLinSol_SPBCGS" ;
59
- using_iterative_solver = true ;
63
+ throw std::domain_error (
64
+ " Unknown linear solver or incompatible options. For a matrix-free jacobian "
65
+ " please use one of the iterative linear solvers: \" SUNLinSol_SPBCGS\" , "
66
+ " \" SUNLinSol_SPFGMR\" , \" SUNLinSol_SPGMR\" , or \" SUNLinSol_SPTFQMR\" ."
67
+ );
60
68
}
61
69
else
62
70
{
63
- py::print (" Unknown linear solver or incompatible options using "
64
- " SUNLinSol_Dense by default" );
65
- linear_solver = " SUNLinSol_Dense" ;
71
+ throw std::domain_error (
72
+ " Unknown linear solver \" " s + linear_solver +
73
+ " \" , use one of \" SUNLinSol_KLU\" , \" SUNLinSol_Dense\" , "
74
+ " \" SUNLinSol_LapackDense\" , \" SUNLinSol_SPBCGS\" , \" SUNLinSol_SPFGMR\" , "
75
+ " \" SUNLinSol_SPGMR\" , or \" SUNLinSol_SPTFQMR\" "
76
+ );
66
77
}
67
78
68
79
if (using_iterative_solver)
69
80
{
70
81
if (preconditioner != " none" && preconditioner != " BBDP" )
71
82
{
72
- py::print (" Unknown preconditioner using BBDP by default" );
73
- preconditioner = " BBDP" ;
83
+ throw std::domain_error (
84
+ " Unknown preconditioner \" " s + preconditioner +
85
+ " \" , use one of \" BBDP\" or \" none\" " s
86
+ );
74
87
}
75
88
}
76
89
else
0 commit comments