예제 #1
0
TEST(Boundary, index_boundary) {
	//
	const st dim = 2;
	// new shape--------------------
	Shape2D shape;
	CreatCircle(shape, 0.001, 0.001, 1.503, 10);
	//Float x1 = 1.5, y1 = 1.5, x2 = 3.5, y2 = 3.5;
	//CreatCube(shape, x1, y1, x2, y2);
	// shape is out bound
	// define unit length
	Float UL = 1.5;
	// build grid ------------------
	Domain_<Float, Float, dim> domain(&shape, UL, 3, 4);
	domain.build();
	// show ================================
	std::list<Gnuplot_actor> lga;
	Gnuplot_actor ga;
	GnuplotActor_LeafNodes(ga, domain.grid());
	lga.push_back(ga);
	GnuplotActor_GhostNodes(ga, domain.ghost());
	lga.push_back(ga);
	GnuplotActor_GhostNodesContour_BoundaryIndex(ga, domain.ghost());
	lga.push_back(ga);
	GnuplotActor_Shape2D(ga, shape, 0);
	lga.push_back(ga);

	Gnuplot gp;
	gp.set_equal_ratio();
	gp.plot(lga);
	//delete shape
}
예제 #2
0
inline void show_value_on_line(Domain_<Float, Float, 2>& domain, Axes aix,
		Float v, st i) {
	typedef Domain_<Float, Float, 2> Domain;
	typedef Domain_<Float, Float, 2>::pNode pNode;
	std::list<Gnuplot_actor> lga;
	Gnuplot_actor ga;

	//GnuplotActor_GhostNodesContours(ga, domain.ghost(), 4);
	//lga.push_back(ga);
	//GnuplotActor_GhostNodesDataIndex(ga, domain.ghost());
	//lga.push_back(ga);
	//GnuplotActor_LeafNodes(ga, domain.grid(), 4);
	//lga.push_back(ga);
	std::list<pNode> lpn = domain.grid().get_leaf(aix, v);

	GnuplotActor_NodesValues(ga, lpn, i, VerticalAxes2D(aix));
	//GnuplotActor_NodesContours(ga, lpn, 4);
	lga.push_back(ga);
	//GnuplotActor_LeafNodes(ga, domain.grid());
	//lga.push_back(ga);
	//GnuplotActor_Shape2D(ga, shape, 0);
	//lga.push_back(ga);
	Gnuplot gp;
	//gp.set_equal_ratio();
	gp.plot(lga);
}
예제 #3
0
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);
}
예제 #4
0
void test_2_run(int level, Float& e1, Float& e2, Float& e3) {
	const st dim = 2;
	// new shape--------------------
	Shape2D shape;
	Shape2D cir;
	//CreatCircle(cir, 2.1, 2.1, 0.8, 359);
	Float x1 = -0.5, y1 = -0.5, x2 = 0.5, y2 = 0.5;
	CreatCube(shape, x1, y1, x2, y2);
	// define unit length
	Float UL = 1.0;
	// build grid ------------------
	Domain_<Float, Float, dim> domain(&shape, UL, level, level + 1);
	//domain.adaptive().adapt_shape_boundary(cir);
	domain.build();
	//domain.new_data(4,0,0,0); // idx = 3 used for exact
	//domain.set_val(3,exact_fun_2);
	Poisson_<Float, Float, dim> poisson(&domain);
	poisson.set_beta(coe_set_b);
	poisson.set_f(f_fun_2);
	// set exact
	domain.set_val(0, exact_fun_2);
	// boundary condition
	Poisson_<Float, Float, dim>::BoundaryCondition bc;
	//bc.set_default_1_bc(exact_fun_2);
	poisson.set_boundary_condition(0, 0, poisson.phi_idx(), &bc);
	poisson.set_boundary_condition(0, 1, poisson.phi_idx(), &bc);
	poisson.set_boundary_condition(0, 2, poisson.phi_idx(), &bc);
	poisson.set_boundary_condition(0, 3, poisson.phi_idx(), &bc);
	std::cout << "solve -----------\n";
	poisson.solve();
	cout << "end solve -------\n";
	e1 = error_1(domain, 2, 0);
	e2 = error_2(domain, 2, 0);
	e3 = error_i(domain, 2, 0);
	//cout << "error 1  " << e1 << "\n";
	//cout << "error 2  " << e2 << "\n";
	//cout << "error 3  " << e3 << "\n";
	// show ================================
	GnuplotActor::list_spActor lga;
	lga.push_back(
			GnuplotActor::LeafNodesContour(domain.grid(), poisson.phi_idx()));
	lga.push_back(
			GnuplotActor::GhostNodesContours(domain.ghost(),
					poisson.phi_idx()));
	lga.push_back(GnuplotActor::Shape(shape, 0));
	Gnuplot gp;
	gp.set_equal_ratio();
	//gp.set_xrange(2.0,3.0);
	//gp.set_yrange(1.5,2.5);
	//gp.set_cbrange(-2.0, 2.0);
	gp.plot(lga);
	//delete shape
}
예제 #5
0
inline void show_veo_field(Domain& d, st idxu, st idxv) {
	std::list<Gnuplot_actor> lga;
	Gnuplot_actor ga;
	GnuplotActor_Velocity_field(ga, d.grid(), idxu, idxv, 1);
	lga.push_back(ga);
	GnuplotActor_LeafNodes(ga, d.grid());
	lga.push_back(ga);

	//sga.show_data();
	Gnuplot gp;
	gp.set_equal_ratio();
	//sgp.set_view(45, 10, 1, 1);
	gp.set_palette_blue_red();
	//sgp.set("ticslevel 0");
	//sgp.set_xrange(1.4, 2.0);
	//sgp.set_yrange(1.4, 2.0);
	gp.plot(lga);
}
예제 #6
0
void test_adp_boundary() {
	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();
    //g.show_info();
	// 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.0, 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);
	g.connect_nodes();
	// boundary ====
	Ghost_<Float, Float, 2> ghost(&g);

	// 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_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);
}
예제 #7
0
inline void show_plot_contour(Domain& d, st idx, std::string title = "") {
	std::list<Gnuplot_actor> lga;
	Gnuplot_actor ga;
	GnuplotActor_LeafNodesContours(ga, d.grid(), idx);
	//GnuplotActor_NodesSurface(sga, pn, 0);
	lga.push_back(ga);
	GnuplotActor_GhostNodesContours(ga, d.ghost(), idx);
	lga.push_back(ga);
	//sga.show_data();
	Gnuplot gp;
	gp.set_title(title);
	//sgp.set_equal_ratio();
	//sgp.set_view(45, 10, 1, 1);
	gp.set_palette_blue_red();
	//sgp.set("ticslevel 0");
	//sgp.set_xrange(1.4, 2.0);
	//sgp.set_yrange(1.4, 2.0);
	gp.plot(lga);
}
예제 #8
0
TEST(DISABLED_Boundary, inner_soild) {
	//
	const st dim = 2;
	// new shape--------------------
	Shape2D shape;
	CreatCircle(shape, 0.001, 0.001, 1.501, 10);

	Shape2D inner_shape;
	CreatCircle(inner_shape, 0.4, 0.6, 0.4, 3);
	std::list<Shape2D*> lis;
	lis.push_back(&inner_shape);
	Shape2D inner_shape2;
	CreatCircle(inner_shape2, .5, -0.1, 0.3, 6);
	lis.push_back(&inner_shape2);
	//Float x1 = 1.5, y1 = 1.5, x2 = 3.5, y2 = 3.5;
	//CreatCube(shape, x1, y1, x2, y2);
	// shape is out bound
	// define unit length
	Float UL = 1.0;
	// build grid ------------------
	Domain_<Float, Float, dim> domain(&shape, lis, UL, 2, 4);
	domain.build();
	// show ================================
	std::list<Gnuplot_actor> lga;
	Gnuplot_actor ga;
	GnuplotActor_LeafNodes(ga, domain.grid());
	lga.push_back(ga);
	GnuplotActor_GhostNodes(ga, domain.ghost());
	lga.push_back(ga);
	GnuplotActor_GhostNodesContour_BoundaryIndex(ga, domain.ghost());
	lga.push_back(ga);
	GnuplotActor_Shape2D(ga, shape, 0);
	lga.push_back(ga);

	Gnuplot gp;
	gp.set_equal_ratio();
	gp.plot(lga);
	//delete shape
}
예제 #9
0
// ----------------------------------------------------------------------
bool ShowPopulation(Gnuplot &gplot, const CPopulation &pop, const std::string &legend)
{
	if (!SaveToFile(legend, pop, ios_base::out)) return false;

	size_t n = 0;
#ifdef OUTPUT_DECISION_VECTOR
	n = pop[0].vars().size();
#endif
	
	if (pop[0].objs().size() == 2)
	{
		gplot.plot(legend, n+1, n+2);
		return true;
	}
	else if (pop[0].objs().size() == 3)
	{
		gplot.splot(legend, n+1, n+2, n+3);
		return true;
	}
	else // only plot 2-D or 3-D figures
		return false;
}