Пример #1
0
int
main(int argc, char **argv)
{
  pcurve2d  gr;
  pamatrix  Vfull, KMfull;
  pbem2d    bem_slp, bem_dlp;
  pcluster  root;
  pblock block;
  phmatrix  V, KM;
  pclusterbasis Vrb, Vcb, KMrb, KMcb;
  ph2matrix V2, KM2;
  uint      n, q, clf, m, l;
  real      eta, delta, eps_aca;

  init_h2lib(&argc, &argv);

  n = 579;
  q = 2;
  clf = 16;
  eta = 1.0;

  gr = new_circle_curve2d(n, 0.333);
  bem_slp = new_slp_laplace_bem2d(gr, q, BASIS_CONSTANT_BEM2D);
  bem_dlp = new_dlp_laplace_bem2d(gr, q, BASIS_CONSTANT_BEM2D,
				  BASIS_CONSTANT_BEM2D, 0.5);
  root = build_bem2d_cluster(bem_slp, clf, BASIS_CONSTANT_BEM2D);
  block = build_nonstrict_block(root, root, &eta, admissible_max_cluster);

  Vfull = new_amatrix(n, n);
  KMfull = new_amatrix(n, n);
  bem_slp->nearfield(NULL, NULL, bem_slp, false, Vfull);
  bem_dlp->nearfield(NULL, NULL, bem_dlp, false, KMfull);

  V = build_from_block_hmatrix(block, 0);
  KM = build_from_block_hmatrix(block, 0);

  printf("----------------------------------------\n");
  printf("Testing inner Boundary integral equations:\n");
  printf("----------------------------------------\n\n");

  /*
   * Test Interpolation
   */

  m = 9;

  setup_hmatrix_aprx_inter_row_bem2d(bem_slp, root, root, block, m);
  setup_hmatrix_aprx_inter_row_bem2d(bem_dlp, root, root, block, m);
  test_hmatrix_system("Interpolation row", Vfull, KMfull, block, bem_slp, V,
		      bem_dlp, KM, false);

  setup_hmatrix_aprx_inter_col_bem2d(bem_slp, root, root, block, m);
  setup_hmatrix_aprx_inter_col_bem2d(bem_dlp, root, root, block, m);
  test_hmatrix_system("Interpolation column", Vfull, KMfull, block, bem_slp,
		      V, bem_dlp, KM, false);

  setup_hmatrix_aprx_inter_mixed_bem2d(bem_slp, root, root, block, m);
  setup_hmatrix_aprx_inter_mixed_bem2d(bem_dlp, root, root, block, m);
  test_hmatrix_system("Interpolation mixed", Vfull, KMfull, block, bem_slp, V,
		      bem_dlp, KM, false);

  /*
   * Test Green
   */

  m = 10;
  l = 2;
  delta = 0.5;

  setup_hmatrix_aprx_green_row_bem2d(bem_slp, root, root, block, m, l, delta,
				     build_bem2d_rect_quadpoints);
  setup_hmatrix_aprx_green_row_bem2d(bem_dlp, root, root, block, m, l, delta,
				     build_bem2d_rect_quadpoints);
  test_hmatrix_system("Green row", Vfull, KMfull, block, bem_slp, V, bem_dlp,
		      KM, false);

  setup_hmatrix_aprx_green_col_bem2d(bem_slp, root, root, block, m, l, delta,
				     build_bem2d_rect_quadpoints);
  setup_hmatrix_aprx_green_col_bem2d(bem_dlp, root, root, block, m, l, delta,
				     build_bem2d_rect_quadpoints);
  test_hmatrix_system("Green column", Vfull, KMfull, block, bem_slp, V,
		      bem_dlp, KM, false);

  setup_hmatrix_aprx_green_mixed_bem2d(bem_slp, root, root, block, m, l,
				       delta, build_bem2d_rect_quadpoints);
  setup_hmatrix_aprx_green_mixed_bem2d(bem_dlp, root, root, block, m, l,
				       delta, build_bem2d_rect_quadpoints);
  test_hmatrix_system("Green mixed", Vfull, KMfull, block, bem_slp, V,
		      bem_dlp, KM, false);

  /*
   * Test Greenhybrid
   */

  m = 3;
  l = 1;
  delta = 1.0;
  eps_aca = 1.0e-7;

  setup_hmatrix_aprx_greenhybrid_row_bem2d(bem_slp, root, root, block, m, l,
					   delta, eps_aca,
					   build_bem2d_rect_quadpoints);
  setup_hmatrix_aprx_greenhybrid_row_bem2d(bem_dlp, root, root, block, m, l,
					   delta, eps_aca,
					   build_bem2d_rect_quadpoints);
  test_hmatrix_system("Greenhybrid row", Vfull, KMfull, block, bem_slp, V,
		      bem_dlp, KM, false);

  setup_hmatrix_aprx_greenhybrid_col_bem2d(bem_slp, root, root, block, m, l,
					   delta, eps_aca,
					   build_bem2d_rect_quadpoints);
  setup_hmatrix_aprx_greenhybrid_col_bem2d(bem_dlp, root, root, block, m, l,
					   delta, eps_aca,
					   build_bem2d_rect_quadpoints);
  test_hmatrix_system("Greenhybrid column", Vfull, KMfull, block, bem_slp, V,
		      bem_dlp, KM, false);

  setup_hmatrix_aprx_greenhybrid_mixed_bem2d(bem_slp, root, root, block, m, l,
					     delta, eps_aca,
					     build_bem2d_rect_quadpoints);
  setup_hmatrix_aprx_greenhybrid_mixed_bem2d(bem_dlp, root, root, block, m, l,
					     delta, eps_aca,
					     build_bem2d_rect_quadpoints);
  test_hmatrix_system("Greenhybrid mixed", Vfull, KMfull, block, bem_slp, V,
		      bem_dlp, KM, false);

  /*
   * Test ACA / PACA / HCA
   */

  m = 4;
  eps_aca = 1.0e-6;

  setup_hmatrix_aprx_aca_bem2d(bem_slp, root, root, block, eps_aca);
  setup_hmatrix_aprx_aca_bem2d(bem_dlp, root, root, block, eps_aca);
  test_hmatrix_system("ACA full pivoting", Vfull, KMfull, block, bem_slp, V,
		      bem_dlp, KM, false);

  setup_hmatrix_aprx_paca_bem2d(bem_slp, root, root, block, eps_aca);
  setup_hmatrix_aprx_paca_bem2d(bem_dlp, root, root, block, eps_aca);
  test_hmatrix_system("ACA partial pivoting", Vfull, KMfull, block, bem_slp,
		      V, bem_dlp, KM, false);

  setup_hmatrix_aprx_hca_bem2d(bem_slp, root, root, block, m, eps_aca);
  setup_hmatrix_aprx_hca_bem2d(bem_dlp, root, root, block, m, eps_aca);
  test_hmatrix_system("HCA2", Vfull, KMfull, block, bem_slp, V, bem_dlp, KM,
		      false);

  /*
   * H2-matrix
   */

  del_hmatrix(V);
  del_hmatrix(KM);
  del_block(block);

  block = build_strict_block(root, root, &eta, admissible_max_cluster);

  Vrb = build_from_cluster_clusterbasis(root);
  Vcb = build_from_cluster_clusterbasis(root);
  KMrb = build_from_cluster_clusterbasis(root);
  KMcb = build_from_cluster_clusterbasis(root);

  V2 = build_from_block_h2matrix(block, Vrb, Vcb);
  KM2 = build_from_block_h2matrix(block, KMrb, KMcb);

  /*
   * Test Interpolation
   */

  m = 9;

  setup_h2matrix_aprx_inter_bem2d(bem_slp, Vrb, Vcb, block, m);
  setup_h2matrix_aprx_inter_bem2d(bem_dlp, KMrb, KMcb, block, m);
  test_h2matrix_system("Interpolation", Vfull, KMfull, block, bem_slp, V2,
		       bem_dlp, KM2, false);

  /*
   * Test Greenhybrid
   */

  m = 3;
  l = 1;
  delta = 1.0;
  eps_aca = 1.0e-7;

  setup_h2matrix_aprx_greenhybrid_bem2d(bem_slp, Vrb, Vcb, block, m, l, delta,
					eps_aca, build_bem2d_rect_quadpoints);
  setup_h2matrix_aprx_greenhybrid_bem2d(bem_dlp, KMrb, KMcb, block, m, l,
					delta, eps_aca,
					build_bem2d_rect_quadpoints);
  test_h2matrix_system("Greenhybrid", Vfull, KMfull, block, bem_slp, V2,
		       bem_dlp, KM2, false);

  setup_h2matrix_aprx_greenhybrid_ortho_bem2d(bem_slp, Vrb, Vcb, block, m, l,
					      delta, eps_aca,
					      build_bem2d_rect_quadpoints);
  setup_h2matrix_aprx_greenhybrid_ortho_bem2d(bem_dlp, KMrb, KMcb, block, m,
					      l, delta, eps_aca,
					      build_bem2d_rect_quadpoints);
  test_h2matrix_system("Greenhybrid ortho", Vfull, KMfull, block, bem_slp, V2,
		       bem_dlp, KM2, false);

  del_h2matrix(V2);
  del_h2matrix(KM2);
  del_block(block);
  del_bem2d(bem_dlp);

  printf("----------------------------------------\n");
  printf("Testing outer Boundary integral equations:\n");
  printf("----------------------------------------\n\n");

  bem_dlp = new_dlp_laplace_bem2d(gr, q, BASIS_CONSTANT_BEM2D,
				  BASIS_CONSTANT_BEM2D, -0.5);
  block = build_nonstrict_block(root, root, &eta, admissible_max_cluster);
  bem_dlp->nearfield(NULL, NULL, bem_dlp, false, KMfull);

  V = build_from_block_hmatrix(block, 0);
  KM = build_from_block_hmatrix(block, 0);

  /*
   * Test Interpolation
   */

  m = 9;

  setup_hmatrix_aprx_inter_row_bem2d(bem_slp, root, root, block, m);
  setup_hmatrix_aprx_inter_row_bem2d(bem_dlp, root, root, block, m);
  test_hmatrix_system("Interpolation row", Vfull, KMfull, block, bem_slp, V,
		      bem_dlp, KM, true);

  setup_hmatrix_aprx_inter_col_bem2d(bem_slp, root, root, block, m);
  setup_hmatrix_aprx_inter_col_bem2d(bem_dlp, root, root, block, m);
  test_hmatrix_system("Interpolation column", Vfull, KMfull, block, bem_slp,
		      V, bem_dlp, KM, true);

  setup_hmatrix_aprx_inter_mixed_bem2d(bem_slp, root, root, block, m);
  setup_hmatrix_aprx_inter_mixed_bem2d(bem_dlp, root, root, block, m);
  test_hmatrix_system("Interpolation mixed", Vfull, KMfull, block, bem_slp, V,
		      bem_dlp, KM, true);

  /*
   * Test Green
   */

  m = 10;
  l = 2;
  delta = 0.5;

  setup_hmatrix_aprx_green_row_bem2d(bem_slp, root, root, block, m, l, delta,
				     build_bem2d_rect_quadpoints);
  setup_hmatrix_aprx_green_row_bem2d(bem_dlp, root, root, block, m, l, delta,
				     build_bem2d_rect_quadpoints);
  test_hmatrix_system("Green row", Vfull, KMfull, block, bem_slp, V, bem_dlp,
		      KM, true);

  setup_hmatrix_aprx_green_col_bem2d(bem_slp, root, root, block, m, l, delta,
				     build_bem2d_rect_quadpoints);
  setup_hmatrix_aprx_green_col_bem2d(bem_dlp, root, root, block, m, l, delta,
				     build_bem2d_rect_quadpoints);
  test_hmatrix_system("Green column", Vfull, KMfull, block, bem_slp, V,
		      bem_dlp, KM, true);

  setup_hmatrix_aprx_green_mixed_bem2d(bem_slp, root, root, block, m, l,
				       delta, build_bem2d_rect_quadpoints);
  setup_hmatrix_aprx_green_mixed_bem2d(bem_dlp, root, root, block, m, l,
				       delta, build_bem2d_rect_quadpoints);
  test_hmatrix_system("Green mixed", Vfull, KMfull, block, bem_slp, V,
		      bem_dlp, KM, true);

  /*
   * Test Greenhybrid
   */

  m = 3;
  l = 1;
  delta = 1.0;
  eps_aca = 1.0e-7;

  setup_hmatrix_aprx_greenhybrid_row_bem2d(bem_slp, root, root, block, m, l,
					   delta, eps_aca,
					   build_bem2d_rect_quadpoints);
  setup_hmatrix_aprx_greenhybrid_row_bem2d(bem_dlp, root, root, block, m, l,
					   delta, eps_aca,
					   build_bem2d_rect_quadpoints);
  test_hmatrix_system("Greenhybrid row", Vfull, KMfull, block, bem_slp, V,
		      bem_dlp, KM, true);

  setup_hmatrix_aprx_greenhybrid_col_bem2d(bem_slp, root, root, block, m, l,
					   delta, eps_aca,
					   build_bem2d_rect_quadpoints);
  setup_hmatrix_aprx_greenhybrid_col_bem2d(bem_dlp, root, root, block, m, l,
					   delta, eps_aca,
					   build_bem2d_rect_quadpoints);
  test_hmatrix_system("Greenhybrid column", Vfull, KMfull, block, bem_slp, V,
		      bem_dlp, KM, true);

  setup_hmatrix_aprx_greenhybrid_mixed_bem2d(bem_slp, root, root, block, m, l,
					     delta, eps_aca,
					     build_bem2d_rect_quadpoints);
  setup_hmatrix_aprx_greenhybrid_mixed_bem2d(bem_dlp, root, root, block, m, l,
					     delta, eps_aca,
					     build_bem2d_rect_quadpoints);
  test_hmatrix_system("Greenhybrid mixed", Vfull, KMfull, block, bem_slp, V,
		      bem_dlp, KM, true);

  /*
   * Test ACA / PACA / HCA
   */

  m = 4;
  eps_aca = 1.0e-6;

  setup_hmatrix_aprx_aca_bem2d(bem_slp, root, root, block, eps_aca);
  setup_hmatrix_aprx_aca_bem2d(bem_dlp, root, root, block, eps_aca);
  test_hmatrix_system("ACA full pivoting", Vfull, KMfull, block, bem_slp, V,
		      bem_dlp, KM, true);

  setup_hmatrix_aprx_paca_bem2d(bem_slp, root, root, block, eps_aca);
  setup_hmatrix_aprx_paca_bem2d(bem_dlp, root, root, block, eps_aca);
  test_hmatrix_system("ACA partial pivoting", Vfull, KMfull, block, bem_slp,
		      V, bem_dlp, KM, true);

  setup_hmatrix_aprx_hca_bem2d(bem_slp, root, root, block, m, eps_aca);
  setup_hmatrix_aprx_hca_bem2d(bem_dlp, root, root, block, m, eps_aca);
  test_hmatrix_system("HCA2", Vfull, KMfull, block, bem_slp, V, bem_dlp, KM,
		      true);

  /*
   * H2-matrix
   */

  del_hmatrix(V);
  del_hmatrix(KM);
  del_block(block);

  block = build_strict_block(root, root, &eta, admissible_max_cluster);

  Vrb = build_from_cluster_clusterbasis(root);
  Vcb = build_from_cluster_clusterbasis(root);
  KMrb = build_from_cluster_clusterbasis(root);
  KMcb = build_from_cluster_clusterbasis(root);

  V2 = build_from_block_h2matrix(block, Vrb, Vcb);
  KM2 = build_from_block_h2matrix(block, KMrb, KMcb);

  /*
   * Test Interpolation
   */

  m = 9;

  setup_h2matrix_aprx_inter_bem2d(bem_slp, Vrb, Vcb, block, m);
  setup_h2matrix_aprx_inter_bem2d(bem_dlp, KMrb, KMcb, block, m);
  test_h2matrix_system("Interpolation", Vfull, KMfull, block, bem_slp, V2,
		       bem_dlp, KM2, true);

  /*
   * Test Greenhybrid
   */

  m = 3;
  l = 1;
  delta = 1.0;
  eps_aca = 1.0e-7;

  setup_h2matrix_aprx_greenhybrid_bem2d(bem_slp, Vrb, Vcb, block, m, l, delta,
					eps_aca, build_bem2d_rect_quadpoints);
  setup_h2matrix_aprx_greenhybrid_bem2d(bem_dlp, KMrb, KMcb, block, m, l,
					delta, eps_aca,
					build_bem2d_rect_quadpoints);
  test_h2matrix_system("Greenhybrid", Vfull, KMfull, block, bem_slp, V2,
		       bem_dlp, KM2, true);

  setup_h2matrix_aprx_greenhybrid_ortho_bem2d(bem_slp, Vrb, Vcb, block, m, l,
					      delta, eps_aca,
					      build_bem2d_rect_quadpoints);
  setup_h2matrix_aprx_greenhybrid_ortho_bem2d(bem_dlp, KMrb, KMcb, block, m,
					      l, delta, eps_aca,
					      build_bem2d_rect_quadpoints);
  test_h2matrix_system("Greenhybrid Ortho", Vfull, KMfull, block, bem_slp, V2,
		       bem_dlp, KM2, true);

  del_h2matrix(V2);
  del_h2matrix(KM2);
  del_block(block);
  freemem(root->idx);
  del_cluster(root);
  del_bem2d(bem_slp);
  del_bem2d(bem_dlp);
  del_amatrix(Vfull);
  del_amatrix(KMfull);
  del_curve2d(gr);

  (void) printf("----------------------------------------\n"
		"  %u matrices and\n"
		"  %u vectors still active\n"
		"  %u errors found\n", getactives_amatrix(),
		getactives_avector(), problems);

  uninit_h2lib();

  return problems;
}
Пример #2
0
int
main(int argc, char **argv)
{
  pmacrosurface3d mg;
  psurface3d gr;
  pamatrix  Vfull, KMfull;
  pbem3d    bem_slp, bem_dlp;
  pcluster  root;
  pblock block;
  phmatrix  V, KM;
  pclusterbasis Vrb, Vcb, KMrb, KMcb;
  ph2matrix V2, KM2;
  uint      n, q, clf, m, l;
  real      eta, delta, eps_aca;
  field     kvec[3];
  cl_device_id *devices;
  cl_uint   ndevices;
  uint     *idx;
  uint      i;

  init_h2lib(&argc, &argv);

  get_opencl_devices(&devices, &ndevices);
  ndevices = 1;
  set_opencl_devices(devices, ndevices, 2);

  kvec[0] = 2.0, kvec[1] = 0.0, kvec[2] = 0.0;
  n = 512;
  q = 2;
  clf = 16;
  eta = 1.0;

  mg = new_sphere_macrosurface3d();
  gr = build_from_macrosurface3d_surface3d(mg, REAL_SQRT(n * 0.125));
  n = gr->triangles;

  printf("Testing unit sphere with %d triangles\n", n);

  bem_slp = new_slp_helmholtz_ocl_bem3d(kvec, gr, q, q + 2,
					BASIS_CONSTANT_BEM3D);
  bem_dlp = new_dlp_helmholtz_ocl_bem3d(kvec, gr, q, q + 2,
					BASIS_CONSTANT_BEM3D,
					BASIS_CONSTANT_BEM3D, 0.5);
  root = build_bem3d_cluster(bem_slp, clf, BASIS_CONSTANT_BEM3D);
  block = build_nonstrict_block(root, root, &eta, admissible_max_cluster);

  max_pardepth = 0;

  Vfull = new_amatrix(n, n);
  KMfull = new_amatrix(n, n);
  idx = allocuint(n);
  for (i = 0; i < n; ++i) {
    idx[i] = i;
  }
  SCHEDULE_OPENCL(0, 1, bem_slp->nearfield, idx, idx, bem_slp, false, Vfull);
  SCHEDULE_OPENCL(0, 1, bem_dlp->nearfield, idx, idx, bem_dlp, false, KMfull);

  V = build_from_block_hmatrix(block, 0);
  KM = build_from_block_hmatrix(block, 0);

  printf("----------------------------------------\n");
  printf("Testing outer Boundary integral equations:\n");
  printf("----------------------------------------\n\n");

  /*
   * Test Interpolation
   */

  m = 4;

  setup_hmatrix_aprx_inter_row_bem3d(bem_slp, root, root, block, m);
  setup_hmatrix_aprx_inter_row_bem3d(bem_dlp, root, root, block, m);
  test_hmatrix_system("Interpolation row", Vfull, KMfull, block, bem_slp, V,
		      bem_dlp, KM, false, true, 1.0e-3, 2.0e-3);

  setup_hmatrix_aprx_inter_col_bem3d(bem_slp, root, root, block, m);
  setup_hmatrix_aprx_inter_col_bem3d(bem_dlp, root, root, block, m);
  test_hmatrix_system("Interpolation column", Vfull, KMfull, block, bem_slp,
		      V, bem_dlp, KM, false, true, 1.0e-3, 2.0e-3);

  setup_hmatrix_aprx_inter_mixed_bem3d(bem_slp, root, root, block, m);
  setup_hmatrix_aprx_inter_mixed_bem3d(bem_dlp, root, root, block, m);
  test_hmatrix_system("Interpolation mixed", Vfull, KMfull, block, bem_slp, V,
		      bem_dlp, KM, false, true, 1.0e-3, 2.0e-3);

  /*
   * Test Green
   */

  m = 5;
  l = 1;
  delta = 0.5;

  setup_hmatrix_aprx_green_row_bem3d(bem_slp, root, root, block, m, l, delta,
				     build_bem3d_cube_quadpoints);
  setup_hmatrix_aprx_green_row_bem3d(bem_dlp, root, root, block, m, l, delta,
				     build_bem3d_cube_quadpoints);
  test_hmatrix_system("Green row", Vfull, KMfull, block, bem_slp, V, bem_dlp,
		      KM, false, true, 1.0e-3, 2.0e-3);

  setup_hmatrix_aprx_green_col_bem3d(bem_slp, root, root, block, m, l, delta,
				     build_bem3d_cube_quadpoints);
  setup_hmatrix_aprx_green_col_bem3d(bem_dlp, root, root, block, m, l, delta,
				     build_bem3d_cube_quadpoints);
  test_hmatrix_system("Green column", Vfull, KMfull, block, bem_slp, V,
		      bem_dlp, KM, false, true, 1.0e-3, 2.0e-3);

  setup_hmatrix_aprx_green_mixed_bem3d(bem_slp, root, root, block, m, l,
				       delta, build_bem3d_cube_quadpoints);
  setup_hmatrix_aprx_green_mixed_bem3d(bem_dlp, root, root, block, m, l,
				       delta, build_bem3d_cube_quadpoints);
  test_hmatrix_system("Green mixed", Vfull, KMfull, block, bem_slp, V,
		      bem_dlp, KM, false, true, 1.0e-3, 2.0e-3);

  /*
   * Test Greenhybrid
   */

  m = 2;
  l = 1;
  delta = 1.0;
  eps_aca = 2.0e-2;

  setup_hmatrix_aprx_greenhybrid_row_bem3d(bem_slp, root, root, block, m, l,
					   delta, eps_aca,
					   build_bem3d_cube_quadpoints);
  setup_hmatrix_aprx_greenhybrid_row_bem3d(bem_dlp, root, root, block, m, l,
					   delta, eps_aca,
					   build_bem3d_cube_quadpoints);
  test_hmatrix_system("Greenhybrid row", Vfull, KMfull, block, bem_slp, V,
		      bem_dlp, KM, false, true, 1.0e-3, 2.0e-3);

  setup_hmatrix_aprx_greenhybrid_col_bem3d(bem_slp, root, root, block, m, l,
					   delta, eps_aca,
					   build_bem3d_cube_quadpoints);
  setup_hmatrix_aprx_greenhybrid_col_bem3d(bem_dlp, root, root, block, m, l,
					   delta, eps_aca,
					   build_bem3d_cube_quadpoints);
  test_hmatrix_system("Greenhybrid column", Vfull, KMfull, block, bem_slp, V,
		      bem_dlp, KM, false, true, 1.0e-3, 2.0e-3);

  setup_hmatrix_aprx_greenhybrid_mixed_bem3d(bem_slp, root, root, block, m, l,
					     delta, eps_aca,
					     build_bem3d_cube_quadpoints);
  setup_hmatrix_aprx_greenhybrid_mixed_bem3d(bem_dlp, root, root, block, m, l,
					     delta, eps_aca,
					     build_bem3d_cube_quadpoints);
  test_hmatrix_system("Greenhybrid mixed", Vfull, KMfull, block, bem_slp, V,
		      bem_dlp, KM, false, true, 1.0e-3, 2.0e-3);

  /*
   * Test ACA / PACA / HCA
   */

  m = 2;
  eps_aca = 1.0e-2;

  /* Nearfield computation on GPU not applicable here yet! */

//  setup_hmatrix_aprx_aca_bem3d(bem_slp, root, root, block, eps_aca);
//  setup_hmatrix_aprx_aca_bem3d(bem_dlp, root, root, block, eps_aca);
//  test_hmatrix_system("ACA full pivoting", Vfull, KMfull, block, bem_slp, V,
//      bem_dlp, KM, false, true, 1.0e-3, 2.0e-3);
//
//  setup_hmatrix_aprx_paca_bem3d(bem_slp, root, root, block, eps_aca);
//  setup_hmatrix_aprx_paca_bem3d(bem_slp, root, root, block, eps_aca);
//  test_hmatrix_system("ACA partial pivoting", Vfull, KMfull, block, bem_slp, V,
//      bem_dlp, KM, false, true, 1.0e-3, 2.0e-3);
  setup_hmatrix_aprx_hca_bem3d(bem_slp, root, root, block, m, eps_aca);
  setup_hmatrix_aprx_hca_bem3d(bem_slp, root, root, block, m, eps_aca);
  test_hmatrix_system("HCA2", Vfull, KMfull, block, bem_slp, V, bem_dlp, KM,
		      false, true, 1.0e-3, 2.0e-3);

  del_hmatrix(V);
  del_hmatrix(KM);
  del_block(block);

  /*
   * H2-matrix
   */

  block = build_strict_block(root, root, &eta, admissible_max_cluster);

  Vrb = build_from_cluster_clusterbasis(root);
  Vcb = build_from_cluster_clusterbasis(root);
  KMrb = build_from_cluster_clusterbasis(root);
  KMcb = build_from_cluster_clusterbasis(root);

  V2 = build_from_block_h2matrix(block, Vrb, Vcb);
  KM2 = build_from_block_h2matrix(block, KMrb, KMcb);

  /*
   * Test Interpolation
   */

  m = 3;

  setup_h2matrix_aprx_inter_bem3d(bem_slp, Vrb, Vcb, block, m);
  setup_h2matrix_aprx_inter_bem3d(bem_dlp, KMrb, KMcb, block, m);
  test_h2matrix_system("Interpolation", Vfull, KMfull, block, bem_slp, V2,
		       bem_dlp, KM2, false, true, 1.0e-3, 2.0e-3);

  /*
   * Test Greenhybrid
   */

  m = 2;
  l = 1;
  delta = 1.0;
  eps_aca = 2.0e-2;

  setup_h2matrix_aprx_greenhybrid_bem3d(bem_slp, Vrb, Vcb, block, m, l, delta,
					eps_aca, build_bem3d_cube_quadpoints);
  setup_h2matrix_aprx_greenhybrid_bem3d(bem_dlp, KMrb, KMcb, block, m, l,
					delta, eps_aca,
					build_bem3d_cube_quadpoints);
  test_h2matrix_system("Greenhybrid", Vfull, KMfull, block, bem_slp, V2,
		       bem_dlp, KM2, false, true, 1.0e-3, 2.0e-3);

  /* Nearfield computation on GPU not applicable here yet! */

//  setup_h2matrix_aprx_greenhybrid_ortho_bem3d(bem_slp, Vrb, Vcb, block, m, l,
//      delta, eps_aca, build_bem3d_cube_quadpoints);
//  setup_h2matrix_aprx_greenhybrid_ortho_bem3d(bem_dlp, KMrb, KMcb, block, m, l,
//      delta, eps_aca, build_bem3d_cube_quadpoints);
//  test_h2matrix_system("Greenhybrid ortho", Vfull, KMfull, block, bem_slp, V2,
//      bem_dlp, KM2, false, true, 1.0e-3, 2.0e-3);
  del_h2matrix(V2);
  del_h2matrix(KM2);
  del_block(block);
  freemem(root->idx);
  del_cluster(root);
  del_helmholtz_ocl_bem3d(bem_slp);
  del_helmholtz_ocl_bem3d(bem_dlp);

  del_amatrix(Vfull);
  del_amatrix(KMfull);
  del_surface3d(gr);
  del_macrosurface3d(mg);
  freemem(idx);

  (void) printf("----------------------------------------\n"
		"  %u matrices and\n"
		"  %u vectors still active\n"
		"  %u errors found\n", getactives_amatrix(),
		getactives_avector(), problems);

  uninit_h2lib();

  return problems;
}