Ejemplo n.º 1
0
void divx_test() {
  char bufx[128];
  char bufq[128];
  printf("def dtest(x,y,q,r,o1,o2)\n    xx=q*y+r;\n    msg=\"x=#{x} y=#{y} q=#{q} r=#{r} xx=#{xx} o1=#{o1} o2=#{o2}\"\n    puts(msg + \" val\") if (x != xx);\n    puts(msg + \" overflow\") if (o1 != 0 || o2 != 0);\nend\n\n");
  fflush(stdout);
  for (uint128 xh = 1; xh > 0; xh <<= 1) {
    for (uint64 yh = 1; yh > 0; yh <<= 1) {
      for (uint128 xl = 0; xl <= 5; xl++) {
        uint128 x = xh + xl - 1;
        for (uint64 yl = 0; yl <= 5; yl++) {
          uint64 y = yh + yl - 1;
          if (y == 0) {
            continue;
          }
          uint128 x1 = upper(x);
          unsigned_divx_result z1 = divx(x1, y);
          uint128 x2 = combine(z1.remainder, lower(x));
          unsigned_divx_result z2 = divx(x2, y);
          uint128 q = combine(z1.quotient, z2.quotient);
          uint64  r = z2.remainder;
          sprint_uint128_hex(bufx, x);
          sprint_uint128_hex(bufq, q);
          printf("x=0x%s; y=%llu; q=0x%s; r=%llu; o1=%d; o2=%d;\ndtest(x,y,q,r,o1,o2);\n", bufx, y, bufq, r, z1.overflow, z2.overflow);
          fflush(stdout);
        }
      }
    }
  }
}
Ejemplo n.º 2
0
void ISOP2P1::outputTecplot(const std::string &prefix)
{
	/// 计算速度单元上的涡量和散度.
        computeDiv_and_Vor();
	RegularMesh<DIM> &mesh_p = irregular_mesh_p->regularMesh();
	RegularMesh<DIM> &mesh_v = irregular_mesh_v->regularMesh();
	int n_node = mesh_v.n_geometry(0);
	int n_ele = mesh_v.n_geometry(2);

	FEMFunction <double, DIM> p_h_refine(fem_space_v);
	Operator::L2Interpolate(p_h, p_h_refine);

	/// 减掉均值.
	p_h_refine.add(-Functional::meanValue(p_h_refine, 3));

	DiVx divx(viscosity, t);
	DiVy divy(viscosity, t);
	// RealVx divx;
	// RealVy divy;
	std::stringstream result;
	result.setf(std::ios::fixed);
	result.precision(4);
	result << prefix << ".dat";
	std::ofstream tecplot(result.str().c_str());
	tecplot.setf(std::ios::fixed);
	tecplot.precision(20);
	tecplot << "VARIABLES = \"X\", \"Y\", \"P\", \"U\", \"V\", \"L2Error\", \"divergence\", \"vorticity\"";
	tecplot << std::endl;
	tecplot << "ZONE NODES=" << n_node << ", ELEMENTS=" << n_ele << ", DATAPACKING=BLOCK," << std::endl;
	tecplot << "VARLOCATION=([6, 7]=CELLCENTERED)," << "ZONETYPE=FETRIANGLE" << std::endl;
	for (int i = 0; i < n_node; ++i)
		tecplot << mesh_v.point(i)[0] << "\n";
	tecplot << std::endl;
	for (int i = 0; i < n_node; ++i)
		tecplot << mesh_v.point(i)[1] << "\n";
	tecplot << std::endl;
	for (int i = 0; i < n_node; ++i)
		tecplot << p_h_refine(i) << "\n";
	tecplot << std::endl;
	for (int i = 0; i < n_node; ++i)
		tecplot << v_h[0](i) << "\n";
	tecplot << std::endl;
	for (int i = 0; i < n_node; ++i)
		tecplot << v_h[1](i) << "\n";
	tecplot << std::endl;
//	for (int i = 0; i < n_node; ++i)
//	{
//		double error = fabs(divx.value(mesh_v.point(i)) - v_h[0](i));
//		tecplot << error << "\n";
//	}
//	for (int i = 0; i < n_node; ++i)
//	{
//		double error = fabs(divy.value(mesh_v.point(i)) - v_h[1](i));
//		tecplot << error << "\n";
//	}
	for (int i = 0; i < n_ele; ++i)
		tecplot << err_ele[i] << "\n";
	tecplot << std::endl;
	for (int i = 0; i < n_ele; ++i)
		tecplot << divergence[i] << "\n";
	tecplot << std::endl;
	for (int i = 0; i < n_node; ++i)
		tecplot << vorticity(i) << "\n";
	tecplot << std::endl;

	for (int i = 0; i < n_ele; ++i)
	{
		std::vector<int> &vtx =  fem_space_v.element(i).geometry().vertex();
		tecplot << vtx[0] + 1 << "\n" << vtx[1] + 1 << "\n" << vtx[2] + 1 << std::endl;
	}
	tecplot.close();
};