Line data Source code
1 : /*
2 : * Copyright (c) 2014: G-CSC, Goethe University Frankfurt
3 : * Author: Martin Rupp
4 : *
5 : * This file is part of UG4.
6 : *
7 : * UG4 is free software: you can redistribute it and/or modify it under the
8 : * terms of the GNU Lesser General Public License version 3 (as published by the
9 : * Free Software Foundation) with the following additional attribution
10 : * requirements (according to LGPL/GPL v3 §7):
11 : *
12 : * (1) The following notice must be displayed in the Appropriate Legal Notices
13 : * of covered and combined works: "Based on UG4 (www.ug4.org/license)".
14 : *
15 : * (2) The following notice must be displayed at a prominent place in the
16 : * terminal output of covered works: "Based on UG4 (www.ug4.org/license)".
17 : *
18 : * (3) The following bibliography is recommended for citation and must be
19 : * preserved in all covered files:
20 : * "Reiter, S., Vogel, A., Heppner, I., Rupp, M., and Wittum, G. A massively
21 : * parallel geometric multigrid solver on hierarchically distributed grids.
22 : * Computing and visualization in science 16, 4 (2013), 151-164"
23 : * "Vogel, A., Reiter, S., Rupp, M., Nägel, A., and Wittum, G. UG4 -- a novel
24 : * flexible software system for simulating pde based models on high performance
25 : * computers. Computing and visualization in science 16, 4 (2013), 165-179"
26 : *
27 : * This program is distributed in the hope that it will be useful,
28 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
29 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 : * GNU Lesser General Public License for more details.
31 : */
32 :
33 : /*
34 : * http://crd-legacy.lbl.gov/~xiaoye/SuperLU
35 : */
36 :
37 : #ifndef __H__UG__SUPER_LU_SOLVER__
38 : #define __H__UG__SUPER_LU_SOLVER__
39 :
40 :
41 : #define SUPERLU_6_EXPERIMENTAL 1
42 :
43 : #include "lib_algebra/operator/linear_solver/external_solvers/external_solvers.h"
44 : #include <vector>
45 :
46 :
47 : namespace ug{
48 :
49 : struct SuperLUConfiguration
50 : {
51 : bool bPrintStat;
52 : bool equil;
53 : enum
54 : {
55 : CPT_NATURAL, CPT_MMD_ATA, CPT_MMD_AT_PLUS_A, CPT_COLAMD
56 : } colPerm;
57 : };
58 :
59 :
60 : IExternalSolverImplementation *CreateSuperLUImplementation(SuperLUConfiguration &config);
61 :
62 :
63 : template<typename TAlgebra>
64 0 : class SuperLUSolver : public IExternalSolver<TAlgebra>
65 : {
66 : SuperLUConfiguration config;
67 : IExternalSolverImplementation *impl;
68 : public:
69 :
70 : using IExternalSolver<TAlgebra>::init;
71 :
72 0 : SuperLUSolver()
73 0 : {
74 0 : config.bPrintStat = false;
75 0 : config.equil = true;
76 0 : config.colPerm = SuperLUConfiguration::CPT_COLAMD;
77 :
78 0 : impl = CreateSuperLUImplementation(config);
79 0 : }
80 :
81 0 : void print_stat(bool b)
82 : {
83 0 : config.bPrintStat = b;
84 0 : }
85 :
86 0 : void equil(bool b)
87 : {
88 0 : config.equil = b;
89 0 : }
90 :
91 0 : void col_perm_natural()
92 : {
93 0 : config.colPerm = SuperLUConfiguration::CPT_NATURAL;
94 0 : }
95 :
96 0 : void col_perm_mdo_ATA()
97 : {
98 0 : config.colPerm = SuperLUConfiguration::CPT_MMD_ATA;
99 0 : }
100 :
101 0 : void col_perm_mdo_AT_plus_A()
102 : {
103 0 : config.colPerm = SuperLUConfiguration::CPT_MMD_AT_PLUS_A;
104 0 : }
105 :
106 0 : void col_perm_approximate()
107 : {
108 0 : config.colPerm = SuperLUConfiguration::CPT_COLAMD;
109 0 : }
110 :
111 :
112 0 : virtual bool double_apply(CPUAlgebra::vector_type &c, const CPUAlgebra::vector_type &d)
113 : {
114 0 : return impl->apply(c, d);
115 : }
116 :
117 0 : virtual const char *double_name() const
118 : {
119 0 : return impl->name();
120 : }
121 :
122 0 : virtual void double_init(const CPUAlgebra::matrix_type &mat)
123 : {
124 0 : impl->init(mat);
125 0 : }
126 :
127 : };
128 :
129 : } // end namespace ug
130 :
131 : #endif
132 :
|