Hex: src/factorizers/lu-pardiso.h Source File

| Hex 2.2 Hydrogen-electron collision solver

lu-pardiso.h
Go to the documentation of this file.
1 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
2 // //
3 // / / / / __ \ \ / / //
4 // / /__ / / / _ \ \ \/ / //
5 // / ___ / | |/_/ / /\ \ //
6 // / / / / \_\ / / \ \ //
7 // //
8 // //
9 // Copyright (c) 2016, Jakub Benda, Charles University in Prague //
10 // //
11 // MIT License: //
12 // //
13 // Permission is hereby granted, free of charge, to any person obtaining a //
14 // copy of this software and associated documentation files (the "Software"), //
15 // to deal in the Software without restriction, including without limitation //
16 // the rights to use, copy, modify, merge, publish, distribute, sublicense, //
17 // and/or sell copies of the Software, and to permit persons to whom the //
18 // Software is furnished to do so, subject to the following conditions: //
19 // //
20 // The above copyright notice and this permission notice shall be included //
21 // in all copies or substantial portions of the Software. //
22 // //
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS //
24 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, //
25 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE //
26 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, //
27 // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF //
28 // OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. //
29 // //
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31
32 #if (!defined(HEX_LU_PARDISO_H) && (defined(WITH_PARDISO) || defined(WITH_MKL)))
33 #define HEX_LU_PARDISO_H
34
35 // --------------------------------------------------------------------------------- //
36
37 #include "hex-csrmatrix.h"
38
39 #include "luft.h"
40
41 // --------------------------------------------------------------------------------- //
42
43 #define DPARM(x) dparm_[x-1]
44 #define IPARM(x) iparm_[x-1]
45
46 // --------------------------------------------------------------------------------- //
47
48 #ifdef WITH_MKL
49
50 // old interfaces still in Intel MKL
51
52 extern "C" void pardisoinit
53 (
54 void* pt, // internal data structure
55 const int* mtype, // matrix type
56 int* iparm // integer parameters
57 );
58
59 extern "C" void pardiso
60 (
61 void* pt, // internal data structure
62 const int* maxfct, // maximal number of factorizations
63 const int* mnum, // factorization index
64 const int* mtype, // matrix type
65 const int* phase, // solver phase
66 const int* n, // matrix rank
67 const void* a, // matrix non-zero elements
68 const int* ia, // matrix column pointers
69 const int* ja, // matrix row indices
70 int* perm, // permutation array
71 const int* nrhs, // number of right-hand sides
72 int* iparm, // integer parameters
73 const int* msglvl, // verbosity level
74 void* b, // right-hand sides
75 void* x, // solutions
76 int* error // status indicator
77 );
78
79 #else
80
81 // new interfaces (as of Pardiso 5.0.0)
82
83 extern "C" void pardisoinit
84 (
85 void* pt, // internal data structure
86 const int* mtype, // matrix type
87 const int* solver, // solver
88 int* iparm, // integer parameters
89 double* dparm, // real parameters
90 int* error // status indicator
91 );
92
93 extern "C" void pardiso
94 (
95 void* pt, // internal data structure
96 const int* maxfct, // maximal number of factorizations
97 const int* mnum, // factorization index
98 const int* mtype, // matrix type
99 const int* phase, // solver phase
100 const int* n, // matrix rank
101 const void* a, // matrix non-zero elements
102 const int* ia, // matrix column pointers
103 const int* ja, // matrix row indices
104 int* perm, // permutation array
105 const int* nrhs, // number of right-hand sides
106 int* iparm, // integer parameters
107 const int* msglvl, // verbosity level
108 void* b, // right-hand sides
109 void* x, // solutions
110 int* error, // status indicator
111 double* dparm // double parameters
112 );
113
114 #endif
115
116 // --------------------------------------------------------------------------------- //
117
123 class LUft_Pardiso : public LUft
124 {
125 public:
126
127 // run-time selection mechanism
128 factorizerRunTimeSelectionDefinitions(LUft_Pardiso, "pardiso")
129
130
131 LUft_Pardiso ();
132
134 virtual ~LUft_Pardiso();
135
136 // Disable bitwise copy
137 LUft_Pardiso const & operator= (LUft_Pardiso const &) = delete;
138
140 virtual void factorize (CsrMatrix<LU_int_t,Complex> const & matrix, LUftData data);
141
143 virtual bool valid () const { return size() != 0; }
144
146 virtual std::size_t size () const;
147
149 virtual void solve (const cArrayView b, cArrayView x, int eqs) const;
150
152 virtual void save (std::string name) const;
153
155 virtual void load (std::string name, bool throw_on_io_failure = true);
156
158 virtual void drop ();
159
160 private:
161
163 void pardisoerror (int error) const;
164
166 NumberArray<int> P_;
167 NumberArray<int> I_;
168 NumberArray<std::complex<double>> X_;
169
171 NumberArray<int> perm_;
172
174 void* pt_[64];
175 int iparm_[64];
176 double dparm_[64];
177 };
178
179 // --------------------------------------------------------------------------------- //
180
181 #endif // WITH_MKL or WITH_PARDISO
LUft::solve
virtual void solve(const cArrayView b, cArrayView x, int eqs) const =0
Solve equations.
luft.h
LUft::size
virtual std::size_t size() const
Size of the numerical data.
Definition: luft.h:117
LUft
LU factorization object.
Definition: luft.h:74
CsrMatrix
Definition: luft.h:42
factorizerRunTimeSelectionDefinitions
#define factorizerRunTimeSelectionDefinitions(TYPE, NAME)
Definition: luft.h:198
LUft::drop
virtual void drop()
Free memory.
Definition: luft.h:109
LUft::save
virtual void save() const
Definition: luft.h:181
LUft::load
virtual void load()
Definition: luft.h:187
LUftData
Definition: luft.h:46