static void _random_fill (AranSolver3d *solver)
{
  guint i;
  PointAccum *point;
  GRand *rand = g_rand_new_with_seed (_random_seed);

  for (i=0; i<np; i++)
    {
      PointAccum tmp;

#ifdef VSG_HAVE_MPI
      if (i%_flush_interval == 0)
        {
          aran_solver3d_migrate_flush (solver);
          if (i%(_flush_interval*10) == 0)
            {
              if (_verbose && rk == 0)
                g_printerr ("%d: contiguous dist before %dth point\n", rk, i);

              aran_solver3d_distribute_contiguous_leaves (solver);
              _flush_interval *=2;
            }
        }
#endif /* VSG_HAVE_MPI */

      tmp.vector.x = g_rand_double_range (rand, -R, R);;
      tmp.vector.y = g_rand_double_range (rand, -R, R);;
      tmp.vector.z = g_rand_double_range (rand, -R, R);;
      tmp.density = 1.;
      tmp.field = VSG_V3D_ZERO;
      tmp.id = i;

      if (check) memcpy (&check_points[i], &tmp, sizeof (PointAccum));

      if (i%sz != rk) continue;

      if (i % 10000 == 0 && _verbose)
        g_printerr ("%d: insert %dth point\n", rk, i);

      point = point_accum_alloc (TRUE, NULL);

      memcpy (point, &tmp, sizeof (PointAccum));

      aran_solver3d_insert_point (solver, point);
    }

#ifdef VSG_HAVE_MPI
  aran_solver3d_migrate_flush (solver);
  aran_solver3d_distribute_contiguous_leaves (solver);
#endif /* VSG_HAVE_MPI */

  g_rand_free (rand);
}
static void _one_circle_fill (AranSolver3d *solver)
{
  guint i;
  PointAccum *point;

  for (i=0; i<np; i++)
    {
      PointAccum tmp;

#ifdef VSG_HAVE_MPI
      if (i%_flush_interval == 0)
        {
          aran_solver3d_migrate_flush (solver);
          if (i%(_flush_interval*10) == 0)
            {
              if (_verbose && rk == 0)
                g_printerr ("%d: contiguous dist before %dth point\n", rk, i);

              aran_solver3d_distribute_contiguous_leaves (solver);
              _flush_interval *=2;
            }
        }
#endif /* VSG_HAVE_MPI */

      tmp.vector.x = R * cos(2.*G_PI*i/np);
      tmp.vector.y = R * sin(2.*G_PI*i/np);
      tmp.vector.z = 0.0;
/*       tmp.vector.z = tmp.vector.x; */
      tmp.density = 1./np;
      tmp.field = VSG_V3D_ZERO;
      tmp.id = i;

      if (check) memcpy (&check_points[i], &tmp, sizeof (PointAccum));

      if (i%sz != rk) continue;

      if (i % 10000 == 0 && _verbose)
        g_printerr ("%d: insert %dth point\n", rk, i);

      point = point_accum_alloc (TRUE, NULL);

      memcpy (point, &tmp, sizeof (PointAccum));

      if (!direct) aran_solver3d_insert_point (solver, point);
    }
#ifdef VSG_HAVE_MPI
  aran_solver3d_migrate_flush (solver);
  aran_solver3d_distribute_contiguous_leaves (solver);
#endif /* VSG_HAVE_MPI */
}
static void _random_distribution (PointAccum **points,
				  AranSolver3d *solver)
{
  guint i, cptr = 0;
  gdouble tol = 1.e-2;

  aran_solver3d_set_tolerance (solver, tol);

  for (i=0; i<np; i++)
    {
      PointAccum *point = g_malloc0 (sizeof (PointAccum));
      PointAccum *found;

      point->vector.x = g_random_double_range (-R,R);
      point->vector.y = g_random_double_range (-R,R);
      point->vector.z = g_random_double_range (-R,R);
      point->density = g_random_double_range (0., 2./np);
      point->field = VSG_V3D_ZERO;
/*       point->accum = 0.; */
      point->id = cptr;

      if (direct)
        {
          points[cptr] = point;
          cptr ++;
        }
      else
        {
          found = aran_solver3d_find_point (solver, point);

          if (found != NULL)
            {
              found->density += point->density;

              g_free (point);
            }
          else
            {
              points[cptr] = point;
              aran_solver3d_insert_point (solver, point);
              cptr ++;
            }
        }
    }

  np = cptr;
}
void check_parallel_points (AranSolver3d *solver)
{
  VsgVector3d lbound;
  VsgVector3d ubound;
  VsgPRTree3d *prtree;
  AranSolver3d *solver2;
  int i;

  aran_solver3d_get_bounds (solver, &lbound, &ubound);

  prtree =
    vsg_prtree3d_new_full (&lbound, &ubound,
                            (VsgPoint3dLocFunc) vsg_vector3d_vector3d_locfunc,
                            (VsgPoint3dDistFunc) vsg_vector3d_dist,
                            (VsgRegion3dLocFunc) NULL, maxbox);

  solver2 = aran_solver3d_new (prtree, ARAN_TYPE_DEVELOPMENT3D,
                              aran_development3d_new (0, order),
                              (AranZeroFunc) aran_development3d_set_zero);

  aran_solver3d_set_functions (solver2,
                               (AranParticle2ParticleFunc3d) p2p,
                               (AranParticle2MultipoleFunc3d) p2m,
                               m2m,
                               m2l,
                               l2l,
                               (AranLocal2ParticleFunc3d) l2p);

  if (_hilbert)
    {
      /* configure for hilbert curve order traversal */
      aran_solver3d_set_children_order_hilbert (solver2);
    }

  for (i=0; i<np; i++)
    {
      aran_solver3d_insert_point (solver2, &check_points[i]);
    }

  aran_solver3d_solve (solver2);

  aran_solver3d_free (solver2);
}
static void _grid_distribution (PointAccum **points,
                                AranSolver3d *solver)
{
  guint i, j, k, size, cptr = 0;
  gdouble x, y, z, density;

  size = floor (pow (np, 1./3.));

  np = size*size*size;
  density = 1./np;

  for (i=0; i<size; i ++)
    {
      x = R * (2.*i/(size-1.)-1.);
      for (j=0; j<size; j ++)
        {
          y = R * (2.*j/(size-1.)-1.);
          for (k=0; k<size; k ++)
            {
              PointAccum *point = g_malloc0 (sizeof (PointAccum));

              z = R * (2.*k/(size-1.)-1.);

              point->vector.x = x;
              point->vector.y = y;
              point->vector.z = z;
              point->density = density;
              point->field = VSG_V3D_ZERO;
/*               point->accum = 0.; */
              point->id = cptr;

              if (!direct)
                aran_solver3d_insert_point (solver, point);

              points[cptr] = point;

              cptr ++;
            }
        }
    }
}
static void _one_circle_distribution (PointAccum **points, AranSolver3d *solver)
{
  guint i;

  for (i=0; i<np; i++)
    {
      PointAccum *point = g_malloc0 (sizeof (PointAccum));

      point->vector.x = R * cos(2.*G_PI*i/np);
      point->vector.y = R * sin(2.*G_PI*i/np);
      point->vector.z = 0.0;
/*       point->vector.z = point->vector.x; */
      point->density = 1./np;
      point->field = VSG_V3D_ZERO;
/*       point->accum = 0.; */
      point->id = i;

      points[i] = point;

      if (!direct) aran_solver3d_insert_point (solver, point);
    }
}
static void _plummer_fill (AranSolver3d *solver)
{
  gdouble rmax = 300.;
  guint i, real_np = 0;
  PointAccum lb, ub;
  PointAccum *point;
  GRand *rand = g_rand_new_with_seed (_random_seed);

  point = point_accum_alloc (TRUE, NULL);

  ub.vector.x = rmax;
  ub.vector.y = rmax;
  ub.vector.z = rmax;

  lb.vector.x = - rmax;
  lb.vector.y = - rmax;
  lb.vector.z = - rmax;

  if (rk == 0)
    {
      aran_solver3d_insert_point (solver, &ub);
      aran_solver3d_insert_point (solver, &lb);
    }

  aran_solver3d_migrate_flush (solver);

  aran_solver3d_remove_point (solver, &lb);
  aran_solver3d_remove_point (solver, &ub);

  for (i=0; i<np; i++)
    {
      gdouble x1, x2, x3, r, tmp;

#ifdef VSG_HAVE_MPI
      if (i%_flush_interval == 0)
        {
          aran_solver3d_migrate_flush (solver);
          if (i%(_flush_interval*10) == 0)
            {
              if (_verbose && rk == 0)
                g_printerr ("%d: contiguous dist before %dth point\n", rk, i);

              aran_solver3d_distribute_contiguous_leaves (solver);
              _flush_interval *=2;
            }
        }
#endif /* VSG_HAVE_MPI */

      x1 = g_rand_double_range (rand, 0., 1.);
      x2 = g_rand_double_range (rand, 0., 1.);
      x3 = g_rand_double_range (rand, 0., 1.);

      r = 1./ sqrt (pow (x1, -2./3.) -1.);

      point->vector.z = R * (1. - (x2+x2)) * r;

      tmp = sqrt (r*r - point->vector.z*point->vector.z);

      point->vector.x = R * tmp * cos (2.*G_PI * x3);
      point->vector.y = R * tmp * sin (2.*G_PI * x3);

      if (fabs (point->vector.x) > rmax) continue;
      if (fabs (point->vector.y) > rmax) continue;
      if (fabs (point->vector.z) > rmax) continue;

      point->density = 1./np;
      point->field = VSG_V3D_ZERO;
      point->id = real_np;

      if (check) memcpy (&check_points[real_np], point, sizeof (PointAccum));

      real_np ++;

      if (aran_solver3d_insert_point_local (solver, point))
        {
          if (i % 10000 == 0 && _verbose)
            g_printerr ("%d: insert %dth point\n", rk, i);

          point = point_accum_alloc (TRUE, NULL);
        }
    }

  g_printerr ("%d : real_np %d\n", rk, real_np);

  np = real_np;

  point_accum_destroy (point, TRUE, NULL);

#ifdef VSG_HAVE_MPI
  aran_solver3d_migrate_flush (solver);
  aran_solver3d_distribute_contiguous_leaves (solver);
#endif /* VSG_HAVE_MPI */

  g_rand_free (rand);
}
Exemple #8
0
void check_parallel_points (AranSolver3d *solver)
{
  VsgVector3d lbound;
  VsgVector3d ubound;
  VsgPRTree3d *prtree;
  AranSolver3d *solver2;
  guint64 i;

  aran_solver3d_get_bounds (solver, &lbound, &ubound);

  prtree =
    vsg_prtree3d_new_full (&lbound, &ubound,
                            (VsgPoint3dLocFunc) vsg_vector3d_vector3d_locfunc,
                            (VsgPoint3dDistFunc) vsg_vector3d_dist,
                            (VsgRegion3dLocFunc) NULL, maxbox);

  solver2 = aran_solver3d_new (prtree, ARAN_TYPE_DEVELOPMENT3D,
                              aran_development3d_new (0, order),
                              (AranZeroFunc) aran_development3d_set_zero);

  aran_solver3d_set_functions (solver2,
                               (AranParticle2ParticleFunc3d) p2p,
                               (AranParticle2MultipoleFunc3d) p2m,
                               m2m,
                               m2l,
                               l2l,
                               (AranLocal2ParticleFunc3d) l2p);


  if (semifar_threshold < G_MAXUINT)
    {
      /* if optimal threshold was requested, we need to compare with the same value */
      if (semifar_threshold == 0)
        aran_solver3d_get_functions_full (solver, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
                                          &semifar_threshold);

      aran_solver3d_set_functions_full (solver2,
                                        (AranParticle2ParticleFunc3d) p2p,
                                        (AranParticle2MultipoleFunc3d) p2m,
                                        m2m,
                                        m2l,
                                        l2l,
                                        (AranLocal2ParticleFunc3d) l2p,
                                        (AranParticle2LocalFunc3d) p2l,
                                        (AranMultipole2ParticleFunc3d) m2p,
                                        semifar_threshold);
    }

  if (_hilbert)
    {
      /* configure for hilbert curve order traversal */
      aran_solver3d_set_children_order_hilbert (solver2);
    }

  for (i=0; i<np; i++)
    {
      aran_solver3d_insert_point (solver2, &check_points[i]);
    }

  aran_solver3d_solve (solver2);

  aran_solver3d_free (solver2);
}