Greens-code
A modular quantum transport code
interface.hpp
1 #ifndef INTERFACE_G_H
2 #define INTERFACE_G_H
3 
4 #include <list>
5 
6 #include "iterators.hpp"
7 #include "mkl_matrix.hpp"
8 
9 #include "rect_fwd.hpp"
10 #include <fstream>
11 #include <string>
12 
13 /**************************
14  *
15  * struct index_connector
16  *
17  * Describes how indizes match
18  *
19  */
20 
22 
23  typedef STD_TR1::shared_ptr<index_connector> ref;
24 
25  typedef std::vector<int>::const_iterator const_iterator;
26 
27  const_iterator begin(){ return indizes.begin();};
28  const_iterator end(){ return indizes.end();};
29 
30  int operator()(const int i) const { return shift + indizes[i];};
31  row operator()(const row i) const { return row(shift + indizes[i.get()]);};
32  column operator()(const column i) const { return column(shift + indizes[i.get()]);};
33 
34  size_t size(){ return indizes.size();};
35 
36  size_t max_index(){ return (max + shift);};
37 
38  void debug_print(std::string name="index_connector");
39 
40 private:
41  friend class Interface;
42 
43  index_connector(size_t n, size_t s = 0): indizes(n,0), shift(0), max(0) {};
44 
45  void add_shift(size_t t){ shift += t;};
46 
47  void connect(size_t ind, int j);
48 
49  std::vector<int> indizes;
50  size_t shift;
51  int max;
52 };
53 
54 
55 /*****************************
56  *
57  * class Interface_Matrix
58  *
59  * Matrix class for connecting to few columns of a large matrix
60  * Describes how two matrices of different sizes are to be connected
61  *
62  */
63 
64 class interface_Matrix: public Matrix{
65 public:
66 
68  const index_connector::ref& i1,
69  const index_connector::ref& i2);
70 
71  virtual ~interface_Matrix() throw() {};
72 
73 private:
74  Matrix* my_mat;
75 
76  index_connector::ref row_connect;
77  index_connector::ref column_connect;
78 
79  void insert(row r, column c, complex v);
80  void add(row r, column c, complex v);
81  complex get(row r, column c) const;
82 
83  size_t num_rows() const { return row_connect->size();};
84  size_t num_cols() const { return column_connect->size();};
85 };
86 
87 
105 
106 public:
107 
108  typedef STD_TR1::shared_ptr<Interface> ref;
109  typedef STD_TR1::shared_ptr<const Interface> const_ref;
110 
111  static void
112  reduce(const Matrix&,
113  const index_connector::ref,
114  const index_connector::ref,
115  mkl_Matrix&);
116 
117  static void
118  reduce(const Vector&,
119  const index_connector::ref,
120  Vector&);
121  static void
122  reduce(Vector&,
123  const index_connector::ref);
124 
125  static void
126  expand(const Vector&,
127  const index_connector::ref,
128  complex*);
129 
131  static index_connector::ref empty( size_t ny );
132 
133  virtual ~Interface() throw(){};
134 
135  index_connector::ref left() const;
136  index_connector::ref right() const;
137 
138  double y_shift() const { return yshift();};
139 
140  void create_full_Interface(Matrix& m) const;
141 
142  void create_Hi(Matrix& m) const { createHi(m);};
143  void create_Hit(Matrix& m) const { createHit(m);};
144 
145  void create_Hi_expand_left(Matrix& m) const;
146  void create_Hi_expand_right(Matrix& m) const;
147  void create_Hi_expand_both(Matrix& m) const;
148  void create_Hit_expand_left(Matrix& m) const;
149  void create_Hit_expand_right(Matrix& m) const;
150  void create_Hit_expand_both(Matrix& m) const;
151 
152  mkl_Matrix::ref create_Hi() const {
153  mkl_Matrix::ref p(new rectangular_Matrix(row(n_left()),column(n_right())));
154  createHi(*p); return p;
155  };
156  mkl_Matrix::ref create_Hi_expand_left() const {
157  mkl_Matrix::ref p(new rectangular_Matrix(row(n_right()),column(nleft_rect)));
158  create_Hi_expand_left(*p); return p;
159  };
160  mkl_Matrix::ref create_Hi_expand_right() const {
161  mkl_Matrix::ref p(new rectangular_Matrix(row(nright_rect), column(n_left())));
162  create_Hi_expand_right(*p); return p;
163  };
164  mkl_Matrix::ref create_Hi_expand_both() const {
165  mkl_Matrix::ref p(new rectangular_Matrix(row(nleft_rect),
166  column(nright_rect)));
167  create_Hi_expand_both(*p); return p;
168  };
169 
170  mkl_Matrix::ref create_Hit() const {
171  mkl_Matrix::ref p(new rectangular_Matrix(row(n_right()),column(n_left())));
172  createHit(*p); return p;
173  }
174  mkl_Matrix::ref create_Hit_expand_left() const {
175  mkl_Matrix::ref p(new rectangular_Matrix(row(nleft_rect),column(n_right())));
176  create_Hit_expand_left(*p); return p;
177  };
178  mkl_Matrix::ref create_Hit_expand_right() const {
179  mkl_Matrix::ref p(new rectangular_Matrix(row(n_left()), column(nright_rect)));
180  create_Hit_expand_right(*p); return p;
181  };
182  mkl_Matrix::ref create_Hit_expand_both() const {
183  mkl_Matrix::ref p(new rectangular_Matrix(row(nright_rect),
184  column(nleft_rect)));
185  create_Hit_expand_both(*p); return p;
186  };
187 
189  size_t n_left() const { return nleft();};
191  size_t n_right() const { return nright();};
192 
194  size_t n_left_rect() const { return nleft_rect;};
196  size_t n_right_rect() const { return nright_rect;};
197 
198 protected:
199 
200  Interface(){};
201 
202  static
203  void connect_index(index_connector& v, size_t i, int j)
204  { v.connect( i, j);};
205 
206  void set_n_left_right(size_t nl, size_t nr) { nleft_rect = nl; nright_rect = nr;};
207 
208 private:
209  const char* name() const { return "Abstract_Interface";};
210 
211  size_t nleft_rect;
212  size_t nright_rect;
213 
214  void init();
215  virtual void init_interface_params() = 0;
216 
217  virtual void connect_left_indizes(index_connector&) const = 0;
218  virtual void connect_right_indizes(index_connector&) const = 0;
219 
220  virtual void createHi(Matrix& m) const = 0;
221  virtual void createHit(Matrix& m) const = 0;
222 
223  virtual double yshift() const = 0;
224 
225  virtual size_t nright() const = 0;
226  virtual size_t nleft() const = 0;
227 };
228 
229 #endif
Definition: interface.hpp:64
size_t n_left() const
the number of virtual interface points to the left
Definition: interface.hpp:189
size_t n_right() const
the number of virtual interface points to the right
Definition: interface.hpp:191
size_t n_left_rect() const
the number of actual grid points for the rectangle to the left
Definition: interface.hpp:194
Definition: interface.hpp:21
size_t n_right_rect() const
the number of actual grid points for the rectangle to the right
Definition: interface.hpp:196
An abstract base class supporting xml_file_reading of input parameters.
Definition: input_file.hpp:79
Abstract base class describing the interface between adjacent Rectangles.
Definition: interface.hpp:104
Base Matrix class for access to 2D number grids.
Definition: matrix.hpp:82
Definition: mkl_matrix.hpp:216
Definition: mkl_matrix.hpp:7