Hex  2.2
Hydrogen-electron collision solver
luft.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 #ifndef HEX_LUFT_H
33 #define HEX_LUFT_H
34 
35 // --------------------------------------------------------------------------------- //
36 
37 #include "hex-arrays.h"
38 #include "hex-rts.h"
39 
40 // --------------------------------------------------------------------------------- //
41 
42 template <class IdxT, class DataT> class CsrMatrix;
43 
44 // --------------------------------------------------------------------------------- //
45 
46 typedef struct
47 {
50  int verbosity;
52  int groupsize;
53  const char * ooc_dir;
56 }
57 LUftData;
58 
59 // --------------------------------------------------------------------------------- //
60 
62 
63 // --------------------------------------------------------------------------------- //
64 
74 class LUft
75 {
76  public:
77 
78  //
79  // Run-time selection mechanism (object factory).
80  //
81 
83 
84  //
85  // Class member functions.
86  //
87 
88 
89  LUft () : filename_() {}
90 
92  virtual ~LUft () {}
93 
95  virtual void factorize (CsrMatrix<LU_int_t,Complex> const & matrix, LUftData data = defaultLUftData) = 0;
96 
102  virtual bool valid () const { return false; }
103 
109  virtual void drop () {}
110 
117  virtual std::size_t size () const { return 0; }
118 
124  virtual Real cond () const { return 0; }
125 
134  virtual void solve (const cArrayView b, cArrayView x, int eqs) const = 0;
135 
143  virtual cArray solve (const cArrayView b, int eqs = 1) const
144  {
145  // reserve space for the solution
146  cArray x (b.size());
147 
148  // solve
149  this->solve(b, x, eqs);
150 
151  // return the result
152  return x;
153  }
154 
162  virtual void link (std::string name) { filename_ = name; }
163 
167  virtual void unlink () { filename_.clear(); }
168 
172  virtual std::string filename () const { return filename_; }
173 
180  virtual void save (std::string name) const = 0;
181  virtual void save () const { this->save(filename_); }
182 
186  virtual void load (std::string name, bool throw_on_io_failure = true) = 0;
187  virtual void load () { this->load(filename_, true); }
188  virtual void silent_load () { this->load(filename_, false); }
189 
190  private:
191 
193  std::string filename_;
194 };
195 
196 // --------------------------------------------------------------------------------- //
197 
198 #define factorizerRunTimeSelectionDefinitions(TYPE,NAME) \
199  derivedClassRunTimeSelectionDefinitions(LUft, (), TYPE, (), NAME)
200 
201 // --------------------------------------------------------------------------------- //
202 
203 #endif // HEX_LUFT_H
virtual void factorize(CsrMatrix< LU_int_t, Complex > const &matrix, LUftData data=defaultLUftData)=0
Factorize.
baseClassRunTimeSelectionDefinitions(LUft,()) LUft()
Default constructor.
Definition: luft.h:82
virtual void solve(const cArrayView b, cArrayView x, int eqs) const =0
Solve equations.
int groupsize
Definition: luft.h:52
virtual std::string filename() const
Name of the linked disk file.
Definition: luft.h:172
int fortran_comm
Definition: luft.h:51
virtual bool valid() const
Validity indicator.
Definition: luft.h:102
virtual std::size_t size() const
Size of the numerical data.
Definition: luft.h:117
LU factorization object.
Definition: luft.h:74
Definition: luft.h:42
virtual ~LUft()
Destructor.
Definition: luft.h:92
virtual void drop()
Free memory.
Definition: luft.h:109
void * superlu_dist_grid
Definition: luft.h:54
bool out_of_core
Definition: luft.h:49
virtual cArray solve(const cArrayView b, int eqs=1) const
Solve equations.
Definition: luft.h:143
virtual void unlink()
Unlink disk file.
Definition: luft.h:167
LUftData defaultLUftData
Definition: luft.cpp:36
bool centralized_matrix
Definition: luft.h:55
virtual void silent_load()
Definition: luft.h:188
Real drop_tolerance
Definition: luft.h:48
virtual void save() const
Definition: luft.h:181
const char * ooc_dir
Definition: luft.h:53
virtual void load()
Definition: luft.h:187
Definition: luft.h:46
virtual void link(std::string name)
Link to a disk file.
Definition: luft.h:162
int verbosity
Definition: luft.h:50
virtual Real cond() const
Estimation of the condition number.
Definition: luft.h:124