Greens-code
A modular quantum transport code
image_parser.hpp
1 #ifndef IMAGE_PARSER_HPP
2 #define IMAGE_PARSER_HPP
3 
4 #include "executable.hpp"
5 #include "my_mkl.hpp"
6 
7 class Bild;
8 class palette;
9 
11 
22 {
23 public:
24  typedef STD_TR1::shared_ptr<abstract_image_parser> ref;
25  typedef STD_TR1::shared_ptr<const abstract_image_parser> const_ref;
26 
27  ~abstract_image_parser() throw() {};
28 
30  void process_image( MPI_Comm comm,
31  const Bild& b,
32  const std::string& file_id);
33 
35 // struct process{
36 // process( const Bild& bb, const std::string& s):
37 // b(bb), name(s){};
38 //
39 // void operator()( const STD_TR1::shared_ptr<abstract_image_parser>& p)
40 // { p->process_image(b,name);}
41 // private:
42 // process();
43 //
44 // const Bild& b;
45 // std::string name;
46 // };
47 
48 private:
50  virtual void process_image_( MPI_Comm comm,
51  const Bild&,
52  const std::string&) = 0;
53 };
54 
56 
67 {
68 public:
69  ~image_manipulator() throw() {};
70 private:
71  STD_TR1::shared_ptr< std::list< STD_TR1::shared_ptr<abstract_image_parser> > >
72  processors;
73 
75  void process_image_( MPI_Comm comm,
76  const Bild&,
77  const std::string&);
78 
80  virtual std::unique_ptr<Bild> altered_image_( const Bild& ) = 0;
81 
83  void init();
84 
86  virtual const char* filename_addition_() const = 0;
87 
89  virtual void init_manipulator_() = 0;
90 };
91 
93 
103 {
104 public:
105  ~Crop_image() throw() {};
106 
107 private:
108  double x_min, x_max, y_min, y_max;
109 
110  const char* name() const { return "crop_image";};
111 
112  const char* filename_addition_() const { return "cropped";};
113 
114  std::unique_ptr<Bild> altered_image_( const Bild& );
115 
116  void init_manipulator_();
117 };
118 
120 
128 {
129 public:
130  ~Blur_image() throw() {};
131 
132 private:
133  int radius;
134 
135  const char* name() const { return "blur_image";};
136 
137  const char* filename_addition_() const { return "blured";};
138 
139  std::unique_ptr<Bild> altered_image_( const Bild& );
140 
141  void init_manipulator_();
142 };
143 
145 
162 {
163 public:
164  ~EraseBorder_image() throw() {};
165 
166 private:
167  int border;
168  int radius;
169  bool rectangular;
170  bool renorm;
171 
172  void erase_rectangular(Bild& fb);
173  void erase_circular(Bild& fb);
174  void renorm_image(Bild& fb);
175 
176  const char* name() const { return "erase_border_image";};
177 
178  const char* filename_addition_() const { return "erasedborder";};
179 
180  std::unique_ptr<Bild> altered_image_( const Bild& );
181 
182  void init_manipulator_();
183 };
184 
186 
194 {
195 public:
196  ~participation_ratio_processor() throw() {};
197 
198 private:
199  int nx_min;
200  int nx_max;
201 
202  const char* name() const { return "PPR_image";};
203  void init();
204  virtual void process_image_( MPI_Comm,
205  const Bild&,
206  const std::string&);
207 };
208 
210 
217 {
218 public:
219  ~spread_processor() throw() {};
220 
221 private:
222  int nx_min;
223  int nx_max;
224 
225  const char* name() const { return "spread_image";};
226  void init();
227  virtual void process_image_( MPI_Comm,
228  const Bild&,
229  const std::string&);
230 };
231 
233 
243 {
244 public:
245  ~ascii_image_processor() throw() {};
246 private:
247  char fill_char;
248 
249  bool write_imag;
250 
251  const char* name() const { return "ascii_image";};
252  void init();
253 
254  void process_image_( MPI_Comm,
255  const Bild& b,
256  const std::string& filen );
257 
258  bool check_state_id( const Bild& b);
259 
260 };
261 
281 public:
282  ~sum_image_processor() throw() {};
283 
284  const Bild& get_current_image() const;
285 
286  void reset_current_image();
287 
288  void synchronize_threads(MPI_Comm);
289 
290  size_t count() const { return c;};
291 
292  typedef STD_TR1::shared_ptr<sum_image_processor> ref;
293  typedef STD_TR1::shared_ptr<const sum_image_processor> const_ref;
294 
295 private:
296  std::vector<complex>::iterator start;
297  std::vector<complex>::iterator end;
298 
299  std::vector<complex> coeffs;
300 
301  int do_absolute;
302 
303  size_t c;
304 
305  std::unique_ptr<Bild> data;
306 
307  const char* name() const { return "sum_images";};
308 
309  void init();
310 
311  void process_image_( MPI_Comm,
312  const Bild& b,
313  const std::string& filen );
314 };
315 
325 public:
326  ~sum_image_writer() throw() {};
327 
328 private:
329 
330  sum_image_processor::ref sip;
331 
332 
333  STD_TR1::shared_ptr< std::list< abstract_image_parser::ref > >
334  my_image_parsers;
335 
336 
337  const char* name() const { return "sum_image_writer";};
338  void init();
339 
340  void setup_data_();
341 
342  void reinit_param(const std::string& param_name);
343 
344  void perform_(MPI_Comm comm);
345 
346  void post_process_(MPI_Comm comm);
347 };
348 
350 
357 public:
358  ~subtract_image_processor() throw() {};
359 
360  const Bild& get_current_image() const;
361 
362  void reset_current_image();
363 
364  size_t count() const { return c;};
365 
366  typedef STD_TR1::shared_ptr<subtract_image_processor> ref;
367  typedef STD_TR1::shared_ptr<const subtract_image_processor> const_ref;
368 
369 private:
370  std::vector<complex>::iterator start;
371  std::vector<complex>::iterator end;
372 
373  int c;
374 
375  double prop;
376 
377  int p_one,p_two;
378 
379  std::unique_ptr<Bild> final;
380 
381  const char* name() const { return "subtract_images";};
382 
383  void init();
384 
385  void process_image_( MPI_Comm,
386  const Bild& b,
387  const std::string& filen );
388 };
389 
391 public:
392  ~subtract_image_writer() throw() {};
393 
394 private:
395 
396  subtract_image_processor::ref sip;
397 
398  STD_TR1::shared_ptr< std::list< STD_TR1::shared_ptr< abstract_image_parser> > >
399  my_image_parsers;
400 
401  const char* name() const { return "subtract_image_writer";};
402  void init();
403 
404  void setup_data_();
405 
406  void reinit_param(const std::string& param_name);
407 
408  void perform_(MPI_Comm comm);
409 
410  void post_process_(MPI_Comm);
411 };
412 
414 
427 {
428 public:
429  ~average_image_processor() throw() {};
430 private:
431 
432  bool x_cut;
433  double min_y;
434  double max_y;
435  double min_x;
436  double max_x;
437 
438  const char* name() const { return "average_image";};
439  void init();
440 
441  void process_image_( MPI_Comm,
442  const Bild& b,
443  const std::string& filen );
444 
445  void make_x_cut(std::ofstream& ofs,
446  const Bild& b) const;
447  void make_y_cut(std::ofstream& ofs,
448  const Bild& b) const;
449 
450 };
451 
452 
454 
463 {
464 public:
465  ~cut_image_processor() throw() {};
466 private:
467 
468  bool x_cut;
469  double cut;
470  int mittel; //the program takes the average of several cuts. mittel is the number of cuts taken for the average
471 
472  const char* name() const { return "cut_image";};
473  void init();
474 
475  void process_image_( MPI_Comm,
476  const Bild& b,
477  const std::string& filen );
478 
479  void make_x_cut(std::ofstream& ofs,
480  const Bild& b) const;
481  void make_y_cut(std::ofstream& ofs,
482  const Bild& b) const;
483 
484 };
485 
487 
495 {
496 public:
497  ~current_image_processor() throw() {};
498 private:
499 
500 
501  const char* name() const { return "current_image";};
502  void init();
503 
504  void process_image_( MPI_Comm,
505  const Bild& b,
506  const std::string& filen );
507 
508 };
509 
512 {
513 private:
514  double min_border;
515 
516  const char* name() const { return "corrogation_image";};
517  void init();
518 
519  void process_image_( MPI_Comm,
520  const Bild& b,
521  const std::string& filen );
522 };
523 
526 {
527 private:
528 
529  double norm;
530 
531  const char* name() const { return "correlation_image";};
532  void init();
533 
534  void correlate(int, int, complex*, const Bild&) const;
535 
536  void process_image_( MPI_Comm,
537  const Bild& b,
538  const std::string& filen );
539 };
540 
542 public:
543  ~collect_image_processor() throw() {};
544 
545  const Bild& get_image(size_t i) const;
546 
547  void reset_images();
548 
549  void synchronize_threads(MPI_Comm);
550 
551  size_t count() const { return size;};
552 
553  typedef STD_TR1::shared_ptr<collect_image_processor> ref;
554  typedef STD_TR1::shared_ptr<const collect_image_processor> const_ref;
555  typedef std::vector< STD_TR1::shared_ptr<Bild> >::iterator iterator;
556 
557  iterator begin(){ return data.begin();}
558  iterator end() { return data.end(); }
559 
560 private:
561  size_t size;
562 
563  std::vector< STD_TR1::shared_ptr<Bild> > data;
564 
565  const char* name() const { return "collect_images";};
566 
567  void init();
568  void process_image_( MPI_Comm,
569  const Bild& b,
570  const std::string& filen );
571 };
572 
574 public:
575  ~normalize_image_by_maximum() throw() {};
576 
577 private:
578  bool mark_max;
579  std::vector<double> normalizations;
580  int low_x,high_x;
581  int low_y,high_y;
582  const char * name() const { return "normalize_image_by_maximum";};
583  void init_manipulator_();
584  std::unique_ptr<Bild> altered_image_( const Bild& b );
585  const char* filename_addition_() const { return "maxnorm";};
586  };
587 
588 
590 
596 public:
597  ~project_images() throw() {};
598 
599 private:
600  collect_image_processor::ref targets;
601  collect_image_processor::ref basis;
602  collect_image_processor::ref biorthogonal_basis;
603  std::vector< std::vector<complex> > coefficients;
604  size_t image_n;
605  size_t basis_n;
606 
607  const char* name() const {return "project_images";};
608  void init();
609  void setup_data_();
610  void reinit_param(const std::string& param_name);
611  void perform_(MPI_Comm comm);
612  void post_process_(MPI_Comm comm);
613 };
614 
615 #endif
Manipulator to erase Border.
Definition: image_parser.hpp:161
Definition: image_parser.hpp:541
Executable Object to output images collected by a sum_image_processor sum_image_writer will forward t...
Definition: image_parser.hpp:324
Definition: image_parser.hpp:573
Processor to cut through wavefunction.
Definition: image_parser.hpp:462
Definition: image_parser.hpp:390
Processor for autocorrogation of wavefunction.
Definition: image_parser.hpp:511
class to turn a complex value into a color
Definition: write_jpg.hpp:60
Class to contain wave-function image data.
Definition: generate_wavefunction.hpp:25
Base clase for Processors that change the image, and then call actuall processors.
Definition: image_parser.hpp:66
Abstract base class to process calculated wavefunctions.
Definition: image_parser.hpp:21
Processor to subtract wavefunctions.
Definition: image_parser.hpp:356
Manipulator to blur an image, useful when rendering graphene.
Definition: image_parser.hpp:127
Processor to sum up identical wavefunctions sum_image_processor will store an image internally...
Definition: image_parser.hpp:280
An abstract base class supporting xml_file_reading of input parameters.
Definition: input_file.hpp:79
Processor for current of wavefunction - will be mostly zero for eigenstates of closed systems at zero...
Definition: image_parser.hpp:494
Average out one spatial dimension in the image.
Definition: image_parser.hpp:426
Processor to calculate PPR.
Definition: image_parser.hpp:193
Class to project wavefunctions on a basis.
Definition: image_parser.hpp:595
Processor for autocorrelation of wavefunction.
Definition: image_parser.hpp:525
Processor to calculate spread.
Definition: image_parser.hpp:216
Definition: executable.hpp:16
Processor to output image as gnuplotable text.
Definition: image_parser.hpp:242
void process_image(MPI_Comm comm, const Bild &b, const std::string &file_id)
Process the image in Bild, use file_id as part of the output name.
Definition: image_parser.cpp:17
Manipulator to crop an image, useful when one wants to further process.
Definition: image_parser.hpp:102