Hex  2.2
Hydrogen-electron collision solver
ILUPreconditioner.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_ILUPRECONDITIONER_H
33 #define HEX_ILUPRECONDITIONER_H
34 
35 // --------------------------------------------------------------------------------- //
36 
37 #include "luft.h"
38 
39 // --------------------------------------------------------------------------------- //
40 
41 #include "CGPreconditioner.h"
42 
43 // --------------------------------------------------------------------------------- //
44 
45 #ifdef _OPENMP
46  #include <omp.h>
47 #endif
48 
49 // --------------------------------------------------------------------------------- //
50 
51 #ifdef WITH_SUPERLU_DIST
52  #include <superlu_zdefs.h>
53 #endif
54 
55 // --------------------------------------------------------------------------------- //
56 
64 class ILUCGPreconditioner : public virtual CGPreconditioner
65 {
66  public:
67 
68  // run-time selection mechanism
70 
71  // default constructor needed by the RTS mechanism
73 
74  // constructor
76  (
77  CommandLine const & cmd,
78  InputFile const & inp,
79  Parallel const & par,
80  AngularBasis const & ang,
81  Bspline const & bspline_x_inner,
82  Bspline const & bspline_x_full,
83  Bspline const & bspline_y_inner,
84  Bspline const & bspline_y_full
85  );
86 
87  // destructor
89 
90  // preconditioner description
91  virtual std::string description () const;
92 
93  // reuse parent definitions
97 
98  // declare own definitions
99  virtual void setup ();
100  virtual void update (Real E);
101  virtual void finish ();
102 
103  // inner CG callback (needed by parent)
104  virtual void CG_init (int iblock) const;
105  virtual void CG_prec (int iblock, const cArrayView r, cArrayView z) const;
106  virtual void CG_exit (int iblock) const;
107 
108  protected:
109 
110  // LU data
111  mutable std::vector<LUftData> data_;
112 
113  // LU decompositions of the diagonal blocks
114  mutable std::vector<std::shared_ptr<LUft>> lu_;
115 
116  // prepare data structures for LU factorizations
117  void reset_lu ();
118 
119 #ifdef _OPENMP
120  // factorization lock
121  mutable omp_lock_t lu_lock_;
122 #endif
123 
124 #ifdef WITH_SUPERLU_DIST
125  // process grid
126  gridinfo_t grid_;
127 #endif
128 };
129 
130 // --------------------------------------------------------------------------------- //
131 
132 #endif
void reset_lu()
Definition: ILUPreconditioner.cpp:93
virtual void CG_prec(int iblock, const cArrayView r, cArrayView z) const
Definition: ILUPreconditioner.cpp:318
ILU-preconditioned CG-based preconditioner.
Definition: ILUPreconditioner.h:64
virtual void finish()
Clean up memory etc.
Definition: ILUPreconditioner.cpp:357
B-spline environment.
Definition: bspline.h:57
virtual void precondition(BlockArray< Complex > const &r, BlockArray< Complex > &z) const
Precondition the equation.
Definition: CGPreconditioner.cpp:142
virtual std::string description() const
Description of the preconditioner.
Definition: ILUPreconditioner.cpp:51
Angular basis.
Definition: ang.h:44
std::vector< std::shared_ptr< LUft > > lu_
Definition: ILUPreconditioner.h:114
Command line parameters.
Definition: io.h:57
ILUCGPreconditioner(CommandLine const &cmd, InputFile const &inp, Parallel const &par, AngularBasis const &ang, Bspline const &bspline_x_inner, Bspline const &bspline_x_full, Bspline const &bspline_y_inner, Bspline const &bspline_y_full)
Definition: ILUPreconditioner.cpp:58
virtual void rhs(BlockArray< Complex > &chi, int ienergy, int instate) const
Calculate the right-hand side.
Definition: NoPreconditioner.cpp:821
CG iteration-based preconditioner.
Definition: CGPreconditioner.h:48
Input parameters.
Definition: io.h:321
~ILUCGPreconditioner()
Definition: ILUPreconditioner.cpp:81
std::vector< LUftData > data_
Definition: ILUPreconditioner.h:111
virtual void CG_exit(int iblock) const
Definition: ILUPreconditioner.cpp:337
MPI info.
Definition: parallel.h:50
virtual void update(Real E)
Update the preconditioner for the next energy.
Definition: ILUPreconditioner.cpp:135
virtual void setup()
Initialize the preconditioner.
Definition: ILUPreconditioner.cpp:126
virtual void multiply(BlockArray< Complex > const &p, BlockArray< Complex > &q, MatrixSelection::Selection tri=MatrixSelection::Both) const
Multiply by the matrix equation.
Definition: NoPreconditioner.cpp:1233
virtual void CG_init(int iblock) const
Definition: ILUPreconditioner.cpp:148
preconditionerRunTimeSelectionDefinitions(ILUCGPreconditioner, "ILU") ILUCGPreconditioner()
Definition: ILUPreconditioner.h:69