-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsolvers.cpp
More file actions
126 lines (107 loc) · 2.22 KB
/
Copy pathsolvers.cpp
File metadata and controls
126 lines (107 loc) · 2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/*!
* check solver interfaces
*/
#include <iostream>
#ifndef MPT_INCLUDE
# define MPT_INCLUDE(h) <mpt/solver/h>
#endif
#ifdef with_vode
# include MPT_INCLUDE(vode.h)
#endif
#ifdef with_daesolv
# include MPT_INCLUDE(dassl.h)
# include MPT_INCLUDE(mebdfi.h)
# include MPT_INCLUDE(radau.h)
#endif
#ifdef with_limex
# include MPT_INCLUDE(limex.h)
#endif
#ifdef with_sundials
# include MPT_INCLUDE(sundials.h)
#endif
#ifdef with_nlsolv
# include MPT_INCLUDE(minpack.h)
# include MPT_INCLUDE(portn2.h)
#endif
#ifdef __GLIBC__
# include <mcheck.h>
#else
# define mtrace()
#endif
using namespace mpt;
using namespace mpt::solver;
static int val(void *, const property *pr)
{
if (!pr) {
return BadArgument;
}
if (!pr->name) {
std::cout << '<' << pr->val << '>' << std::endl;
} else {
std::cout << pr->name << " = " << pr->val << std::endl;
}
return 0;
}
static void info(generic &s)
{
property pr("");
const char *name = "";
const char *type = "";
const char *ver = "";
s.property(&pr);
if (pr.name) name = pr.name;
if (pr.desc) type = pr.desc;
pr.name = "version";
s.property(&pr);
ver = pr.val.string();
int types = s.property(0);
println("<%s> [0x%x] %s (%s)", name, types, ver, type);
s.report(Header | Status | Values | Report, val, 0);
println(0);
}
static void pde(IVP &s)
{
double vec[3] = { 1, 2, 3 };
span<double> val(vec, 3);
// PDE equotations and grid
mpt_object_set(&s, "", "iD", 3, val);
// PDE time and start values
mpt_object_set(&s, 0, "dddd", 0.5, 1.1, 1.2, 1.3);
s.set(IVP::rside(0));
s.set(IVP::pdefcn(0));
s.prepare();
}
#ifdef with_nlsolv
static void nls(NLS &s)
{
// equotation count
mpt_object_set(&s, "", "i", 3);
// initial parameter values
mpt_object_set(&s, 0, "ddd", 1.1, 1.2, 1.3);
s.set(NLS::functions(0));
s.prepare();
}
#endif
int main()
{
mtrace();
#ifdef with_vode
Vode v; pde(v); info(v);
#endif
#ifdef with_daesolv
Dassl d; pde(d); info(d);
Mebdfi m; pde(m); info(m);
Radau r; pde(r); info(r);
#endif
#ifdef with_limex
Limex l; pde(l); info(l);
#endif
#ifdef with_sundials
CVode cv; pde(cv); info(cv);
IDA ida; pde(ida); info(ida);
#endif
#ifdef with_nlsolv
MinPack mp; nls(mp); info(mp);
PortN2 n2; nls(n2); info(n2);
#endif
}