Ejemplo n.º 1
0
/*
 * Some simple tests
 */
static void base_test(void) {
  printf("*****************\n");
  printf("    BASE TESTS\n");
  printf("*****************\n\n");

  init_test_bench(&bench, &poly_table);
  bench.show_details = true;

  test_activate(&bench, 10);
  test_activate(&bench, 2);
  test_activate(&bench, 4);
  test_propagate(&bench);
  test_push(&bench);
  test_activate(&bench, 24);
  test_activate(&bench, 23);
  test_activate(&bench, 41);
  test_activate(&bench, 49);
  test_activate(&bench, 55);
  test_propagate(&bench);
  test_assert_eq(&bench, 4, 2, -12);
  test_assert_eq(&bench, 4, 10, 0);
  test_propagate(&bench);
  test_increase_dlevel(&bench);
  test_assert_eq(&bench, 5, -1, 1223);
  test_propagate(&bench);
  test_assert_eq(&bench, 2, 10, 20); // cause a conflict
  test_propagate(&bench);
  test_backtrack(&bench);
  test_propagate(&bench);
  test_pop(&bench);
  test_propagate(&bench);
  delete_test_bench(&bench);
}
Ejemplo n.º 2
0
/*
 * Random test:
 * - p = number of polynomials to activate first
 * - n = number of random operations
 */
static void random_test(uint32_t n, uint32_t p) {
  printf("*******************\n");
  printf("    RANDOM TESTS\n");
  printf("*******************\n\n");

  init_test_bench(&bench, &poly_table);

  random_activate(&bench, p);
  while (n > 0) {
    random_op(&bench);
    n --;
  }

  // final step: propagate
  if (! bench.mngr_conflict) {
    test_propagate(&bench);
  }

  delete_test_bench(&bench);
}
Ejemplo n.º 3
0
int main(int argc, char **argv)
{
	static Front front;
	static RECT_GRID comp_grid;
	static F_BASIC_DATA f_basic;
	static LEVEL_FUNC_PACK level_func_pack;
	static VELO_FUNC_PACK velo_func_pack;
	TNORV_PARAMS norm_params; /* velocity function parameters */
	TMC_PARAMS mc_params;
	Locstate  sl;

	f_basic.dim = 2;
	FrontInitStandardIO(argc,argv,&f_basic);

	/* Initialize basic computational data */

	f_basic.L[0] = 0.0;	f_basic.L[1] = 0.0;
	f_basic.U[0] = 1.0;	f_basic.U[1] = 1.0;
	f_basic.gmax[0] = 100;	f_basic.gmax[1] = 100;
	f_basic.boundary[0][0] = f_basic.boundary[0][1] = PERIODIC_BOUNDARY;
	f_basic.boundary[1][0] = f_basic.boundary[1][1] = PERIODIC_BOUNDARY;
	f_basic.size_of_intfc_state = 0;

        in_name                 = f_basic.in_name;
        restart_state_name      = f_basic.restart_state_name;
        out_name                = f_basic.out_name;
        restart_name            = f_basic.restart_name;
        RestartRun              = f_basic.RestartRun;
        RestartStep             = f_basic.RestartStep;

        sprintf(restart_name,"%s.ts%s",restart_name,right_flush(RestartStep,7));
#if defined(__MPI__)
        sprintf(restart_name,"%s-nd%s",restart_name,right_flush(pp_mynode(),4));
#endif /* defined(__MPI__) */

	FrontStartUp(&front,&f_basic);

	if (!RestartRun)
	{
	    /* Initialize interface through level function */

	    mc_params.num_cir = 3;
            vector(&mc_params.rad,mc_params.num_cir,FLOAT);
            matrix(&mc_params.cen,mc_params.num_cir,2,FLOAT);
	    mc_params.cen[0][0] = 0.3;
	    mc_params.cen[0][1] = 0.3;
	    mc_params.cen[1][0] = 0.7;
	    mc_params.cen[1][1] = 0.3;
	    mc_params.cen[2][0] = 0.5;
	    mc_params.cen[2][1] = 0.7;
	    mc_params.rad[0] = 0.1;
	    mc_params.rad[1] = 0.1;
	    mc_params.rad[2] = 0.1;

	    level_func_pack.neg_component = 1;
	    level_func_pack.pos_component = 2;
	    level_func_pack.func_params = (POINTER)&mc_params;
	    level_func_pack.func = multi_circle_func;

	    FrontInitIntfc(&front,&level_func_pack);
	}

	/* Initialize velocity field function */

	norm_params.dim = 2;
	norm_params.coeff = 0.1;

	velo_func_pack.func_params = (POINTER)&norm_params;
	velo_func_pack.func = norm_vel_func;
	velo_func_pack.point_propagate = first_order_point_propagate;

	FrontInitVelo(&front,&velo_func_pack);

        /* For geometry-dependent velocity, use first
        * order point propagation function, higher order
        * propagation requires surface propagate, currently
        * in writing, not yet in use. The following override
        * the assigned fourth_order_point_propagate.
        */

        front._point_propagate = first_order_point_propagate;

	/* Propagate the front */

	test_propagate(&front);

	clean_up(0);
	return 0;
}
Ejemplo n.º 4
0
/*
 * Random test: give more weight to assert_eq and propagate
 * - if there's a conflict, try to resolve it first
 */
static void random_op(test_bench_t *bench) {
  uint32_t r;

  if (bench->mngr_conflict) {
    if (bench->decision_level > bench->base_level) {
      test_backtrack(bench);
    } else if (bench->base_level > 0) {
      test_pop(bench);
    }
  } else {
    r = random_index(15);
    switch (r) {
    case 0:
    case 1:
    case 2:
    case 3:
    case 4:
      random_assert_eq(bench);
      break;

    case 5:
      random_assert_eq(bench);
    case 6:
      random_assert_eq(bench);
    case 7:
      random_assert_eq(bench);
    case 8:
      test_propagate(bench);
      break;

    case 9:
      random_activate(bench, 1);
      break;

    case 10:
    case 11:
      // increase decision level: force propagate first
      test_propagate(bench);
      if (! bench->mngr_conflict) {
	test_increase_dlevel(bench);
      }
      break;

    case 12:
      // push
      if (bench->decision_level == bench->base_level) {
	test_push(bench);
      }
      break;

    case 13:
      // backtrack
      if (bench->decision_level > bench->base_level) {
	test_backtrack(bench);
      }
      break;

    case 14:
      // pop
      if (bench->base_level > 0) {
	test_pop(bench);
      }
      break;

    default:
      assert(false);
      break;
    }
  }
}
Ejemplo n.º 5
0
int main(int argc, char **argv)
{
	static Front front;
	static RECT_GRID comp_grid;
	static F_BASIC_DATA f_basic;
	static LEVEL_FUNC_PACK level_func_pack;
	static VELO_FUNC_PACK velo_func_pack;
        DOUBLE_VORTEX_PARAMS dv_params; /* velocity function parameters */

	f_basic.dim = 2;
	FrontInitStandardIO(argc,argv,&f_basic);

	/* Initialize basic computational data */

	f_basic.L[0] = 0.0;	f_basic.L[1] = 0.0;
	f_basic.U[0] = 1.0;	f_basic.U[1] = 1.0;
	f_basic.gmax[0] = 200;	f_basic.gmax[1] = 200;
	f_basic.boundary[0][0] = f_basic.boundary[0][1] = DIRICHLET_BOUNDARY;
	f_basic.boundary[1][0] = f_basic.boundary[1][1] = DIRICHLET_BOUNDARY;
	f_basic.size_of_intfc_state = 0;

        in_name                 = f_basic.in_name;
        restart_state_name      = f_basic.restart_state_name;
        out_name                = f_basic.out_name;
        restart_name            = f_basic.restart_name;
        RestartRun              = f_basic.RestartRun;
        RestartStep             = f_basic.RestartStep;

        sprintf(restart_name,"%s.ts%s",restart_name,right_flush(RestartStep,7));
#if defined(__MPI__)
        sprintf(restart_name,"%s-nd%s",restart_name,right_flush(pp_mynode(),4));
#endif /* defined(__MPI__) */
	

	FrontStartUp(&front,&f_basic);

	if (!RestartRun)
	{
	    /* Initialize interface through level function */

	    level_func_pack.neg_component = 1;
	    level_func_pack.pos_component = 2;
	    level_func_pack.func_params = NULL;
	    level_func_pack.func = NULL;
	    level_func_pack.num_points = 500;
	    level_func_pack.is_closed_curve = YES;

	    matrix(&level_func_pack.point_array,500,2,sizeof(float));
	    int i;
	    for (i = 0; i < 500; ++i)
	    {
	        float phi = i*2.0*PI/500.0;
	        level_func_pack.point_array[i][0] = 0.5 + 0.3*cos(phi);
	        level_func_pack.point_array[i][1] = 0.5 + 0.3*sin(phi);
	    }
	
	    FrontInitIntfc(&front,&level_func_pack);
	}

	/* Initialize velocity field function */

        dv_params.cen1[0] = 0.25;
        dv_params.cen1[1] = 0.50;
        dv_params.cen2[0] = 0.75;
        dv_params.cen2[1] = 0.50;
        dv_params.i1 = -0.5;
        dv_params.i2 =  0.5;

        velo_func_pack.func_params = (POINTER)&dv_params;
        velo_func_pack.func = test_vortex_vel;
        velo_func_pack.point_propagate = fourth_order_point_propagate;

        FrontInitVelo(&front,&velo_func_pack);

        /* Propagate the front */

        test_propagate(&front);

	clean_up(0);
}