Hex  2.2
Hydrogen-electron collision solver
preconditioners.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_ECS_PRECONDITIONERS
33 #define HEX_ECS_PRECONDITIONERS
34 
35 // --------------------------------------------------------------------------------- //
36 
37 #include <tuple>
38 
39 // --------------------------------------------------------------------------------- //
40 
41 #include "hex-arrays.h"
42 #include "hex-matrix.h"
43 #include "hex-rts.h"
44 
45 // --------------------------------------------------------------------------------- //
46 
47 #include "ang.h"
48 #include "radial.h"
49 #include "parallel.h"
50 
51 // --------------------------------------------------------------------------------- //
52 
63 {
64  public:
65 
66  //
67  // Run-time selection mechanism (object factory).
68  //
69 
71  (
73  (
74  CommandLine const & cmd,
75  InputFile const & inp,
76  Parallel const & par,
77  AngularBasis const & ang,
78  Bspline const & bspline_inner,
79  Bspline const & bspline_full,
80  Bspline const & bspline_panel_x,
81  Bspline const & bspline_panel_y
82  )
83  )
84 
85  //
86  // Class member functions.
87  //
88 
92  PreconditionerBase () : verbose_(true) {}
93 
99  virtual ~PreconditionerBase () {}
100 
106  virtual std::string description () const { return ""; }
107 
115  virtual void setup () {}
116 
123  virtual void update (Real E) {}
124 
137  virtual std::pair<int,int> bstates (Real E, int l1, int l2) const
138  {
139  return std::make_pair(0,0);
140  }
141 
149  virtual void finish () {}
150 
154  virtual void rhs (BlockArray<Complex> & chi, int ie, int instate) const {}
155 
162  virtual void multiply
163  (
164  BlockArray<Complex> const & p,
165  BlockArray<Complex> & q,
166  MatrixSelection::Selection tri = MatrixSelection::BlockBoth | MatrixSelection::Both
167  ) const {}
168 
179  virtual void precondition (BlockArray<Complex> const & r, BlockArray<Complex> & z) const {}
180 
186  virtual void verbose (bool b) { verbose_ = b; }
187 
188  protected:
189 
190  bool verbose_;
191 };
192 
193 // --------------------------------------------------------------------------------- //
194 
195 #define preconditionerRunTimeSelectionDefinitions(TYPE,NAME) \
196  derivedClassRunTimeSelectionDefinitions \
197  ( \
198  PreconditionerBase, \
199  ( \
200  CommandLine const & cmd, \
201  InputFile const & inp, \
202  Parallel const & par, \
203  AngularBasis const & ang, \
204  Bspline const & bspline_inner, \
205  Bspline const & bspline_full, \
206  Bspline const & bspline_panel_x, \
207  Bspline const & bspline_panel_y \
208  ), \
209  TYPE, \
210  ( \
211  cmd, \
212  inp, \
213  par, \
214  ang, \
215  bspline_inner, \
216  bspline_full, \
217  bspline_panel_x, \
218  bspline_panel_y \
219  ), \
220  NAME \
221  )
222 
223 // --------------------------------------------------------------------------------- //
224 
225 #endif // HEX_ECS_PRECONDITIONERS
virtual void finish()
Clean up memory etc.
Definition: preconditioners.h:149
bool verbose_
Definition: preconditioners.h:190
virtual void multiply(BlockArray< Complex > const &p, BlockArray< Complex > &q, MatrixSelection::Selection tri=MatrixSelection::BlockBoth|MatrixSelection::Both) const
Multiply by the matrix equation.
Definition: preconditioners.h:163
virtual std::pair< int, int > bstates(Real E, int l1, int l2) const
Get the number of allowed bound states.
Definition: preconditioners.h:137
B-spline environment.
Definition: bspline.h:57
virtual void rhs(BlockArray< Complex > &chi, int ie, int instate) const
Calculate the right-hand side.
Definition: preconditioners.h:154
baseClassRunTimeSelectionDefinitions(PreconditionerBase,(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)) PreconditionerBase()
Dummy default constructor needed by the run-time selection.
Definition: preconditioners.h:71
Angular basis.
Definition: ang.h:44
virtual void precondition(BlockArray< Complex > const &r, BlockArray< Complex > &z) const
Precondition the equation.
Definition: preconditioners.h:179
virtual std::string description() const
Description of the preconditioner.
Definition: preconditioners.h:106
Command line parameters.
Definition: io.h:57
virtual ~PreconditionerBase()
Virtual destructor.
Definition: preconditioners.h:99
Input parameters.
Definition: io.h:321
virtual void verbose(bool b)
Set verbosity level.
Definition: preconditioners.h:186
MPI info.
Definition: parallel.h:50
virtual void update(Real E)
Update the preconditioner for the next energy.
Definition: preconditioners.h:123
virtual void setup()
Initialize the preconditioner.
Definition: preconditioners.h:115
Preconditioner template.
Definition: preconditioners.h:62