Greens-code
A modular quantum transport code
abstract_state_worker.hpp
1 #ifndef STATE_WORKER_ABSTRACT_HPP
2 #define STATE_WORKER_ABSTRACT_HPP
3 
4 #include "executable.hpp"
5 #include "state.hpp"
6 
24 public:
25 
26  ~state_worker() throw() {};
27 
28  typedef STD_TR1::shared_ptr<const state_worker> const_ref;
29  typedef STD_TR1::shared_ptr<state_worker> ref;
30 
32  // to create output filename
33 // void process_wv(MPI_Comm comm, const state s){process_wv_(comm,s);};
35  void process_wvs(MPI_Comm comm, const state_collection::const_ref sc){
36  process_wvs_(comm,sc);};
37 
39  void process_geometry(const std::string& filen,
40  const STD_TR1::shared_ptr<const Rectangle>& rect
41  );
42 
44  void process_potential(const std::string& filen,
45  const STD_TR1::shared_ptr<const Rectangle>& rect
46  );
47 
49  int n_start() { return n_start_;};
50 
52  void prepare_wv(
53  const STD_TR1::shared_ptr<const Rectangle>& r){ prepare_Image_(r);};
54 protected:
55 
56  t_filename_list_ref get_filenames(MPI_Comm,
57  const std::string& head,
58  const std::string& getfilen,
59  const std::string& identifier) const;
60 private:
61  size_t n_start_;
62 
63  bool write_potential_;
64  bool write_geometry_;
65 
66  bool subtr_average_;
67  bool subtr_minimum_;
68 
69  bool set_pos_;
70 
71  virtual void process_wvs_(MPI_Comm, const state_collection::const_ref);
72 
73  virtual void process_wv_(MPI_Comm, const state s) = 0;
74 
75  virtual void init_state_worker() = 0;
76 
77  virtual void prepare_Image_(const STD_TR1::shared_ptr<const Rectangle>&) = 0;
78 
79  void init();
80 
81  void reinit_param(const std::string& param_name);
82  void perform_(MPI_Comm comm);
83 };
84 
86 private:
87 
88  typedef std::vector<state_worker::ref> state_worker_List;
89  STD_TR1::shared_ptr<state_worker_List> state_workers;
90 
91  void process_wvs_(MPI_Comm, const state_collection::const_ref);
92  void process_wv_(MPI_Comm, const state);
93  void init_state_worker();
94 
95  virtual bool include_state( const state s ) = 0;
96 
97  virtual void init_condition() = 0;
98 
99 };
100 
102 protected:
103  std::map<int, complex > evals;
104  std::map<int, const complex* > state_pointers;
105 
106  Rectangle_const_ref geometry;
107 
108  size_t N;
109 
110  typedef std::pair<int,int> tworkpair;
111 
112  std::set<tworkpair> work_pairs;
113 
114  std::set<int> needed;
115 
116 private:
117 
118  state_collection::ref second_set_states;
119 
120  std::vector<int> allstates;
121 
122  virtual void setup_calculation() = 0;
123  virtual void perform_work(MPI_Comm) = 0;
124 
125  void setup_workpairs_needed(MPI_Comm comm, int);
126 
127  void distribute_simple(MPI_Comm comm);
128  void distribute_mincomm(MPI_Comm comm);
129 
130  void init_second(MPI_Comm comm);
131 
132  void process_wvs_(
133  MPI_Comm comm,
134  const state_collection::const_ref states);
135 
136  void process_wv_(MPI_Comm, const state);
137 };
138 
139 #endif
int n_start()
return the starting index of a file
Definition: abstract_state_worker.hpp:49
void process_wvs(MPI_Comm comm, const state_collection::const_ref sc)
process wavefunction of Rectangle in state, using filen and n
Definition: abstract_state_worker.hpp:35
void prepare_wv(const STD_TR1::shared_ptr< const Rectangle > &r)
prepae wavefunction creation, usually you do not need to call this explicitly
Definition: abstract_state_worker.hpp:52
void process_potential(const std::string &filen, const STD_TR1::shared_ptr< const Rectangle > &rect)
create a wv showing potential inside Rectangle, use filen to create output filename ...
Definition: abstract_state_worker.cpp:99
Definition: abstract_state_worker.hpp:85
Definition: state.hpp:24
Definition: abstract_state_worker.hpp:101
void process_geometry(const std::string &filen, const STD_TR1::shared_ptr< const Rectangle > &rect)
create a wv showing geometry of Rectangle, use filen to create output filename
Definition: abstract_state_worker.cpp:133
Definition: executable.hpp:16
abstract base class to work on wavefunctions (states)
Definition: abstract_state_worker.hpp:23