DUNE-FEM (unstable)

umfpack.hh
1#ifndef DUNE_FEM_MISC_UMFPACK_HH
2#define DUNE_FEM_MISC_UMFPACK_HH
3
4#include <complex>
5
6#if HAVE_DUNE_ISTL
8#endif
9
10#if HAVE_SUITESPARSE_UMFPACK
11#include <umfpack.h>
12
13#include <dune/fem/misc/double.hh>
14
15namespace Dune
16{
17
18 // UMFPackMethodChooser
19 // --------------------
20
21#if not HAVE_DUNE_ISTL
22 template< class T >
23 struct UMFPackMethodChooser {};
24
25
26 template< >
27 struct UMFPackMethodChooser< double >
28 {
29 template< class... A >
30 static void defaults ( A ... args )
31 {
32 umfpack_dl_defaults( args ... );
33 }
34 template< class ... A >
35 static void free_numeric ( A ... args )
36 {
37 umfpack_dl_free_numeric( args ... );
38 }
39 template< class ... A >
40 static void free_symbolic ( A ... args )
41 {
42 umfpack_dl_free_symbolic( args ... );
43 }
44 template< class ... A >
45 static int load_numeric ( A ... args )
46 {
47 return umfpack_dl_load_numeric( args ... );
48 }
49 template< class ... A >
50 static void numeric ( A ... args )
51 {
52 umfpack_dl_numeric( args ... );
53 }
54 template< class ... A >
55 static void report_info ( A ... args )
56 {
57 umfpack_dl_report_info( args ... );
58 }
59 template< class ... A >
60 static void report_status ( A ... args )
61 {
62 umfpack_dl_report_status( args ... );
63 }
64 template< class ... A >
65 static int save_numeric ( A ... args )
66 {
67 return umfpack_di_save_numeric( args ... );
68 }
69 template< class ... A >
70 static void solve ( A ... args )
71 {
72 umfpack_dl_solve( args ... );
73 }
74 template< class ... A >
75 static void symbolic ( A ... args )
76 {
77 umfpack_dl_symbolic( args ... );
78 }
79 };
80
81 template< >
82 struct UMFPackMethodChooser< std::complex< double > >
83 {
84 template< class ... A >
85 static void defaults ( A ... args )
86 {
87 umfpack_zi_defaults( args ... );
88 }
89 template< class ... A >
90 static void free_numeric ( A ... args )
91 {
92 umfpack_zi_free_numeric( args ... );
93 }
94 template< class ... A >
95 static void free_symbolic ( A ... args )
96 {
97 umfpack_zi_free_symbolic( args ... );
98 }
99 template< class ... A >
100 static int load_numeric ( A ... args )
101 {
102 return umfpack_zi_load_numeric( args ... );
103 }
104 template< class ... A >
105 static void numeric ( const int *cs, const int *ri, const double *val, A ... args )
106 {
107 umfpack_zi_numeric( cs, ri, val, nullptr, args ... );
108 }
109 template< class ... A >
110 static void report_info ( A ... args )
111 {
112 umfpack_zi_report_info( args ... );
113 }
114 template< class ... A >
115 static void report_status ( A ... args )
116 {
117 umfpack_zi_report_status( args ... );
118 }
119 template< class ... A >
120 static int save_numeric ( A ... args )
121 {
122 return umfpack_zi_save_numeric( args ... );
123 }
124 template< class ... A >
125 static void solve ( int m, const int *cs, const int *ri, std::complex< double > *val, double *x, const double *b, A ... args )
126 {
127 const double *cval = reinterpret_cast< const double * >(val);
128 umfpack_zi_solve( m, cs, ri, cval, nullptr, x, nullptr, b, nullptr, args ... );
129 }
130 template< class ... A >
131 static void symbolic ( int m, int n, const int *cs, const int *ri, const double *val, A ... args )
132 {
133 umfpack_zi_symbolic( m, n, cs, ri, val, nullptr, args ... );
134 }
135 };
136#endif // #if not HAVE_DUNE_ISTL
137
138 template< >
139 struct UMFPackMethodChooser< Fem::Double >
140 {
141 template< class... A >
142 static void defaults ( A ... args )
143 {
144 umfpack_di_defaults( args ... );
145 }
146 template< class ... A >
147 static void free_numeric ( A ... args )
148 {
149 umfpack_di_free_numeric( args ... );
150 }
151 template< class ... A >
152 static void free_symbolic ( A ... args )
153 {
154 umfpack_di_free_symbolic( args ... );
155 }
156 template< class ... A >
157 static int load_numeric ( A ... args )
158 {
159 return umfpack_di_load_numeric( args ... );
160 }
161 template< class ... A >
162 static void numeric ( A ... args )
163 {
164 umfpack_di_numeric( args ... );
165 }
166 template< class ... A >
167 static void report_info ( A ... args )
168 {
169 umfpack_di_report_info( args ... );
170 }
171 template< class ... A >
172 static void report_status ( A ... args )
173 {
174 umfpack_di_report_status( args ... );
175 }
176 template< class ... A >
177 static int save_numeric ( A ... args )
178 {
179 return umfpack_di_save_numeric( args ... );
180 }
181 template< class ... A >
182 static void symbolic ( A ... args )
183 {
184 umfpack_di_symbolic( args ... );
185 }
186 static void numeric ( const int *Ap, const int *Ai, const double *Ax, void* Symbolic, void **Numeric,
187 const double Control[ UMFPACK_CONTROL], double Info[ UMFPACK_INFO] )
188 {
189 umfpack_di_numeric( Ap, Ai, Ax, Symbolic, Numeric, Control, Info );
190 Fem::FlOpCounter< Fem::Double >::instance() += Info[ UMFPACK_FLOPS ];
191 }
192
193 static void solve ( int m, const int *cs, const int *ri, const Fem::Double *val, Fem::Double *x, const Fem::Double *b,
194 void *Numeric, const double Control[ UMFPACK_CONTROL ], double Info[ UMFPACK_INFO ] )
195 {
196 umfpack_di_solve( m, cs, ri, reinterpret_cast< const double * >(val),
197 reinterpret_cast< double * >( x ), reinterpret_cast< const double * >( b ), Numeric, Control, Info );
198 Fem::FlOpCounter< Fem::Double >::instance() += Info[ UMFPACK_SOLVE_FLOPS ];
199 }
200 };
201
202} // namespace Dune
203
204#endif // #if HAVE_SUITESPARSE_UMFPACK
205
206#endif // #ifndef DUNE_FEM_MISC_UMFPACK_HH
Classes for using UMFPack with ISTL matrices.
Dune namespace.
Definition: alignedallocator.hh:13
STL namespace.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 27, 22:29, 2024)