26 #include "rheolef/iorheo.h"
40 default: error_macro (
"unimplemented gnuplot visualization of "<<valued()<<
"-valued polynomials");
45 basis_rep<T>::put_scalar_valued (ostream& os, reference_element hat_K)
const
54 bool verbose = iorheo::getverbose(os);
55 bool clean = iorheo::getclean(os);
56 bool execute = iorheo::getexecute(os);
57 size_type nsub = iorheo::getsubdivide(os);
58 if (nsub <= 1) nsub = 20;
66 string plot_name =
basename +
".plot";
67 string gdat_name =
basename +
".gdat";
68 ofstream plot (plot_name.c_str());
69 cerr <<
"! file \"" << plot_name <<
"\" created" << endl;
70 filelist +=
" \"" + plot_name +
"\"";
72 check_macro (
d==1 ||
d==2,
"unsupported dimension " <<
d);
73 plot <<
"gdat = \"" << gdat_name <<
"\"" << endl
74 <<
"set colors classic" << endl
75 <<
"set size square" << endl
83 for (
size_type loc_isid = 0, loc_nsid = hat_K.
n_subgeo(1); loc_isid < loc_nsid; ++loc_isid) {
88 plot <<
"set arrow from ";
92 if (
mu+1 != d2) plot <<
", ";
99 if (
mu+1 != d2) plot <<
", ";
103 plot <<
" nohead lc 0 lw 1" << endl;
107 <<
"set xrange ["<<xmin[0]-
delta<<
":"<<xmax[0]+
delta<<
"]"<<endl;
109 plot <<
"set yrange ["<<xmin[1]-
delta<<
":"<<xmax[1]+
delta<<
"]"<<endl;
111 plot <<
"set yrange [-1:1]"<<endl;
114 plot <<
"set zrange ["<<xmin[2]-
delta<<
":"<<xmax[2]+
delta<<
"]"<<endl
115 <<
"set xyplane at "<< xmin[2]-
delta << endl;
118 plot <<
"plot \\" << endl
120 for (
size_t loc_idof = 0; loc_idof < loc_ndof; ++loc_idof) {
121 plot <<
" gdat u 1:"<<loc_idof+2 <<
" t \"L" << loc_idof+1 <<
"\" w l";
122 if (loc_idof+1 != loc_ndof) { plot <<
",\\"; }
126 plot <<
"pause_duration = 0.5" << endl
128 <<
"scale= 1./" << nsub << endl
130 <<
"idxmax = " << loc_ndof << endl
131 <<
"plot gdat i idx u 1:2:(scale*$3):(scale*$4) t sprintf(\"P%d\",idx+1) w vec lc 0 lw 2" << endl
132 <<
"load \"" <<
basename <<
".loop\"" << endl
134 string loop_name =
basename +
".loop";
135 ofstream loop (loop_name.c_str());
136 cerr <<
"! file \"" << loop_name <<
"\" created" << endl;
137 filelist +=
" \"" + loop_name +
"\"";
138 loop <<
"idx = idx+1" << endl
139 <<
"if (idx < idxmax) \\" << endl
140 <<
" pause -1 \"<return>\"; \\" << endl
141 <<
" replot; \\" << endl
145 plot <<
"pause -1 \"<return>\"" << endl;
151 ofstream gdat (gdat_name.c_str());
152 cerr <<
"! file \"" << gdat_name <<
"\" created" << endl;
153 filelist +=
" \"" + gdat_name +
"\"";
154 gdat << setprecision(std::numeric_limits<T>::digits10)
155 <<
"# basis " <<
name() << endl
156 <<
"# element " << hat_K.
name() << endl
157 <<
"# degree " << degree() << endl
165 gdat <<
"# ndof " << loc_ndof << endl
167 for (
size_t loc_idof = 0; loc_idof < loc_ndof; ++loc_idof) {
168 gdat <<
" L" << loc_idof+1;
173 eval (hat_K, hat_x,
value);
175 for (
size_t loc_idof = 0, loc_ndof =
value.size(); loc_idof < loc_ndof; ++loc_idof) {
176 for (
size_t mu = 0;
mu <
d; ++
mu) {
177 gdat <<
" " <<
value[loc_idof][
mu];
187 Eigen::Matrix<point_basic<T>,Eigen::Dynamic,1> hat_node;
188 Eigen::Matrix<point_basic<T>,Eigen::Dynamic,Eigen::Dynamic>
value;
191 size_t loc_nnod =
value.rows();
192 size_t loc_ndof =
value.cols();
193 for (
size_t loc_idof = 0; loc_idof < loc_ndof; ++loc_idof) {
194 for (
size_t loc_inod = 0; loc_inod < loc_nnod; ++loc_inod) {
195 for (
size_t mu = 0;
mu <
d; ++
mu) {
196 gdat << hat_node[loc_inod][
mu] <<
" ";
198 for (
size_t mu = 0;
mu <
d; ++
mu) {
199 gdat <<
value(loc_inod,loc_idof)[
mu] <<
" ";
203 gdat << endl << endl;
210 for (
size_type j = 0; j+k <= nsub; j++) {
211 for (
size_type i = 0; i+j+k <= nsub; i++) {
213 eval_lagrange (hat_x, hat_K, degree, sopt, inv_vdm,
value);
221 for (
size_type k = 0; k <= degree; k++) {
222 for (
size_type j = 0; j <= degree; j++) {
223 for (
size_type i = 0; i+j <= degree; i++) {
225 eval_lagrange (hat_x, hat_K, degree, sopt, inv_vdm,
value);
233 for (
size_type k = 0; k <= degree; k++) {
234 for (
size_type j = 0; j <= degree; j++) {
235 for (
size_type i = 0; i <= degree; i++) {
237 eval_lagrange (hat_x, hat_K, degree, sopt, inv_vdm,
value);
246 error_macro (
"unexpected element type `"<<hat_K.
name()<<
"'");
251 string command =
"gnuplot \"" + plot_name +
"\"";
258 string command =
"/bin/rm -f " + filelist;
273 plot <<
"set colors classic" << endl
274 <<
"set nokey" << endl
275 <<
"set noborder" << endl
276 <<
"set noxtics" << endl
277 <<
"set noytics" << endl
278 <<
"set noztics" << endl
281 plot <<
"set size ratio -1 # 2d equal scales" << endl;
283 plot <<
"set view 70, 140 # x to left, y to right, z to top" << endl;
284 plot <<
"set view equal xyz # 3d equal scales" << endl;
294 for (
size_type loc_isid = 0, loc_nsid = hat_K.
n_subgeo(1); loc_isid < loc_nsid; ++loc_isid) {
299 plot <<
"set arrow from ";
303 if (
mu+1 != d2) plot <<
", ";
310 if (
mu+1 != d2) plot <<
", ";
314 plot <<
" nohead lc 0 lw 1" << endl;
318 <<
"set xrange ["<<xmin[0]-
delta<<
":"<<xmax[0]+
delta<<
"]"<<endl;
320 plot <<
"set yrange ["<<xmin[1]-
delta<<
":"<<xmax[1]+
delta<<
"]"<<endl;
322 plot <<
"set yrange [-1:1]"<<endl;
325 plot <<
"set zrange ["<<xmin[2]-
delta<<
":"<<xmax[2]+
delta<<
"]"<<endl
326 <<
"set xyplane at "<< xmin[2]-
delta << endl;
334 bool verbose = iorheo::getverbose(os);
335 bool clean = iorheo::getclean(os);
336 bool execute = iorheo::getexecute(os);
338 _initialize_data_guard (hat_K);
339 const Eigen::Matrix<point_basic<T>,Eigen::Dynamic,1>& hat_x = hat_node(hat_K);
347 string gdat_name =
basename +
".gdat";
348 ofstream gdat (gdat_name.c_str());
349 cerr <<
"! file \"" << gdat_name <<
"\" created" << endl;
350 filelist +=
" " + gdat_name;
351 gdat << setprecision(std::numeric_limits<T>::digits10)
352 <<
"# basis " <<
name() << endl
353 <<
"# element " << hat_K.
name() << endl
354 <<
"# degree " << degree() << endl
355 <<
"# ndof " <<
ndof(hat_K) << endl
356 <<
"# raw_poly " << _sopt.get_raw_polynomial_name() << endl
357 <<
"# nodeset " << _sopt.get_node_name() << endl
358 <<
"# nnode " << hat_x.size() << endl
360 if (! option().is_restricted_to_sides()) {
362 for (
size_type loc_inod = first_inod_by_dimension(hat_K,
dim), loc_nnod = first_inod_by_dimension(hat_K,
dim+1); loc_inod < loc_nnod; ++loc_inod) {
363 hat_x [loc_inod].put (gdat, max(
d,
size_type(2)));
364 gdat <<
" " << loc_inod << endl;
366 gdat << endl << endl;
370 for (
size_type loc_inod = 0, loc_nnod =
nnod(hat_K); loc_inod < loc_nnod; ++loc_inod) {
371 hat_x [loc_inod].put (gdat, max(
d,
size_type(2)));
372 gdat <<
" " << loc_inod << endl;
378 string plot_name =
basename +
".plot";
379 ofstream plot (plot_name.c_str());
380 cerr <<
"! file \"" << plot_name <<
"\" created" << endl;
381 filelist +=
" " + plot_name;
382 plot <<
"gdat = \"" << gdat_name <<
"\"" << endl
383 <<
"set title \"" <<
name() <<
": nodes\"" << endl
385 put_hat_node_header<T> (plot, hat_K) ;
386 string color[4] = {
"#ff0000",
"#008800",
"#0000ff",
"#ff00ff"};
387 bool need_coma =
false;
389 plot << ((
d==3) ?
"s" :
"") <<
"plot \\" << endl;
390 if (! option().is_restricted_to_sides()) {
392 size_type nnod_dim = first_inod_by_dimension (hat_K,
dim+1) - first_inod_by_dimension (hat_K,
dim);
393 if (nnod_dim == 0)
continue;
394 plot <<
" " << (need_coma ?
", " :
" ") <<
"gdat \\" << endl
395 <<
" index " << index <<
" \\" << endl
396 <<
" w p ps 2 pt 7 lc rgb \"" << color[
dim] <<
"\",\\" << endl
397 <<
" gdat \\" << endl
398 <<
" index " << index <<
" \\" << endl
399 <<
" u 1:2:3" << ((
d==3) ?
":4" :
"") <<
" w labels offset char 2 lc 0 \\" << endl
405 plot <<
" gdat \\" << endl
406 <<
" w p ps 2 pt 7 lc rgb \"" << color[0] <<
"\",\\" << endl
407 <<
" gdat \\" << endl
408 <<
" u 1:2:3" << ((
d==3) ?
":4" :
"") <<
" w labels offset char 2 lc 0" << endl
412 <<
"pause -1 \"<return>\"" << endl
417 string command =
"gnuplot \"" + plot_name +
"\"";
424 string command =
"/bin/rm -f " + filelist;
440 check_macro (is_nodal(),
"side-node visualization: only nodal basis supported");
441 Eigen::Matrix<size_type,Eigen::Dynamic,1> loc_inod;
442 local_idof_on_side (hat_K, sid, loc_inod);
444 bool verbose = iorheo::getverbose(os);
445 bool clean = iorheo::getclean(os);
446 bool execute = iorheo::getexecute(os);
448 _initialize_data_guard (hat_K);
449 const Eigen::Matrix<point_basic<T>,Eigen::Dynamic,1>& hat_x = hat_node (hat_K);
457 string gdat_name =
basename +
".gdat";
458 ofstream gdat (gdat_name.c_str());
459 cerr <<
"! file \"" << gdat_name <<
"\" created" << endl;
460 filelist +=
" " + gdat_name;
461 gdat << setprecision(std::numeric_limits<T>::digits10)
462 <<
"# basis " <<
name() << endl
463 <<
"# element " << hat_K.
name() << endl
464 <<
"# degree " << degree() << endl
465 <<
"# ndof " <<
ndof(hat_K) << endl
466 <<
"# raw_poly " << _sopt.get_raw_polynomial_name() << endl
467 <<
"# nodeset " << _sopt.get_node_name() << endl
468 <<
"# nnode " << hat_x.size() << endl
470 for (
size_type loc_sid_inod = 0, loc_sid_nnod = loc_inod.size(); loc_sid_inod < loc_sid_nnod; ++loc_sid_inod) {
471 hat_x [loc_inod[loc_sid_inod]].put (gdat, max(
d,
size_type(2)));
472 gdat <<
" " << loc_inod[loc_sid_inod] << endl;
477 string plot_name =
basename +
".plot";
478 ofstream plot (plot_name.c_str());
479 cerr <<
"! file \"" << plot_name <<
"\" created" << endl;
480 filelist +=
" " + plot_name;
481 plot <<
"gdat = \"" << gdat_name <<
"\"" << endl
482 <<
"set title \"" <<
name() <<
": nodes\"" << endl
484 put_hat_node_header<T> (plot, hat_K) ;
485 string color[4] = {
"#ff0000",
"#008800",
"#0000ff",
"#ff00ff"};
486 bool need_coma =
false;
488 plot << ((
d==3) ?
"s" :
"") <<
"plot \\" << endl
489 <<
" gdat \\" << endl
490 <<
" w p ps 2 pt 7 lc rgb \"" << color[
d] <<
"\",\\" << endl
491 <<
" gdat \\" << endl
492 <<
" u 1:2:3" << ((
d==3) ?
":4" :
"") <<
" w labels offset char 2 lc 0" << endl
493 <<
"pause -1 \"<return>\"" << endl
498 string command =
"gnuplot \"" + plot_name +
"\"";
505 string command =
"/bin/rm -f " + filelist;
513 #define _RHEOLEF_instanciation(T) \
514 template void basis_rep<Float>::put (ostream& os, reference_element hat_K) const; \
515 template void basis_rep<Float>::put_scalar_valued (ostream& os, reference_element hat_K) const; \
516 template void basis_rep<Float>::put_vector_valued (ostream& os, reference_element hat_K) const; \
517 template void basis_rep<Float>::put_hat_node (ostream& os, reference_element hat_K) const; \
518 template void basis_rep<Float>::put_hat_node_on_side ( \
519 std::ostream&, reference_element, const side_information_type&) const;
basis - finite element method
void put(idiststream &in, odiststream &out, bool do_proj, bool do_lumped_mass, bool def_fill_opt, size_type extract_id, const Float &scale_value, const std::pair< Float, Float > &u_range, render_type render)
field::size_type size_type
see the Float page for the full documentation
see the point page for the full documentation
reference_element::size_type size_type
void put_hat_node_on_side(std::ostream &os, reference_element hat_K, const side_information_type &sid) const
void put_hat_node(std::ostream &os, reference_element hat_K) const
virtual void put_vector_valued(std::ostream &os, reference_element hat_K) const
see the reference_element page for the full documentation
const point_basic< Float > & vertex(size_type iloc) const
static const variant_type H
static const variant_type q
static const variant_type e
size_type dimension() const
static const variant_type p
variant_type variant() const
size_type subgeo_local_vertex(size_type subgeo_dim, size_type loc_isid, size_type loc_jsidvert) const
std::vector< int >::size_type size_type
size_type n_subgeo(size_type subgeo_dim) const
static const variant_type T
static const variant_type P
static const variant_type t
check_macro(expr1.have_homogeneous_space(Xh1), "dual(expr1,expr2); expr1 should have homogeneous space. HINT: use dual(interpolate(Xh, expr1),expr2)")
Float delta(Float f, Float g)
void put(const Basis &b, ostream &os, reference_element hat_K)
void basis_on_pointset_evaluate(const Basis &b, const reference_element &hat_K, const Eigen::Matrix< point_basic< T >, Eigen::Dynamic, 1 > &hat_x, Eigen::Matrix< Value, Eigen::Dynamic, Eigen::Dynamic > &vdm)
size_type nnod(const basis_basic< T > &b, const geo_size &gs, size_type map_dim)
size_type ndof(const basis_basic< T > &b, const geo_size &gs, size_type map_dim)
This file is part of Rheolef.
void pointset_lagrange_equispaced(reference_element hat_K, size_t order_in, Eigen::Matrix< point_basic< T >, Eigen::Dynamic, 1 > &hat_xnod, size_t internal=0)
T norm(const vec< T, M > &x)
norm(x): see the expression page for the full documentation
_RHEOLEF_instanciation(Float) _RHEOLEF_instanciation_evaluate(Float
space_constant::valued_type valued_tag() const