6 #include <deal.II/base/exceptions.h> 12 namespace GridRefinement {
14 template <
typename real>
17 template <
typename real>
19 const std::string &name_input) :
29 template <
typename real>
31 const std::string &name_input)
36 template <
typename real>
38 const std::string &title_input)
43 template <
typename real>
45 const std::string &xlabel_input)
50 template <
typename real>
52 const std::string &ylabel_input)
57 template <
typename real>
59 const bool grid_bool_input)
61 grid = grid_bool_input;
64 template <
typename real>
66 const bool xlog_bool_input)
68 xlog = xlog_bool_input;
71 template <
typename real>
73 const bool ylog_bool_input)
75 ylog = ylog_bool_input;
78 template <
typename real>
80 const bool legend_bool_input)
82 legend = legend_bool_input;
85 template <
typename real>
87 const std::vector<real> &x_data,
88 const std::vector<real> &y_data)
96 template <
typename real>
98 const std::vector<real> &x_data,
99 const std::vector<real> &y_data,
100 const std::string & label_name)
102 Assert(x_data.size() == y_data.size(), dealii::ExcInternalError());
109 template <
typename real>
112 std::ofstream gnu_out(
name +
".gp");
118 gnu_out << std::flush;
121 template <
typename real>
125 out <<
"# *********************************** " <<
'\n' 126 <<
"# * GNUPLOT OUTPUT FILE GENERATED * " <<
'\n' 127 <<
"# * AUTOMATICALLY BY PHiLiP LIBRARY * " <<
'\n' 128 <<
"# *********************************** " <<
'\n' <<
'\n';
130 out <<
"set term png" <<
'\n' <<
'\n';
132 out <<
"set output '" <<
name <<
".png" <<
"'" <<
'\n';
133 out <<
"set title '" <<
title <<
"'" <<
'\n';
134 out <<
"set xlabel '" <<
xlabel <<
"'" <<
'\n';
135 out <<
"set ylabel '" <<
ylabel <<
"'" <<
'\n' <<
'\n';
138 out <<
"set grid" <<
'\n';
140 out <<
"unset grid" <<
'\n';
144 out <<
"set log x" <<
'\n';
146 out <<
"set format x \"10^{%L}\"" <<
'\n';
150 out <<
"set log y" <<
'\n';
152 out <<
"set format y \"10^{%L}\"" <<
'\n';
156 out <<
"set key" <<
'\n';
158 out <<
"unset key" <<
'\n';
164 template <
typename real>
173 for(
unsigned int i = 0; i <
x_data_vec.size(); ++i){
175 out <<
", \\" <<
'\n' <<
" ";
178 std::ofstream dat_out(dat_filename);
182 out <<
"'" << dat_filename <<
"' with linespoint";
185 out <<
" title \"" << label_name_vec[i] <<
"\"";
191 template <
typename real>
198 template <
typename real>
201 const unsigned int data_id)
204 for(
unsigned int i = 0; i <
x_data_vec[data_id].size(); ++i)
208 template <
typename real>
212 int ret = std::system((
"gnuplot \"" +
name +
".gp\"").c_str());
215 std::cout <<
"Note: gnuplot not availible. Set ENABLE_GNUPLOT to automatically run \"" 216 <<
name <<
".gp\"" << std::endl;
void set_y_scale_log(const bool ylog_bool_input)
Set flag for logarithmic y-axis.
bool ylog
Flag for enabling y-axis logarithimic scale.
bool grid
Flag for enabling grid line visibility.
GnuFig()
Constructor with no name specified.
const std::string DEFAULT_TITLE
Default figure title.
void set_x_label(const std::string &xlabel_input)
Sets the x-axis label.
bool legend
Flag for enabling legend visibility.
void set_y_label(const std::string &ylabel_input)
Sets the y-axis label.
const std::string DEFAULT_YLABEL
deafult figure y-axis label
std::string ylabel
Figure y-axis label.
void set_name(const std::string &name_input)
Sets the file output name (without extension)
std::string title
Figure title.
const bool DEFAULT_XLOG
Default flag for enabling x-axis logarithimic scale.
void set_legend(const bool legend_bool_input)
Sets display visibility of figure legend.
Files for the baseline physics.
void write_gnuplot_header(std::ostream &out)
Write the figure formatting header based on settings.
const bool DEFAULT_YLOG
Default flag for enabling y-axis logarithimic sclae.
const std::string DEFAULT_XLABEL
default figure x-axis label
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)
std::string name
File name (no extension)
void write_xy_data(std::ostream &out, const unsigned int data_id)
Write the i^th data entry to .dat file.
void exec_gnuplot()
Executes the gnuplot file.
const std::string DEFAULT_LABEL_PREFIX
Default legend data name prefix (followed by data_id)
std::vector< std::vector< real > > y_data_vec
Data entries y-component.
std::vector< std::string > label_name_vec
Data entries label names.
std::string xlabel
Figure x-axis label.
void write_gnuplot()
Main write function call.
const bool DEFAULT_GRID
Default flag for enabling grid line visibility.
std::vector< std::vector< real > > x_data_vec
Data entries x-component.
bool xlog
Flag for enabling x-axis logarithimic scale.
void set_grid(const bool grid_bool_input)
Set flag for enabling background grid.
void write_gnuplot_footer(std::ostream &out)
Writes the figure footer.
void set_x_scale_log(const bool xlog_bool_input)
Set flag for logarithmic x-axis.
const bool DEFAULT_LEGEND
Default flag for enabling legend visibility.
void set_title(const std::string &title_input)
Sets the figure title.
void write_gnuplot_body(std::ostream &out)
Writes the figure body including performing data outputs.