43 ostream& out = ops.
os();
44 delete_macro (b._p_ctrl_out);
45 delete_macro (b._p_data_out);
46 string basename = iorheo::getbasename(out);
47 if (basename ==
"") basename =
"output";
48 bool do_verbose = iorheo::getverbose(clog);
49 bool do_execute = iorheo::getexecute(clog);
50 bool do_clean = iorheo::getclean (clog);
51 string tmp = (do_clean ?
get_tmpdir() +
"/" :
"");
53 string plot_name = tmp+basename +
".plot";
54 string param_name = tmp+basename +
"-visu-param.plot";
55 b._to_clean = plot_name;
56 b._p_ctrl_out = new_macro (ofstream(plot_name.c_str()));
57 do_verbose && clog <<
"! file `" << plot_name <<
"' created" << endl;
58 *(b._p_ctrl_out) << setbasename(basename)
59 << setprecision(numeric_limits<T>::digits10)
60 <<
"load \"" << param_name <<
"\"" << endl;
61 b._have_u_range.first = (b._u_range.first != std::numeric_limits<T>::max());
62 b._have_u_range.second = (b._u_range.second != -std::numeric_limits<T>::max());
69 bool do_verbose = iorheo::getverbose(clog);
70 size_t nfld = b.n_field();
71 if (nfld == 0)
return;
77 bool do_clean = iorheo::getclean (clog);
78 string basename = iorheo::getbasename(ops.
os());
79 if (basename ==
"") basename =
"output";
80 string tmp = (do_clean ?
get_tmpdir() +
"/" :
"");
84 if (b._count_value == 0) {
85 *(b._p_ctrl_out) <<
"set xrange [" << omega.xmin()[0] <<
":" << omega.xmax()[0] <<
"]" << endl;
87 if (! b._have_u_range.first || ! b._have_u_range.second) {
88 for (
size_t ifld = 0; ifld < nfld; ifld++) {
90 if (! b._have_u_range.first) {
91 b._u_range.first = std::min (b._u_range.first,
u.min());
93 if (! b._have_u_range.second) {
94 b._u_range.second = std::max (b._u_range.second,
u.max());
101 const string& pname = b.parameter_name() +
" = " +
ftos(b.parameter());
102 *(b._p_ctrl_out) <<
"set title \"i = " << b._count_value <<
": " << pname <<
"\" font \"arial,20\"" << endl
103 <<
"plot \\" << endl;
104 for (
size_t ifld = 0; ifld < nfld; ifld++) {
105 const string& uname = b[ifld].first;
106 string gdat_name = tmp + basename +
"_" + uname +
"_" + std::to_string(b._count_value) +
".gdat";
107 *(b._p_ctrl_out) << (ifld == 0 ?
" " :
",")
108 <<
" \"" << gdat_name <<
"\""
110 <<
" t \"" << uname <<
"\""
112 << (ifld < nfld-1 ?
" \\" :
"")
115 *(b._p_ctrl_out) <<
"pause dt_pause" << endl;
120 size_type subdivide = iorheo::getsubdivide(ops.
os());
121 bool fill = iorheo::getfill(ops.
os());
122 for (
size_t ifld = 0; ifld < nfld; ifld++) {
123 const string& uname = b[ifld].first;
125 string gdat_name = tmp + basename +
"_" + uname +
"_" + std::to_string(b._count_value) +
".gdat";
126 ofstream gdat (gdat_name.c_str());
127 b._to_clean = b._to_clean +
" " + gdat_name;
128 if (do_verbose) clog <<
"! file \"" << gdat_name <<
"\" created.\n";
129 gdat << setprecision(numeric_limits<T>::digits10);
132 if (subdivide == 0) {
133 subdivide = std::max(omega.order(), subdivide);
134 subdivide = std::max(b_fem.
degree (), subdivide);
136 size_type map_dim = omega.map_dimension();
137 size_type used_dim = (fill ? map_dim : 1);
138 basis_basic<T> subdivide_pointset (
"P"+std::to_string(subdivide));
142 bbox.
xmin = omega.xmin();
143 bbox.
xmax = omega.xmax();
146 for (
size_type ie = 0, ne = omega.size(used_dim); ie < ne; ie++) {
147 const geo_element& K = omega.get_geo_element(used_dim,ie);
148 put (gdat, omega, K, uh, fops, subdivide, bbox);
158 string basename = iorheo::getbasename(ops.
os());
159 if (basename ==
"") basename =
"output";
160 bool do_verbose = iorheo::getverbose(clog);
161 bool do_execute = iorheo::getexecute(clog);
162 bool do_clean = iorheo::getclean(clog);
163 bool reader_on_stdin = iorheo::getreader_on_stdin(ops.
os());
164 if (! reader_on_stdin) {
165 *(b._p_ctrl_out) <<
"pause -1 \"<end>\"" << endl;
167 string tmp = (do_clean ?
get_tmpdir() +
"/" :
"");
171 string param_name = tmp+basename +
"-visu-param.plot";
172 ofstream param (param_name.c_str());
173 if (do_verbose) clog <<
"! file \"" << param_name <<
"\" created.\n";
174 b._to_clean = b._to_clean +
" " + param_name;
175 param <<
"duration = 30 # in seconds" << endl
176 <<
"n_step = " << b._count_value << endl
177 <<
"dt_pause = 1.0*duration/n_step" << endl;
178 if (b._u_range.second - b._u_range.first < 1e-7) {
180 b._u_range.second = b._u_range.first + 1;
182 param <<
"set yrange [" << b._u_range.first <<
":" << b._u_range.second <<
"]" << endl;
190 command =
"gnuplot ";
191 if (reader_on_stdin) command +=
"-persist ";
192 command += tmp + basename +
".plot";
193 if (do_verbose) clog <<
"! " << command << endl;
195 status = system (command.c_str());
202 if (!do_clean) tmp =
"";
203 string command =
"/bin/rm -f " + b._to_clean;
206 do_verbose && clog <<
"! cleaning temporary .plot and .gdat files" << endl;
207 int status = system (command.c_str());
209 delete_macro (b._p_ctrl_out);
210 delete_macro (b._p_data_out);