[P]arallel [Hi]gh-order [Li]brary for [P]DEs  Latest
Parallel High-Order Library for PDEs through hp-adaptive Discontinuous Galerkin methods
gnu_out.h
1 #ifndef __GNU_OUT_H__
2 #define __GNU_OUT_H__
3 
4 #include <string>
5 #include <vector>
6 
7 namespace PHiLiP {
8 
9 namespace GridRefinement {
10 
12 
15 template <typename real>
16 class GnuFig
17 {
18 public:
20 
23  GnuFig();
24 
26 
28  explicit GnuFig(const std::string &name_input);
29 
31  void set_name(
32  const std::string &name_input);
33 
35  void set_title(
36  const std::string &title_input);
37 
39  void set_x_label(
40  const std::string &xlabel_input);
41 
43  void set_y_label(
44  const std::string &ylabel_input);
45 
47  void set_grid(
48  const bool grid_bool_input);
49 
51  void set_x_scale_log(
52  const bool xlog_bool_input);
53 
55  void set_y_scale_log(
56  const bool ylog_bool_input);
57 
59  void set_legend(
60  const bool legend_bool_input);
61 
63  void add_xy_data(
64  const std::vector<real> &x_data,
65  const std::vector<real> &y_data);
66 
67  // Adds 2D x vs. y data to be plotted (with a legend label)
68  void add_xy_data(
69  const std::vector<real> &x_data,
70  const std::vector<real> &y_data,
71  const std::string & label_name);
72 
74 
76  void write_gnuplot();
77 
79 
81  void exec_gnuplot();
82 
83 private:
86  std::ostream &out);
87 
89  void write_gnuplot_body(
90  std::ostream &out);
91 
94  std::ostream &out);
95 
97  void write_xy_data(
98  std::ostream & out,
99  const unsigned int data_id);
100 
101  // default settings
102  const std::string DEFAULT_NAME = "GnuFig";
103  const std::string DEFAULT_TITLE = "";
104  const std::string DEFAULT_XLABEL = "";
105  const std::string DEFAULT_YLABEL = "";
106  const bool DEFAULT_GRID = false;
107  const bool DEFAULT_XLOG = false;
108  const bool DEFAULT_YLOG = false;
109  const bool DEFAULT_LEGEND = false;
110 
111  // for the legend
112  const std::string DEFAULT_LABEL_PREFIX = "data_";
113 
114 
115  // properties
116  std::string name;
117  std::string title;
118  std::string xlabel;
119  std::string ylabel;
120  bool grid;
121  bool xlog;
122  bool ylog;
123  bool legend;
124 
125  // data
126  std::vector<std::vector<real>> x_data_vec;
127  std::vector<std::vector<real>> y_data_vec;
128  std::vector<std::string> label_name_vec;
129 };
130 
131 } // namespace GridRefinement
132 
133 } //namespace PHiLiP
134 
135 #endif // __GNU_OUT_H__
void set_y_scale_log(const bool ylog_bool_input)
Set flag for logarithmic y-axis.
Definition: gnu_out.cpp:72
const std::string DEFAULT_NAME
Default file name (no extension)
Definition: gnu_out.h:102
bool ylog
Flag for enabling y-axis logarithimic scale.
Definition: gnu_out.h:122
bool grid
Flag for enabling grid line visibility.
Definition: gnu_out.h:120
GnuFig()
Constructor with no name specified.
Definition: gnu_out.cpp:15
const std::string DEFAULT_TITLE
Default figure title.
Definition: gnu_out.h:103
void set_x_label(const std::string &xlabel_input)
Sets the x-axis label.
Definition: gnu_out.cpp:44
bool legend
Flag for enabling legend visibility.
Definition: gnu_out.h:123
void set_y_label(const std::string &ylabel_input)
Sets the y-axis label.
Definition: gnu_out.cpp:51
const std::string DEFAULT_YLABEL
deafult figure y-axis label
Definition: gnu_out.h:105
std::string ylabel
Figure y-axis label.
Definition: gnu_out.h:119
void set_name(const std::string &name_input)
Sets the file output name (without extension)
Definition: gnu_out.cpp:30
std::string title
Figure title.
Definition: gnu_out.h:117
Gnuplot utility class.
Definition: gnu_out.h:16
const bool DEFAULT_XLOG
Default flag for enabling x-axis logarithimic scale.
Definition: gnu_out.h:107
void set_legend(const bool legend_bool_input)
Sets display visibility of figure legend.
Definition: gnu_out.cpp:79
Files for the baseline physics.
Definition: ADTypes.hpp:10
void write_gnuplot_header(std::ostream &out)
Write the figure formatting header based on settings.
Definition: gnu_out.cpp:122
const bool DEFAULT_YLOG
Default flag for enabling y-axis logarithimic sclae.
Definition: gnu_out.h:108
const std::string DEFAULT_XLABEL
default figure x-axis label
Definition: gnu_out.h:104
void add_xy_data(const std::vector< real > &x_data, const std::vector< real > &y_data)
Adds 2D x vs. y data to be plotted (default legend label)
Definition: gnu_out.cpp:86
std::string name
File name (no extension)
Definition: gnu_out.h:116
void write_xy_data(std::ostream &out, const unsigned int data_id)
Write the i^th data entry to .dat file.
Definition: gnu_out.cpp:199
void exec_gnuplot()
Executes the gnuplot file.
Definition: gnu_out.cpp:209
const std::string DEFAULT_LABEL_PREFIX
Default legend data name prefix (followed by data_id)
Definition: gnu_out.h:112
std::vector< std::vector< real > > y_data_vec
Data entries y-component.
Definition: gnu_out.h:127
std::vector< std::string > label_name_vec
Data entries label names.
Definition: gnu_out.h:128
std::string xlabel
Figure x-axis label.
Definition: gnu_out.h:118
void write_gnuplot()
Main write function call.
Definition: gnu_out.cpp:110
const bool DEFAULT_GRID
Default flag for enabling grid line visibility.
Definition: gnu_out.h:106
std::vector< std::vector< real > > x_data_vec
Data entries x-component.
Definition: gnu_out.h:126
bool xlog
Flag for enabling x-axis logarithimic scale.
Definition: gnu_out.h:121
void set_grid(const bool grid_bool_input)
Set flag for enabling background grid.
Definition: gnu_out.cpp:58
void write_gnuplot_footer(std::ostream &out)
Writes the figure footer.
Definition: gnu_out.cpp:192
void set_x_scale_log(const bool xlog_bool_input)
Set flag for logarithmic x-axis.
Definition: gnu_out.cpp:65
const bool DEFAULT_LEGEND
Default flag for enabling legend visibility.
Definition: gnu_out.h:109
void set_title(const std::string &title_input)
Sets the figure title.
Definition: gnu_out.cpp:37
void write_gnuplot_body(std::ostream &out)
Writes the figure body including performing data outputs.
Definition: gnu_out.cpp:165