11 #ifndef IFPACK2_HYPRE_FUNCTIONPARAMETERS_HPP
12 #define IFPACK2_HYPRE_FUNCTIONPARAMETERS_HPP
14 #include "Ifpack2_ConfigDefs.hpp"
15 #if defined(HAVE_IFPACK2_HYPRE) && defined(HAVE_IFPACK2_MPI)
18 #include "HYPRE_utilities.h"
19 #include "HYPRE_IJ_mv.h"
20 #include "HYPRE_parcsr_ls.h"
22 #include "_hypre_parcsr_mv.h"
23 #include "_hypre_IJ_mv.h"
24 #include "HYPRE_parcsr_mv.h"
28 struct hypre_IJMatrix_struct;
29 typedef struct hypre_IJMatrix_struct *HYPRE_IJMatrix;
30 struct hypre_IJVector_struct;
31 typedef struct hypre_IJVector_struct *HYPRE_IJVector;
32 struct hypre_ParCSRMatrix_struct;
33 typedef struct hypre_ParCSRMatrix_struct* HYPRE_ParCSRMatrix;
34 struct hypre_ParVector_struct;
35 typedef struct hypre_ParVector_struct * HYPRE_ParVector;
36 struct hypre_Solver_struct;
37 typedef struct hypre_Solver_struct *HYPRE_Solver;
38 struct hypre_ParVector_struct;
39 typedef struct hypre_ParVector_struct hypre_ParVector;
61 Hypre_Is_Preconditioner
66 typedef HYPRE_Int (*int_func)(HYPRE_Solver, HYPRE_Int);
67 typedef HYPRE_Int (*double_func)(HYPRE_Solver, HYPRE_Real);
68 typedef HYPRE_Int (*double_int_func)(HYPRE_Solver, HYPRE_Real, HYPRE_Int);
69 typedef HYPRE_Int (*int_double_func)(HYPRE_Solver, HYPRE_Int, HYPRE_Real);
70 typedef HYPRE_Int (*int_int_func)(HYPRE_Solver, HYPRE_Int, HYPRE_Int);
71 typedef HYPRE_Int (*int_star_func)(HYPRE_Solver, HYPRE_Int*);
72 typedef HYPRE_Int (*int_star_star_func)(HYPRE_Solver, HYPRE_Int**);
73 typedef HYPRE_Int (*double_star_func)(HYPRE_Solver, HYPRE_Real*);
74 typedef HYPRE_Int (*int_int_double_double_func)(HYPRE_Solver, HYPRE_Int, HYPRE_Int, HYPRE_Real, HYPRE_Real);
75 typedef HYPRE_Int (*int_int_int_double_int_int_func)(HYPRE_Solver, HYPRE_Int, HYPRE_Int, HYPRE_Int, HYPRE_Real, HYPRE_Int, HYPRE_Int);
76 typedef HYPRE_Int (*char_star_func)(HYPRE_Solver,
char*);
81 void IFPACK2_CHK_ERRV(
int code);
83 void IFPACK2_CHK_ERR(
int code);
86 class FunctionParameter {
89 FunctionParameter(Hypre_Chooser chooser, int_func funct, HYPRE_Int param1) :
93 int_param1_(param1) {}
95 FunctionParameter(Hypre_Chooser chooser, std::string funct_name, HYPRE_Int param1) :
98 int_func_(hypreMapIntFunc_.at(funct_name)),
99 int_param1_(param1) {}
102 FunctionParameter(Hypre_Chooser chooser, double_func funct, HYPRE_Real param1):
106 double_param1_(param1) {}
108 FunctionParameter(Hypre_Chooser chooser, std::string funct_name, HYPRE_Real param1):
111 double_func_(hypreMapDoubleFunc_.at(funct_name)),
112 double_param1_(param1) {}
115 FunctionParameter(Hypre_Chooser chooser, double_int_func funct, HYPRE_Real param1, HYPRE_Int param2):
118 double_int_func_(funct),
120 double_param1_(param1) {}
123 FunctionParameter(Hypre_Chooser chooser, int_double_func funct, HYPRE_Int param1, HYPRE_Real param2):
126 int_double_func_(funct),
128 double_param1_(param2) {}
130 FunctionParameter(Hypre_Chooser chooser, std::string funct_name, HYPRE_Real param1, HYPRE_Int param2):
133 double_int_func_(hypreMapDoubleIntFunc_.at(funct_name)),
135 double_param1_(param1) {}
138 FunctionParameter(Hypre_Chooser chooser, int_int_func funct, HYPRE_Int param1, HYPRE_Int param2):
141 int_int_func_(funct),
143 int_param2_(param2) {}
145 FunctionParameter(Hypre_Chooser chooser, std::string funct_name, HYPRE_Int param1, HYPRE_Int param2):
148 int_int_func_(hypreMapIntIntFunc_.at(funct_name)),
150 int_param2_(param2) {}
153 FunctionParameter(Hypre_Chooser chooser, int_star_func funct, HYPRE_Int *param1):
156 int_star_func_(funct),
157 int_star_param_(param1) {}
159 FunctionParameter(Hypre_Chooser chooser, std::string funct_name, HYPRE_Int *param1):
162 int_star_func_(hypreMapIntStarFunc_.at(funct_name)),
163 int_star_param_(param1) {}
166 FunctionParameter(Hypre_Chooser chooser, double_star_func funct,
double* param1):
169 double_star_func_(funct),
170 double_star_param_(param1) {}
172 FunctionParameter(Hypre_Chooser chooser, std::string funct_name,
double* param1):
175 double_star_func_(hypreMapDoubleStarFunc_.at(funct_name)),
176 double_star_param_(param1) {}
179 FunctionParameter(Hypre_Chooser chooser, int_int_double_double_func funct, HYPRE_Int param1, HYPRE_Int param2, HYPRE_Real param3, HYPRE_Real param4):
182 int_int_double_double_func_(funct),
185 double_param1_(param3),
186 double_param2_(param4) {}
188 FunctionParameter(Hypre_Chooser chooser, std::string funct_name, HYPRE_Int param1, HYPRE_Int param2, HYPRE_Real param3, HYPRE_Real param4):
191 int_int_double_double_func_(hypreMapIntIntDoubleDoubleFunc_.at(funct_name)),
194 double_param1_(param3),
195 double_param2_(param4) {}
198 FunctionParameter(Hypre_Chooser chooser, int_star_star_func funct, HYPRE_Int ** param1):
201 int_star_star_func_(funct),
202 int_star_star_param_(param1) {}
204 FunctionParameter(Hypre_Chooser chooser, std::string funct_name, HYPRE_Int** param1):
207 int_star_star_func_(hypreMapIntStarStarFunc_.at(funct_name)),
208 int_star_star_param_(param1) {}
211 FunctionParameter(Hypre_Chooser chooser, int_int_int_double_int_int_func funct, HYPRE_Int param1, HYPRE_Int param2, HYPRE_Int param3, HYPRE_Real param4, HYPRE_Int param5, HYPRE_Int param6):
214 int_int_int_double_int_int_func_(funct),
220 double_param1_(param4) {}
222 FunctionParameter(Hypre_Chooser chooser, std::string funct_name, HYPRE_Int param1, HYPRE_Int param2, HYPRE_Int param3, HYPRE_Real param4, HYPRE_Int param5, HYPRE_Int param6):
225 int_int_int_double_int_int_func_(hypreMapIntIntIntDoubleIntIntFunc_.at(funct_name)),
231 double_param1_(param4) {}
234 FunctionParameter(Hypre_Chooser chooser, char_star_func funct,
char *param1):
237 char_star_func_(funct),
238 char_star_param_(param1) {}
240 FunctionParameter(Hypre_Chooser chooser, std::string funct_name,
char *param1):
243 char_star_func_(hypreMapCharStarFunc_.at(funct_name)),
244 char_star_param_(param1) {}
247 int CallFunction(HYPRE_Solver solver, HYPRE_Solver precond) {
248 if(chooser_ == Hypre_Is_Solver){
250 return int_func_(solver, int_param1_);
251 }
else if(option_ == 1){
252 return double_func_(solver, double_param1_);
253 }
else if(option_ == 2){
254 return double_int_func_(solver, double_param1_, int_param1_);
255 }
else if (option_ == 3){
256 return int_int_func_(solver, int_param1_, int_param2_);
257 }
else if (option_ == 4){
258 return int_star_func_(solver, int_star_param_);
259 }
else if (option_ == 5){
260 return double_star_func_(solver, double_star_param_);
261 }
else if (option_ == 6) {
262 return int_int_double_double_func_(solver, int_param1_, int_param2_, double_param1_, double_param2_);
263 }
else if (option_ == 7) {
264 return int_star_star_func_(solver, int_star_star_param_);
265 }
else if (option_ == 8) {
266 return int_int_int_double_int_int_func_(solver, int_param1_, int_param2_, int_param3_, double_param1_, int_param4_, int_param5_);
267 }
else if (option_ == 9) {
268 return char_star_func_(solver, char_star_param_);
269 }
else if (option_ == 10) {
270 return int_double_func_(solver, int_param1_, double_param1_);
276 return int_func_(precond, int_param1_);
277 }
else if(option_ == 1){
278 return double_func_(precond, double_param1_);
279 }
else if(option_ == 2){
280 return double_int_func_(precond, double_param1_, int_param1_);
281 }
else if(option_ == 3) {
282 return int_int_func_(precond, int_param1_, int_param2_);
283 }
else if(option_ == 4) {
284 return int_star_func_(precond, int_star_param_);
285 }
else if(option_ == 5) {
286 return double_star_func_(precond, double_star_param_);
287 }
else if (option_ == 6) {
288 return int_int_double_double_func_(precond, int_param1_, int_param2_, double_param1_, double_param2_);
289 }
else if (option_ == 7) {
290 return int_star_star_func_(precond, int_star_star_param_);
291 }
else if (option_ == 8) {
292 return int_int_int_double_int_int_func_(precond, int_param1_, int_param2_, int_param3_, double_param1_, int_param4_, int_param5_);
293 }
else if (option_ == 9) {
294 return char_star_func_(solver, char_star_param_);
295 }
else if (option_ == 10) {
296 return int_double_func_(precond, int_param1_, double_param1_);
304 static bool isFuncIntInt(std::string funct_name) {
305 return (hypreMapIntIntFunc_.find(funct_name) != hypreMapIntIntFunc_.end());
308 static bool isFuncIntIntDoubleDouble(std::string funct_name) {
309 return (hypreMapIntIntDoubleDoubleFunc_.find(funct_name) != hypreMapIntIntDoubleDoubleFunc_.end());
312 static bool isFuncIntIntIntDoubleIntInt(std::string funct_name) {
313 return (hypreMapIntIntIntDoubleIntIntFunc_.find(funct_name) != hypreMapIntIntIntDoubleIntIntFunc_.end());
316 static bool isFuncIntStarStar(std::string funct_name) {
317 return (hypreMapIntStarStarFunc_.find(funct_name) != hypreMapIntStarStarFunc_.end());
321 Hypre_Chooser chooser_;
324 double_func double_func_;
325 double_int_func double_int_func_;
326 int_double_func int_double_func_;
327 int_int_func int_int_func_;
328 int_star_func int_star_func_;
329 double_star_func double_star_func_;
330 int_int_double_double_func int_int_double_double_func_;
331 int_int_int_double_int_int_func int_int_int_double_int_int_func_;
332 int_star_star_func int_star_star_func_;
333 char_star_func char_star_func_;
334 HYPRE_Int int_param1_;
335 HYPRE_Int int_param2_;
336 HYPRE_Int int_param3_;
337 HYPRE_Int int_param4_;
338 HYPRE_Int int_param5_;
339 HYPRE_Real double_param1_;
340 HYPRE_Real double_param2_;
341 HYPRE_Int *int_star_param_;
342 HYPRE_Int **int_star_star_param_;
343 HYPRE_Real *double_star_param_;
344 char *char_star_param_;
346 static const std::map<std::string, int_func> hypreMapIntFunc_;
347 static const std::map<std::string, double_func> hypreMapDoubleFunc_;
348 static const std::map<std::string, double_int_func> hypreMapDoubleIntFunc_;
349 static const std::map<std::string, int_double_func> hypreMapIntDoubleFunc_;
350 static const std::map<std::string, int_int_func> hypreMapIntIntFunc_;
351 static const std::map<std::string, int_star_func> hypreMapIntStarFunc_;
352 static const std::map<std::string, double_star_func> hypreMapDoubleStarFunc_;
353 static const std::map<std::string, int_int_double_double_func> hypreMapIntIntDoubleDoubleFunc_;
354 static const std::map<std::string, int_int_int_double_int_int_func> hypreMapIntIntIntDoubleIntIntFunc_;
355 static const std::map<std::string, int_star_star_func> hypreMapIntStarStarFunc_;
356 static const std::map<std::string, char_star_func> hypreMapCharStarFunc_;
362 #endif // HAVE_IFPACK2_HYPRE && HAVE_IFPACK2_MPI
Uses AztecOO's GMRES.
Definition: Ifpack2_CondestType.hpp:20