void test_adapt_vof() { //jan 13, 2016 std::cout << "test adapt initial vof ================\n"; Grid_<Float, Float, 2> g(4, -2.0, 1, // 4, -2.0, 1); g.connect_root(); std::cout << "num root : " << g.get_num_root() << std::endl; Adaptive_<Float, Float, 2> adp(&g, 2, 5); //adp.adapt_full(); // shape Shape2D cir; CreatCircle(cir, 0.0, 0.0, 1.0, 359); adp.adapt_inner_solid(cir); // ============================== // shape for vof Shape2D cir2; CreatCircle(cir2, 0.7, 0.0, 1.5, 359); adp.adapt_vof(cir2); g.new_data_on_leaf(1, 0, 0, 1); Vof_<Float, Float, 2> vof(&g, 0, 0); vof.set_color(cir2); //stencil ============================== Float x = 1.0; Float y = 1.48; Float z = 0.0; Grid_<Float, Float, 2>::pNode pn = nullptr; pn = g.get_pnode(x, y, z); Stencil_2D2 st(pn, _X_, 1, 1, _Y_, 1, 1); typename Vof_<Float, Float, 2>::Matrix3_3 mat; vof.get_matrix(mat, st); Float mx = 0; Float my = 0; vof.cal_norm_Young(mat, mx, my); mat.show(); std::cout << "vector x = " << mx << " y = " << my << std::endl; vof.construct_segments(); // show ================================ std::list<Gnuplot_actor> lga; Gnuplot_actor ga; //GnuplotActor_LeafNodesContours(ga, g, 0); //lga.push_back(ga); GnuplotActor_LeafNodes(ga, g); lga.push_back(ga); //GnuplotActor_Shape2D(ga, cir); //lga.push_back(ga); //GnuplotActor_Shape2D(ga, cir2); //lga.push_back(ga); GnuplotActor_Stencil(ga, st); lga.push_back(ga); GnuplotActor_StencilContour(ga, st, 0); lga.push_back(ga); GnuplotActor_Vof2D(ga, vof); lga.push_back(ga); Gnuplot gp; gp.set_equal_ratio(); gp.set_xrange(-1.5, 0); gp.set_yrange(0, 1.5); gp.plot(lga); }
void rysuj() { Gnuplot mainPlot; mainPlot.set_style("lines"); //styl rysowania wykresu mainPlot.set_grid(); //siatka poprawiająca czytelnosc mainPlot.set_xrange(rangeStart, rangeEnd); //zakres osi x wg. zadanych wartoœci mainPlot.plot_xy(functionX, functionY, "Funkcja aproksymowana"); mainPlot.set_style("lines"); //styl rysowania wykresu mainPlot.set_grid(); //siatka poprawiająca czytelnoœæ mainPlot.set_xrange(rangeStart, rangeEnd); //zakres osi x wg. zadanych wartoœci mainPlot.plot_xy(functionX, approximationY, "Funkcja aproksymujaca"); getchar(); system("PAUSE"); }
void print_step_function(Gnuplot & plot , const step_function & function, std::string label,bool svg) { try{ std::ostringstream function_string; auto i = function.step_values.begin(); auto j = ++function.step_values.begin(); for (;j != function.step_values.end();i++,j++) { function_string << "((x>=" << i->first << ")&&(x<" << j->first << "))? "; function_string << i->second; function_string << ":"; } function_string << "((x>=" << i->first << ")&&(x<" << i->first + (i->first/10) << "))?"; function_string << i->second; function_string << ": 1/0"; if(svg) { plot << "set terminal svg fname 'Verdana' fsize 10 "; plot << "set object 1 rect from screen 0, 0, 0 to screen 1, 1, 0 behind"; plot << "set object 1 rect fc rgb \"white\" fillstyle solid 1.0"; std::string output("set output '"); output += label; output += ".svg'"; plot << output; } else { plot << "set term wxt"; } plot.set_style("fsteps"); plot.set_xrange(0,i->first + (i->first/10)); plot.set_yautoscale(); plot.set_xlabel("Position [m]"); plot.set_ylabel("Acceleration [m/s²]"); plot.plot_equation(function_string.str(),label); } catch (const GnuplotException & e) { std::cout << "Error while plotting with Gnuplot (" << e.what() <<")" << std::endl; } }