Exemplo n.º 1
0
/*
------------------------------------------------------------------------------
B_NO_PAIRS adds a single crossing to a single weave.
Either the crossing is correct, in which case *one* will be set, or it is
wrong.  In this case no more than two weaves are needed, so *two* will be set.
------------------------------------------------------------------------------
*/
void   b_no_pairs(
  word  *list,  /* list of original inputs/outputs, modified by this routine */
  word  *list2,                    /* inputs/outputs of the second new weave */
  word  *one,                                 /* will one new weave suffice? */
  word  *two)                                /* will two new weaves suffice? */
{
  word  i,
        a,
        b,
        c;


  /*-------------------------------------------------- Make the new boundary */
  for (i = oldcross; --i >= 0;) list[map[i]] = map[list[i]];
  a         = plan.which+1;
  list[a-1] = a+1;
  list[a+1] = a-1;

  /*------------------------- Decide if the crossing needs to be operated on */
  c = a-1;
  b_right(list, going_in, c, a, i);
  *one = (i == right);
  *two = !*one;
  if (*two)
  {
    for (i = newcross; --i >= 0;) list2[i] = list[i];
    b               = (plan.prev == going_in[a]) ? a-1 : a+1;
    c               = (plan.prev == going_in[a]) ? a+1 : a-1;
    list2[list2[a]] = b;
    list2[b]        = list2[a];
    list2[a]        = c;
    list2[c]        = a;
  }
}
Exemplo n.º 2
0
static double get_phi(int i, int j)
{
	dp_t u_left(OX[i-1], OY[j+1]); // left upper
	dp_t u_right(OX[i+1], OY[j+1]); // right upper
	dp_t b_left(OX[i-1], OY[j-1]); // left bottom
	dp_t b_right(OX[i+1], OY[j-1]); // right bottom
	dp_t center(OX[i], OY[j]);

	double u = func_u();
	double v = func_v();
	center.x = center.x - TAU * u;
	center.y = center.y - TAU * v;
	u = func_u();
	v = func_v();
	u_left.x = u_left.x - TAU * u;
	u_left.y = u_left.y - TAU * v;
	u = func_u();
	v = func_v();
	u_right.x = u_right.x - TAU * u;
	u_right.y = u_right.y - TAU * v;
	u = func_u();
	v = func_v();
	b_left.x = b_left.x - TAU * u;
	b_left.y = b_left.y - TAU * v;
	u = func_u();
	v = func_v();
	b_right.x = b_right.x - TAU * u;
	b_right.y = b_right.y - TAU * v;

	int nx = 10;
	int ny = 10;
	double x_step = 1.0/nx;
	double y_step = 1.0/ny;
	double* x_mesh = create_mesh_vector(nx);
	double* y_mesh = create_mesh_vector(ny);

	if (i == 1 && j == 1 && f == 0)
	{
		// __print_vector(x_mesh, nx);
		// __print_vector(y_mesh, ny);
		f = 1;
	}

	// get right part for jakoby
	double phi = 0;
	for(int i = 0; i < nx; ++i)
	{
		for(int j = 0; j < ny; ++j)
		{
			dp_t ideal;
			ideal.x = x_mesh[i] + x_step/2.;
			ideal.y = y_mesh[j] + y_step/2.;
			dp_t real = get_point_real_pt_by_ideal_pt(b_left, b_right, u_right, u_left, 
				ideal);
			double dens = get_density_in_real_pt(b_left, b_right, u_right, u_left, 
				real);
			double jakob = jakobian(b_left, b_right, u_right, u_left, ideal);
			phi += dens * jakob;
		}
	}
	phi = (16*phi/9*x_step*y_step);
	delete[] x_mesh;
	delete[] y_mesh;
	return phi;
}