XGCa
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ascii_plots.hpp
Go to the documentation of this file.
1 #ifndef ASCII_PLOTS_HPP
2 #define ASCII_PLOTS_HPP
3 
4 template<typename F>
5 void ascii_contour_plot(const RZBounds& bounds, F func){
6  int nx = 80;
7  int ny = 40;
8  double dr = bounds.get_r_width()/nx;
9  double dz = bounds.get_z_width()/ny;
10  printf("\n");
11  std::vector<int> prevrow(nx+1,-1);
12  for (int j=ny;j>=0;j--){
13  printf("\n");
14  int prevnum = -1;
15  for (int i=0;i<=nx;i++){
16  double r = bounds.min_r + i*dr;
17  double z = bounds.min_z + j*dz;
18 
19  // Get value of function
20  double val = func(r, z);
21 
22  // Assume the user has normalized the function to (0.0,10.0)
23  int num = val;
24 
25  num += 48; // Shift so val=0.0 results in char 0
26 
27  // Allow values outside from 33 (!) to 125 (})
28  num = std::max(33,std::min(num,125));
29 
30  char mychar = num;
31  if (prevnum!=num || prevrow[i]!=num) printf("%c",mychar);
32  else printf(" ");
33  prevnum = num;
34  prevrow[i] = num;
35  }
36  }
37  printf("\n");
38 }
39 
40 #endif
void ascii_contour_plot(const RZBounds &bounds, F func)
Definition: ascii_plots.hpp:5
Definition: rz_bounds.hpp:4
double min_r
Definition: rz_bounds.hpp:5
KOKKOS_INLINE_FUNCTION double get_z_width() const
Definition: rz_bounds.hpp:28
KOKKOS_INLINE_FUNCTION double get_r_width() const
Definition: rz_bounds.hpp:24
double min_z
Definition: rz_bounds.hpp:7