Hex: src/preconditioners/HybPreconditioner.h Source File

| Hex 2.2 Hydrogen-electron collision solver

HybPreconditioner.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_HYBPRECONDITIONER_H
33 #define HEX_HYBPRECONDITIONER_H
34
35 // --------------------------------------------------------------------------------- //
36
37 #include <set>
38 #include <string>
39 #include <vector>
40
41 // --------------------------------------------------------------------------------- //
42
43 #include "hex-arrays.h"
44 #include "hex-matrix.h"
45
46 // --------------------------------------------------------------------------------- //
47
48 #include "ILUPreconditioner.h"
49 #include "KPAPreconditioner.h"
50
51 // --------------------------------------------------------------------------------- //
52
60 class HybCGPreconditioner : public ILUCGPreconditioner, public KPACGPreconditioner
61 {
62 public:
63
64 // run-time selection mechanism
65 preconditionerRunTimeSelectionDefinitions(HybCGPreconditioner, "HYB")
66
67 // default constructor needed by the RTS mechanism
68 HybCGPreconditioner () {}
69
70 // constructor
71 HybCGPreconditioner
72 (
73 CommandLine const & cmd,
74 InputFile const & inp,
75 Parallel const & par,
76 AngularBasis const & ang,
77 Bspline const & bspline_x_inner,
78 Bspline const & bspline_x_full,
79 Bspline const & bspline_y_inner,
80 Bspline const & bspline_y_full
81 ) : CGPreconditioner
82 (
83 cmd, inp, par, ang,
84 bspline_x_inner, bspline_x_full,
85 bspline_y_inner, bspline_y_full
86 ),
87 ILUCGPreconditioner
88 (
89 cmd, inp, par, ang,
90 bspline_x_inner, bspline_x_full,
91 bspline_y_inner, bspline_y_full
92 ),
93 KPACGPreconditioner
94 (
95 cmd, inp, par, ang,
96 bspline_x_inner, bspline_x_full,
97 bspline_y_inner, bspline_y_full
98 )
99 {
100 // nothing more to do
101 }
102
103 // preconditioner description
104 virtual std::string description () const;
105
106 // reuse parent definitions
107 using CGPreconditioner::multiply;
108 using CGPreconditioner::rhs;
109 using CGPreconditioner::precondition;
110
111 // declare own definitions
112 virtual void setup ();
113 virtual void update (Real E);
114 virtual void finish ();
115
116 // inner CG callback (needed by parent)
117 virtual void CG_init (int iblock) const;
118 virtual void CG_prec (int iblock, const cArrayView r, cArrayView z) const;
119 virtual void CG_mmul (int iblock, const cArrayView r, cArrayView z) const;
120 virtual void CG_exit (int iblock) const;
121
122 // decide whether to use the ILU preconditioner
123 bool ilu_needed (int iblock) const;
124 };
125
126 // --------------------------------------------------------------------------------- //
127
128 #endif
HybCGPreconditioner::ilu_needed
bool ilu_needed(int iblock) const
Definition: HybPreconditioner.cpp:45
ILUCGPreconditioner
ILU-preconditioned CG-based preconditioner.
Definition: ILUPreconditioner.h:64
Bspline
B-spline environment.
Definition: bspline.h:57
HybCGPreconditioner::CG_prec
virtual void CG_prec(int iblock, const cArrayView r, cArrayView z) const
Definition: HybPreconditioner.cpp:83
CGPreconditioner::precondition
virtual void precondition(BlockArray< Complex > const &r, BlockArray< Complex > &z) const
Precondition the equation.
Definition: CGPreconditioner.cpp:142
AngularBasis
Angular basis.
Definition: ang.h:44
HybCGPreconditioner::update
virtual void update(Real E)
Update the preconditioner for the next energy.
Definition: HybPreconditioner.cpp:62
HybCGPreconditioner
Hybrid preconditioner.
Definition: HybPreconditioner.h:60
CommandLine
Command line parameters.
Definition: io.h:57
HybCGPreconditioner::CG_exit
virtual void CG_exit(int iblock) const
Definition: HybPreconditioner.cpp:91
HybCGPreconditioner::preconditionerRunTimeSelectionDefinitions
preconditionerRunTimeSelectionDefinitions(HybCGPreconditioner, "HYB") HybCGPreconditioner()
Definition: HybPreconditioner.h:65
KPACGPreconditioner::KPACGPreconditioner
KPACGPreconditioner(CommandLine const &cmd, InputFile const &inp, Parallel const &par, AngularBasis const &ang, Bspline const &bspline_inner, Bspline const &bspline_full, Bspline const &bspline_panel_x, Bspline const &bspline_panel_y)
Definition: KPAPreconditioner.h:78
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
InputFile
Input parameters.
Definition: io.h:321
Parallel
MPI info.
Definition: parallel.h:50
KPACGPreconditioner
KPA-preconditioned CG-preconditioner.
Definition: KPAPreconditioner.h:66
HybCGPreconditioner::setup
virtual void setup()
Initialize the preconditioner.
Definition: HybPreconditioner.cpp:56
HybCGPreconditioner::CG_mmul
virtual void CG_mmul(int iblock, const cArrayView r, cArrayView z) const
Definition: HybPreconditioner.cpp:75
HybCGPreconditioner::CG_init
virtual void CG_init(int iblock) const
Definition: HybPreconditioner.cpp:67
HybCGPreconditioner::HybCGPreconditioner
HybCGPreconditioner(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: HybPreconditioner.h:72
HybCGPreconditioner::description
virtual std::string description() const
Description of the preconditioner.
Definition: HybPreconditioner.cpp:40
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
HybCGPreconditioner::finish
virtual void finish()
Clean up memory etc.
Definition: HybPreconditioner.cpp:99
ILUPreconditioner.h
KPAPreconditioner.h
CGPreconditioner::CGPreconditioner
CGPreconditioner(CommandLine const &cmd, InputFile const &inp, Parallel const &par, AngularBasis const &ang, Bspline const &bspline_inner, Bspline const &bspline_full, Bspline const &bspline_panel_x, Bspline const &bspline_panel_y)
Definition: CGPreconditioner.h:60