Hex: src/preconditioners/DOMPreconditioner.h Source File

| Hex 2.2 Hydrogen-electron collision solver

DOMPreconditioner.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_DOM_PRECONDITIONER_H
33 #define HEX_DOM_PRECONDITIONER_H
34
35 // --------------------------------------------------------------------------------- //
36
37 #include <array>
38 #include <vector>
39
40 // --------------------------------------------------------------------------------- //
41
42 #include "hex-csrmatrix.h"
43 #include "hex-densematrix.h"
44
45 // --------------------------------------------------------------------------------- //
46
47 #include "NoPreconditioner.h"
48
49 // --------------------------------------------------------------------------------- //
50
70 class DOMPreconditioner : public NoPreconditioner
71 {
72 public:
73
74 // run-time selection mechanism
75 preconditionerRunTimeSelectionDefinitions(DOMPreconditioner, "DOM")
76
77 // default constructor needed by the RTS mechanism
78 DOMPreconditioner () {}
79
80 // constructor
81 DOMPreconditioner
82 (
83 CommandLine const & cmd,
84 InputFile const & inp,
85 Parallel const & par,
86 AngularBasis const & ang,
87 Bspline const & bspline_inner,
88 Bspline const & bspline_full,
89 Bspline const & bspline_panel_x,
90 Bspline const & bspline_panel_y
91 );
92
93 // description of the preconditioner
94 virtual std::string description () const;
95
96 // reuse parent definitions
97 using NoPreconditioner::rhs;
98 using NoPreconditioner::multiply;
99
100 // declare own definitions
101 virtual void setup ();
102 virtual void update (Real E);
103 virtual void precondition (BlockArray<Complex> const & r, BlockArray<Complex> & z) const;
104 virtual void finish ();
105
106 protected:
107
108 // neighbour panels
109 enum Neighbours
110 {
111 Left = 0,
112 Right = 1,
113 Down = 2,
114 Up = 3,
115 nNbrs = 4
116 };
117
118 // get reverse direction for a given direction
119 int rev (int dir) const
120 {
121 switch (dir)
122 {
123 case Left : return Right;
124 case Right : return Left;
125 case Down : return Up;
126 case Up : return Down;
127 };
128
129 return nNbrs;
130 }
131
132 // solutions on the sub-domains
133 class PanelSolution
134 {
135 public:
136
137 PanelSolution
138 (
139 int ixpanel, int iypanel,
140 int xpanels, int ypanels,
141 int order,
142 Real theta,
143 Bspline const & xspline, Bspline const & yspline,
144 rArray cxspline1_inner, rArray rxspline_inner, rArray cxspline2_inner,
145 rArray cyspline1_inner, rArray ryspline_inner, rArray cyspline2_inner,
146 rArray cxspline1_full, rArray rxspline_full, rArray cxspline2_full,
147 rArray cyspline1_full, rArray ryspline_full, rArray cyspline2_full,
148 int Nang
149 );
150
151 Bspline xspline_inner; // inner x-axis B-spline basis
152 Bspline yspline_inner; // inner y-axis B-spline basis
153
154 Bspline xspline_full; // full x-axis B-spline basis
155 Bspline yspline_full; // full y-axis B-spline basis
156
157 cBlockArray r; // original source
158 cBlockArray z; // solution
159
160 int ixpanel; // which panel (x-dir)
161 int iypanel; // which panel (y-dir)
162
163 int xoffset; // x-offset of the real basis of panel
164 int yoffset; // y-offset of the real basis of panel
165
166 int minpxspline, maxpxspline; // B-splines that have a counterpart in the global basis (x-dir)
167 int minpyspline, maxpyspline; // B-splines that have a counterpart in the global basis (y-dir)
168 };
169
170 // find solution on a sub-domain
171 void solvePanel
172 (
173 int cycle, int cycles,
174 std::vector<PanelSolution> & p,
175 int i, int j
176 ) const;
177
178 // add neighbour field interfaces
179 void correctSource
180 (
181 cBlockArray & chi,
182 std::vector<PanelSolution> const & panels,
183 int ipanel, int jpanel
184 ) const;
185
186 // evaluate matrix element
187 Complex couplingMatrixElement
188 (
189 int ill, int illp,
190 int i, int j, int k, int l
191 ) const;
192
193 // get knot sub-sequences
194 void knotSubsequence
195 (
196 int ipanel,
197 int npanels,
198 Bspline const & bspline,
199 rArray & rknots,
200 rArray & cknots1,
201 rArray & cknots2
202 ) const;
203
204 // interpolate residual to sub-domains
205 void splitResidual (cBlockArray const & r, std::vector<PanelSolution> & p) const;
206
207 // interpolate solution from sub-domains
208 void collectSolution (cBlockArray & z, std::vector<PanelSolution> & p) const;
209
210 // gap of real knots between the panel seam and the complex absorption layer
211 int gap_;
212 };
213
214 // --------------------------------------------------------------------------------- //
215
216 #endif
DOMPreconditioner
Domain decomposition preconditioner.
Definition: DOMPreconditioner.h:70
DOMPreconditioner::description
virtual std::string description() const
Description of the preconditioner.
Definition: DOMPreconditioner.cpp:71
DOMPreconditioner::PanelSolution::iypanel
int iypanel
Definition: DOMPreconditioner.h:161
DOMPreconditioner::nNbrs
Definition: DOMPreconditioner.h:115
DOMPreconditioner::Down
Definition: DOMPreconditioner.h:113
DOMPreconditioner::PanelSolution::xoffset
int xoffset
Definition: DOMPreconditioner.h:163
DOMPreconditioner::PanelSolution::PanelSolution
PanelSolution(int ixpanel, int iypanel, int xpanels, int ypanels, int order, Real theta, Bspline const &xspline, Bspline const &yspline, rArray cxspline1_inner, rArray rxspline_inner, rArray cxspline2_inner, rArray cyspline1_inner, rArray ryspline_inner, rArray cyspline2_inner, rArray cxspline1_full, rArray rxspline_full, rArray cxspline2_full, rArray cyspline1_full, rArray ryspline_full, rArray cyspline2_full, int Nang)
Definition: DOMPreconditioner.cpp:722
DOMPreconditioner::PanelSolution::minpxspline
int minpxspline
Definition: DOMPreconditioner.h:166
DOMPreconditioner::PanelSolution::r
cBlockArray r
Definition: DOMPreconditioner.h:157
DOMPreconditioner::PanelSolution::ixpanel
int ixpanel
Definition: DOMPreconditioner.h:160
DOMPreconditioner::rev
int rev(int dir) const
Definition: DOMPreconditioner.h:119
DOMPreconditioner::PanelSolution::maxpxspline
int maxpxspline
Definition: DOMPreconditioner.h:166
NoPreconditioner
Solution driver without actual preconditioner.
Definition: NoPreconditioner.h:55
Bspline
B-spline environment.
Definition: bspline.h:57
DOMPreconditioner::PanelSolution::yoffset
int yoffset
Definition: DOMPreconditioner.h:164
AngularBasis
Angular basis.
Definition: ang.h:44
DOMPreconditioner::PanelSolution::minpyspline
int minpyspline
Definition: DOMPreconditioner.h:167
DOMPreconditioner::solvePanel
void solvePanel(int cycle, int cycles, std::vector< PanelSolution > &p, int i, int j) const
Definition: DOMPreconditioner.cpp:202
DOMPreconditioner::precondition
virtual void precondition(BlockArray< Complex > const &r, BlockArray< Complex > &z) const
Precondition the equation.
Definition: DOMPreconditioner.cpp:86
DOMPreconditioner::PanelSolution::maxpyspline
int maxpyspline
Definition: DOMPreconditioner.h:167
DOMPreconditioner::couplingMatrixElement
Complex couplingMatrixElement(int ill, int illp, int i, int j, int k, int l) const
Definition: DOMPreconditioner.cpp:547
DOMPreconditioner::gap_
int gap_
Definition: DOMPreconditioner.h:211
DOMPreconditioner::Up
Definition: DOMPreconditioner.h:114
CommandLine
Command line parameters.
Definition: io.h:57
DOMPreconditioner::update
virtual void update(Real E)
Update the preconditioner for the next energy.
Definition: DOMPreconditioner.cpp:81
DOMPreconditioner::knotSubsequence
void knotSubsequence(int ipanel, int npanels, Bspline const &bspline, rArray &rknots, rArray &cknots1, rArray &cknots2) const
Definition: DOMPreconditioner.cpp:585
NoPreconditioner::rhs
virtual void rhs(BlockArray< Complex > &chi, int ienergy, int instate) const
Calculate the right-hand side.
Definition: NoPreconditioner.cpp:821
DOMPreconditioner::finish
virtual void finish()
Clean up memory etc.
Definition: DOMPreconditioner.cpp:197
DOMPreconditioner::Left
Definition: DOMPreconditioner.h:111
InputFile
Input parameters.
Definition: io.h:321
Parallel
MPI info.
Definition: parallel.h:50
DOMPreconditioner::Neighbours
Neighbours
Definition: DOMPreconditioner.h:109
DOMPreconditioner::DOMPreconditioner
DOMPreconditioner(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: DOMPreconditioner.cpp:51
DOMPreconditioner::PanelSolution
Definition: DOMPreconditioner.h:133
DOMPreconditioner::PanelSolution::yspline_full
Bspline yspline_full
Definition: DOMPreconditioner.h:155
DOMPreconditioner::splitResidual
void splitResidual(cBlockArray const &r, std::vector< PanelSolution > &p) const
Definition: DOMPreconditioner.cpp:638
DOMPreconditioner::PanelSolution::yspline_inner
Bspline yspline_inner
Definition: DOMPreconditioner.h:152
DOMPreconditioner::PanelSolution::xspline_full
Bspline xspline_full
Definition: DOMPreconditioner.h:154
DOMPreconditioner::preconditionerRunTimeSelectionDefinitions
preconditionerRunTimeSelectionDefinitions(DOMPreconditioner, "DOM") DOMPreconditioner()
Definition: DOMPreconditioner.h:75
DOMPreconditioner::collectSolution
void collectSolution(cBlockArray &z, std::vector< PanelSolution > &p) const
Definition: DOMPreconditioner.cpp:672
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
DOMPreconditioner::correctSource
void correctSource(cBlockArray &chi, std::vector< PanelSolution > const &panels, int ipanel, int jpanel) const
Definition: DOMPreconditioner.cpp:456
DOMPreconditioner::PanelSolution::z
cBlockArray z
Definition: DOMPreconditioner.h:158
DOMPreconditioner::PanelSolution::xspline_inner
Bspline xspline_inner
Definition: DOMPreconditioner.h:151
DOMPreconditioner::setup
virtual void setup()
Initialize the preconditioner.
Definition: DOMPreconditioner.cpp:76
NoPreconditioner.h
DOMPreconditioner::Right
Definition: DOMPreconditioner.h:112