Hex  2.2
Hydrogen-electron collision solver
lu-mumps.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_MUMPS_H) && defined(WITH_MUMPS) )
33 #define HEX_LU_MUMPS_H
34 
35 // --------------------------------------------------------------------------------- //
36 
37 #include "hex-csrmatrix.h"
38 #include "luft.h"
39 
40 // --------------------------------------------------------------------------------- //
41 
42 #define ICNTL(x) icntl[(x)-1]
43 #define MUMPS_NOACTION 0
44 #define MUMPS_INITIALIZE (-1)
45 #define MUMPS_FINISH (-2)
46 #define MUMPS_ANALYZE 1
47 #define MUMPS_FACTORIZE 2
48 #define MUMPS_SOLVE 3
49 
50 // --------------------------------------------------------------------------------- //
51 
52 #ifdef SINGLE
53  #include <cmumps_c.h>
54  #define MUMPS_STRUC_C CMUMPS_STRUC_C
55  #define MUMPS_C cmumps_c
56  #define MUMPS_COMPLEX mumps_complex
57 #else
58  #include <zmumps_c.h>
59  #define MUMPS_STRUC_C ZMUMPS_STRUC_C
60  #define MUMPS_C zmumps_c
61  #define MUMPS_COMPLEX mumps_double_complex
62 #endif
63 
64 // --------------------------------------------------------------------------------- //
65 
76 class LUft_MUMPS : public LUft
77 {
78  public:
79 
80  typedef struct
81  {
82  MUMPS_INT out_of_core;
83  MUMPS_INT verbosity_level;
84  MUMPS_INT comm;
85  }
86  Data;
87 
88  // run-time selection mechanism
90 
91 
92  LUft_MUMPS ();
93 
95  virtual ~LUft_MUMPS ();
96 
97  // Disable bitwise copy
98  LUft_MUMPS const & operator= (LUft_MUMPS const &) = delete;
99 
101  virtual void factorize (CsrMatrix<LU_int_t,Complex> const & matrix, LUftData data);
102 
104  virtual bool valid () const
105  {
106  return mmin(I.size(), J.size(), A.size()) > 0;
107  }
108 
110  virtual std::size_t size () const;
111 
113  virtual Real cond () const
114  {
115  #define RINFO(x) rinfo[x-1]
116  return settings.RINFO(11);
117  }
118 
120  virtual void solve (const cArrayView b, cArrayView x, int eqs) const;
121 
123  virtual void save (std::string name) const
124  {
125  I.hdfsave("I-" + name);
126  J.hdfsave("J-" + name);
127  A.hdfsave("A-" + name);
128  }
129 
131  virtual void load (std::string name, bool throw_on_io_failure = true)
132  {
133  if (not I.hdfload("I-" + name) or
134  not J.hdfload("J-" + name) or
135  not A.hdfload("A-" + name))
136  {
137  if (throw_on_io_failure)
138  HexException("Failed to load MUMPS IJV matrices.");
139  }
140  }
141 
143  virtual void drop ()
144  {
145  I.drop();
146  J.drop();
147  A.drop();
148  }
149 
150  private:
151 
152  // Internal data of the library.
153  mutable MUMPS_STRUC_C settings;
154 
155  // rank
156  MUMPS_INT n_;
157 
158  // data arrays
159  NumberArray<MUMPS_INT> I, J;
160  NumberArray<Complex> A;
161 };
162 
163 #endif // HEX_LU_MUMPS_H, WITH_MUMPS
virtual void save(std::string name) const
Save large data to disk.
Definition: lu-mumps.h:123
MUMPS_INT out_of_core
Definition: lu-mumps.h:82
virtual void solve(const cArrayView b, cArrayView x, int eqs) const
Solve equations.
Definition: lu-mumps.cpp:144
factorizerRunTimeSelectionDefinitions(LUft_MUMPS, "mumps") LUft_MUMPS()
Default constructor.
LU factorization object.
Definition: luft.h:74
Definition: luft.h:42
LU factorization object - MUMPS specialization.
Definition: lu-mumps.h:76
virtual Real cond() const
Condition number.
Definition: lu-mumps.h:113
MUMPS_INT comm
Definition: lu-mumps.h:84
MUMPS_INT verbosity_level
Definition: lu-mumps.h:83
virtual void drop()
Release memory.
Definition: lu-mumps.h:143
virtual std::size_t size() const
Return LU byte size.
Definition: lu-mumps.cpp:57
#define MUMPS_STRUC_C
Definition: lu-mumps.h:59
virtual void load(std::string name, bool throw_on_io_failure=true)
Load large data from disk.
Definition: lu-mumps.h:131
Definition: lu-mumps.h:80
virtual void factorize(CsrMatrix< LU_int_t, Complex > const &matrix, LUftData data)
Factorize.
Definition: lu-mumps.cpp:66
Definition: luft.h:46
virtual bool valid() const
Validity indicator.
Definition: lu-mumps.h:104