Hex: src/preconditioners/ILUPreconditioner.h Source File

| 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
69 preconditionerRunTimeSelectionDefinitions(ILUCGPreconditioner, "ILU")
70
71 // default constructor needed by the RTS mechanism
72 ILUCGPreconditioner () {}
73
74 // constructor
75 ILUCGPreconditioner
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
88 ~ILUCGPreconditioner ();
89
90 // preconditioner description
91 virtual std::string description () const;
92
93 // reuse parent definitions
94 using CGPreconditioner::multiply;
95 using CGPreconditioner::rhs;
96 using CGPreconditioner::precondition;
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
ILUCGPreconditioner::reset_lu
void reset_lu()
Definition: ILUPreconditioner.cpp:93
ILUCGPreconditioner::CG_prec
virtual void CG_prec(int iblock, const cArrayView r, cArrayView z) const
Definition: ILUPreconditioner.cpp:318
ILUCGPreconditioner
ILU-preconditioned CG-based preconditioner.
Definition: ILUPreconditioner.h:64
ILUCGPreconditioner::finish
virtual void finish()
Clean up memory etc.
Definition: ILUPreconditioner.cpp:357
Bspline
B-spline environment.
Definition: bspline.h:57
luft.h
CGPreconditioner::precondition
virtual void precondition(BlockArray< Complex > const &r, BlockArray< Complex > &z) const
Precondition the equation.
Definition: CGPreconditioner.cpp:142
ILUCGPreconditioner::description
virtual std::string description() const
Description of the preconditioner.
Definition: ILUPreconditioner.cpp:51
AngularBasis
Angular basis.
Definition: ang.h:44
ILUCGPreconditioner::lu_
std::vector< std::shared_ptr< LUft > > lu_
Definition: ILUPreconditioner.h:114
CGPreconditioner.h
CommandLine
Command line parameters.
Definition: io.h:57
ILUCGPreconditioner::ILUCGPreconditioner
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
NoPreconditioner::rhs
virtual void rhs(BlockArray< Complex > &chi, int ienergy, int instate) const
Calculate the right-hand side.
Definition: NoPreconditioner.cpp:821
CGPreconditioner
CG iteration-based preconditioner.
Definition: CGPreconditioner.h:48
InputFile
Input parameters.
Definition: io.h:321
ILUCGPreconditioner::~ILUCGPreconditioner
~ILUCGPreconditioner()
Definition: ILUPreconditioner.cpp:81
ILUCGPreconditioner::data_
std::vector< LUftData > data_
Definition: ILUPreconditioner.h:111
ILUCGPreconditioner::CG_exit
virtual void CG_exit(int iblock) const
Definition: ILUPreconditioner.cpp:337
Parallel
MPI info.
Definition: parallel.h:50
ILUCGPreconditioner::update
virtual void update(Real E)
Update the preconditioner for the next energy.
Definition: ILUPreconditioner.cpp:135
ILUCGPreconditioner::setup
virtual void setup()
Initialize the preconditioner.
Definition: ILUPreconditioner.cpp:126
NoPreconditioner::multiply
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
ILUCGPreconditioner::CG_init
virtual void CG_init(int iblock) const
Definition: ILUPreconditioner.cpp:148
ILUCGPreconditioner::preconditionerRunTimeSelectionDefinitions
preconditionerRunTimeSelectionDefinitions(ILUCGPreconditioner, "ILU") ILUCGPreconditioner()
Definition: ILUPreconditioner.h:69