static void _random2_fill (AranSolver3d *solver) { guint64 i; PointAccum *point; GRand *rand = g_rand_new_with_seed (_random_seed); point = point_accum_alloc (TRUE, NULL); for (i=0; i<np; i++) { #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 %luth point\n", rk, i); aran_solver3d_distribute_contiguous_leaves (solver); _flush_interval *=2; } } #endif /* VSG_HAVE_MPI */ point->vector.x = g_rand_double_range (rand, -R, R);; point->vector.y = g_rand_double_range (rand, -R, R);; point->vector.z = g_rand_double_range (rand, -R, R);; point->density = 1./np; point->field = VSG_V3D_ZERO; point->id = i; /* if (i == 3) point->density = 0.; */ /* if (i == 4) point->density = 0.; */ /* if (i == 5) point->density = 0.; */ if (check) memcpy (&check_points[i], point, sizeof (PointAccum)); if (aran_solver3d_insert_point_local (solver, point)) { if (i % 10000 == 0 && _verbose) g_printerr ("%d: insert %luth point\n", rk, i); point = point_accum_alloc (TRUE, NULL); } } 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); }
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 _unbalanced_fill (AranSolver3d *solver) { PointAccum *point; np --; _random2_fill (solver); point = point_accum_alloc (TRUE, NULL); point->vector.x = -2. * R; point->vector.y = 0.; point->vector.z = 0.; point->density = 1.; point->field = VSG_V3D_ZERO; point->id = np; if (check) memcpy (&check_points[np], point, sizeof (PointAccum)); if (!aran_solver3d_insert_point_local (solver, point)) point_accum_destroy (point, TRUE, NULL); np ++; #ifdef VSG_HAVE_MPI aran_solver3d_migrate_flush (solver); aran_solver3d_distribute_contiguous_leaves (solver); #endif /* VSG_HAVE_MPI */ }
static void _load_fill (AranSolver3d *solver) { gdouble x, y, z, d; guint i; PointAccum *point; FILE *file = fopen (_load_file, "r"); point = point_accum_alloc (TRUE, NULL); while (fscanf (file, "%d %lf %lf %lf %lf", &i, &x, &y, &z, &d) != EOF) { /* g_printerr ("%d : loaded point %d\n", rk, i); */ #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 */ point->vector.x = x; point->vector.y = y; point->vector.z = z; point->density = d; point->field = VSG_V3D_ZERO; point->id = i; np ++; if (check) { if (np > _cp_size) { _cp_size *= 2; check_points = g_realloc (check_points, _cp_size); } memcpy (&check_points[i], point, sizeof (PointAccum)); } 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); } } point_accum_destroy (point, TRUE, NULL); #ifdef VSG_HAVE_MPI aran_solver3d_distribute_contiguous_leaves (solver); #endif /* VSG_HAVE_MPI */ }
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); }