Loading...
Searching...
No Matches
basis_visu_gnuplot.icc
Go to the documentation of this file.
#ifndef _RHEOLEF_BASIS_VISU_GNUPLOT_ICC
#define _RHEOLEF_BASIS_VISU_GNUPLOT_ICC
// file automatically generated by: ../../../rheolef/nfem/pbasis/make_basis_list_cxx.sh
#include "rheolef/basis_raw.h"
#include "rheolef/iorheo.h"
#include "rheolef/rheostream.h"
namespace rheolef { namespace details {
using namespace std;
template<class Basis>
void
put (const Basis& b, ostream& os, reference_element hat_K)
{
typedef typename Basis::size_type size_type;
typedef typename Basis::value_type T;
bool verbose = iorheo::getverbose(os);
bool clean = iorheo::getclean(os);
bool execute = iorheo::getexecute(os);
size_type nsub = iorheo::getsubdivide(os);
if (nsub <= 1) nsub = 20; // default value
size_type loc_ndof = reference_element::n_node(hat_K.variant(), b.degree());
string basename = "basis-" + b.name() + "-" + hat_K.name();
string filelist;
// --------------------
// .plot
// --------------------
string plot_name = basename + ".plot";
string gdat_name = basename + ".gdat";
ofstream plot (plot_name.c_str());
cerr << "! file \"" << plot_name << "\" created" << endl;
filelist += " \"" + plot_name + "\"";
size_t d = hat_K.dimension();
check_macro (d==1 || d==2, "unsupported dimension " << d);
plot << "gdat = \"" << gdat_name << "\"" << endl
<< "set colors classic" << endl
<< "set size square" << endl
;
if (d == 1) {
plot << "plot \\" << endl
;
for (size_t loc_idof = 0; loc_idof < loc_ndof; ++loc_idof) {
plot << " gdat u 1:"<<loc_idof+2 << " t \"L" << loc_idof+1 << "\" w l";
if (loc_idof+1 != loc_ndof) {
plot << ",\\";
}
plot << endl;
}
} else if (d == 2) {
plot << "pause_duration = 0.5" << endl
<< "d = 2" << endl
<< "i = d+1" << endl
<< "imax = d+" << loc_ndof << endl
<< "set hidden3d back # offset 1 trianglepattern 3 undefined 1 altdiagonal bentover" << endl
<< "set linetype 1 lw 1 lc rgb \"#000000\"" << endl
<< "set linetype 2 lw 1 lc rgb \"#0000ff\"" << endl
<< "splot gdat u 1:2:i t sprintf(\"P%d\",i-d) w l lc 0" << endl
<< "load \"" << basename << ".loop\"" << endl
;
string loop_name = basename + ".loop";
ofstream loop (loop_name.c_str());
cerr << "! file \"" << loop_name << "\" created" << endl;
filelist += " " + loop_name;
loop << "i = i+1" << endl
<< "if (i <= imax) \\" << endl
<< " pause pause_duration; \\" << endl
<< " replot; \\" << endl
<< " reread" << endl
;
}
plot << "pause -1 \"<return>\"" << endl;
plot.close();
// --------------------
// .gdat
// --------------------
ofstream gdat (gdat_name.c_str());
cerr << "! file \"" << gdat_name << "\" created" << endl;
filelist += " \"" + gdat_name + "\"";
gdat << setprecision(std::numeric_limits<T>::digits10)
<< "# basis " << b.name() << endl
<< "# element " << hat_K.name() << endl
<< "# degree " << b.degree() << endl
;
Eigen::Matrix<T,Eigen::Dynamic,1> value;
switch (hat_K.variant()) {
case reference_element::p: {
break;
}
case reference_element::e: {
gdat << "# size " << loc_ndof << endl
<< "# x";
for (size_t loc_idof = 0; loc_idof < loc_ndof; ++loc_idof) {
gdat << " L" << loc_idof+1;
}
gdat << endl;
for (size_type i = 0; i <= nsub; i++) {
point_basic<T> hat_x (T(int(i))/T(int(nsub)));
b.evaluate (hat_K, hat_x, value);
gdat << hat_x[0];
for (size_t loc_idof = 0, loc_ndof = value.size(); loc_idof < loc_ndof; ++loc_idof) {
gdat << " " << value[loc_idof];
}
gdat << endl;
}
break;
}
case reference_element::t: {
for (size_type j = 0; j <= nsub; j++) {
for (size_type i1 = 0; i1 <= nsub; i1++) {
size_type i = std::min(i1, nsub-j);
point_basic<T> hat_x (T(int(i))/T(int(nsub)), T(int(j))/T(int(nsub)));
b.evaluate (hat_K, hat_x, value);
gdat << hat_x[0] << " " << hat_x[1];
for (size_t loc_idof = 0, loc_ndof = value.size(); loc_idof < loc_ndof; ++loc_idof) {
gdat << " " << value[loc_idof];
}
gdat << endl;
}
gdat << endl;
}
break;
}
case reference_element::q: {
for (size_type j = 0; j <= nsub; j++) {
for (size_type i = 0; i <= nsub; i++) {
point_basic<T> hat_x (2*T(int(i))/T(int(nsub))-1, 2*T(int(j))/T(int(nsub))-1);
b.evaluate (hat_K, hat_x, value);
gdat << hat_x[0] << " " << hat_x[1];
for (size_t loc_idof = 0, loc_ndof = value.size(); loc_idof < loc_ndof; ++loc_idof) {
gdat << " " << value[loc_idof];
}
gdat << endl;
}
gdat << endl;
}
break;
}
#ifdef TODO // 3D visu ?
case reference_element::T: {
for (size_type k = 0; k <= nsub; k++) {
for (size_type j = 0; j+k <= nsub; j++) {
for (size_type i = 0; i+j+k <= nsub; i++) {
point_basic<T> hat_x (T(i)/T(nsub), T(j)/T(nsub), T(k)/T(nsub));
b.eval_lagrange (hat_x, hat_K, degree, sopt, inv_vdm, value);
Lambda = max(Lambda, norm(value,1));
}
}
}
return Lambda;
}
case reference_element::P: {
for (size_type k = 0; k <= degree; k++) {
for (size_type j = 0; j <= degree; j++) {
for (size_type i = 0; i+j <= degree; i++) {
point_basic<T> hat_x (T(i)/T(nsub), T(j)/T(nsub), 2*T(k)/T(nsub)-1);
b.eval_lagrange (hat_x, hat_K, degree, sopt, inv_vdm, value);
Lambda = max(Lambda, norm(value,1));
}
}
}
break;
}
case reference_element::H: {
for (size_type k = 0; k <= degree; k++) {
for (size_type j = 0; j <= degree; j++) {
for (size_type i = 0; i <= degree; i++) {
point_basic<T> hat_x (2*T(i)/T(nsub)-1, 2*T(j)/T(nsub), 2*T(k)/T(nsub)-1);
b.eval_lagrange (hat_x, hat_K, degree, sopt, inv_vdm, value);
Lambda = max(Lambda, norm(value,1));
}
}
}
break;
}
#endif // TODO
default:
error_macro ("unexpected element type `"<<hat_K.name()<<"'");
}
// -----------
if (execute) {
// -----------
string command = "gnuplot \"" + plot_name + "\"";
if (verbose) clog << "! " << command << endl;
int status = system (command.c_str());
}
// -----------
if (clean) {
// -----------
string command = "/bin/rm -f " + filelist;
if (verbose) clog << "! " << command << endl;
int status = system (command.c_str());
}
}
}} // namespace rheolef::details
#endif // _RHEOLEF_BASIS_VISU_GNUPLOT_ICC
size_type
field::size_type size_type
Definition branch.cc:430
rheolef::point_basic
Definition point.h:86
rheolef::reference_element
see the reference_element page for the full documentation
Definition reference_element.h:66
rheolef::reference_element::H
static const variant_type H
Definition reference_element.h:81
rheolef::reference_element::q
static const variant_type q
Definition reference_element.h:78
rheolef::reference_element::e
static const variant_type e
Definition reference_element.h:76
rheolef::reference_element::dimension
size_type dimension() const
Definition reference_element.h:101
rheolef::reference_element::p
static const variant_type p
Definition reference_element.h:75
rheolef::reference_element::variant
variant_type variant() const
Definition reference_element.h:99
rheolef::reference_element::n_node
static size_type n_node(variant_type variant, size_type order)
Definition reference_element.cc:201
rheolef::reference_element::T
static const variant_type T
Definition reference_element.h:79
rheolef::reference_element::P
static const variant_type P
Definition reference_element.h:80
rheolef::reference_element::name
char name() const
Definition reference_element.h:100
rheolef::reference_element::t
static const variant_type t
Definition reference_element.h:77
error_macro
#define error_macro(message)
Definition dis_macros.h:49
T
Expr1::float_type T
Definition field_expr.h:230
check_macro
check_macro(expr1.have_homogeneous_space(Xh1), "dual(expr1,expr2); expr1 should have homogeneous space. HINT: use dual(interpolate(Xh, expr1),expr2)")
rheolef::details::put
void put(const Basis &b, ostream &os, reference_element hat_K)
Definition basis_visu_gnuplot.icc:32
rheolef
This file is part of Rheolef.
Definition compiler_eigen.h:39
rheolef::norm
T norm(const vec< T, M > &x)
norm(x): see the expression page for the full documentation
Definition vec.h:387
std
STL namespace.
d
size_t d
Definition neumann-laplace-lambda.cc:28