test27cellsStars.c 17.1 KB
Newer Older
Loic Hausammann's avatar
Loic Hausammann committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
/*******************************************************************************
 * This file is part of SWIFT.
 * Copyright (C) 2015 Matthieu Schaller (matthieu.schaller@durham.ac.uk).
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published
 * by the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 ******************************************************************************/

/* Config parameters. */
#include "../config.h"

/* Some standard headers. */
#include <fenv.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

/* Local headers. */
#include "swift.h"

33 34
#define DOSELF1 runner_doself_branch_stars_density
#define DOSELF1_SUBSET runner_doself_subset_branch_stars_density
Loic Hausammann's avatar
Loic Hausammann committed
35
#ifdef TEST_DOSELF_SUBSET
36
#define DOSELF1_NAME "runner_doself_subset_branch_stars_density"
Loic Hausammann's avatar
Loic Hausammann committed
37
#else
38
#define DOSELF1_NAME "runner_doself1_branch_stars_density"
Loic Hausammann's avatar
Loic Hausammann committed
39 40
#endif

41 42
#define DOPAIR1 runner_dopair_branch_stars_density
#define DOPAIR1_SUBSET runner_dopair_subset_branch_stars_density
Loic Hausammann's avatar
Loic Hausammann committed
43
#ifdef TEST_DOPAIR_SUBSET
44
#define DOPAIR1_NAME "runner_dopair_subset_branch_stars_density"
Loic Hausammann's avatar
Loic Hausammann committed
45
#else
46
#define DOPAIR1_NAME "runner_dopair_branch_stars_density"
Loic Hausammann's avatar
Loic Hausammann committed
47 48 49 50 51 52 53 54 55
#endif

#define NODE_ID 0

/**
 * @brief Constructs a cell and all of its particle in a valid state prior to
 * a DOPAIR or DOSELF calcuation.
 *
 * @param n The cube root of the number of particles.
Matthieu Schaller's avatar
Matthieu Schaller committed
56
 * @param n_stars The cube root of the number of star particles.
Loic Hausammann's avatar
Loic Hausammann committed
57 58 59 60
 * @param offset The position of the cell offset from (0,0,0).
 * @param size The cell size.
 * @param h The smoothing length of the particles in units of the inter-particle
 * separation.
Matthieu Schaller's avatar
Matthieu Schaller committed
61 62
 * @param partId The running counter of IDs for gas.
 * @param spartId The running counter of IDs for stars.
Loic Hausammann's avatar
Loic Hausammann committed
63 64 65 66
 * @param pert The perturbation to apply to the particles in the cell in units
 * of the inter-particle separation.
 * @param h_pert The perturbation to apply to the smoothing length.
 */
67 68 69
struct cell *make_cell(size_t n, size_t n_stars, double *offset, double size,
                       double h, long long *partId, long long *spartId,
                       double pert, double h_pert) {
Loic Hausammann's avatar
Loic Hausammann committed
70
  const size_t count = n * n * n;
71
  const size_t scount = n_stars * n_stars * n_stars;
Loic Hausammann's avatar
Loic Hausammann committed
72
  float h_max = 0.f;
Loic Hausammann's avatar
Loic Hausammann committed
73
  float stars_h_max = 0.f;
Loic Hausammann's avatar
Loic Hausammann committed
74 75 76
  struct cell *cell = (struct cell *)malloc(sizeof(struct cell));
  bzero(cell, sizeof(struct cell));

77
  if (posix_memalign((void **)&cell->hydro.parts, part_align,
Loic Hausammann's avatar
Loic Hausammann committed
78 79 80
                     count * sizeof(struct part)) != 0) {
    error("couldn't allocate particles, no. of particles: %d", (int)count);
  }
81
  bzero(cell->hydro.parts, count * sizeof(struct part));
Loic Hausammann's avatar
Loic Hausammann committed
82 83

  /* Construct the parts */
84
  struct part *part = cell->hydro.parts;
Loic Hausammann's avatar
Loic Hausammann committed
85 86 87 88 89 90 91 92 93 94 95 96 97
  for (size_t x = 0; x < n; ++x) {
    for (size_t y = 0; y < n; ++y) {
      for (size_t z = 0; z < n; ++z) {
        part->x[0] =
            offset[0] +
            size * (x + 0.5 + random_uniform(-0.5, 0.5) * pert) / (float)n;
        part->x[1] =
            offset[1] +
            size * (y + 0.5 + random_uniform(-0.5, 0.5) * pert) / (float)n;
        part->x[2] =
            offset[2] +
            size * (z + 0.5 + random_uniform(-0.5, 0.5) * pert) / (float)n;

98 99 100 101 102 103 104 105 106 107 108
        part->v[0] = 0;
        part->v[1] = 0;
        part->v[2] = 0;
        if (h_pert)
          part->h = size * h * random_uniform(1.f, h_pert) / (float)n;
        else
          part->h = size * h / (float)n;
        h_max = fmaxf(h_max, part->h);
        part->id = ++(*partId);

        part->time_bin = 1;
Loic Hausammann's avatar
Loic Hausammann committed
109 110

#ifdef SWIFT_DEBUG_CHECKS
111 112
        part->ti_drift = 8;
        part->ti_kick = 8;
Loic Hausammann's avatar
Loic Hausammann committed
113
#endif
114
        ++part;
Loic Hausammann's avatar
Loic Hausammann committed
115 116 117 118 119
      }
    }
  }

  /* Construct the sparts */
120
  if (posix_memalign((void **)&cell->stars.parts, spart_align,
Loic Hausammann's avatar
Loic Hausammann committed
121 122 123
                     scount * sizeof(struct spart)) != 0) {
    error("couldn't allocate particles, no. of particles: %d", (int)scount);
  }
124
  bzero(cell->stars.parts, scount * sizeof(struct spart));
Loic Hausammann's avatar
Loic Hausammann committed
125

126
  struct spart *spart = cell->stars.parts;
127 128 129
  for (size_t x = 0; x < n_stars; ++x) {
    for (size_t y = 0; y < n_stars; ++y) {
      for (size_t z = 0; z < n_stars; ++z) {
Loic Hausammann's avatar
Loic Hausammann committed
130
        spart->x[0] =
131 132
            offset[0] + size * (x + 0.5 + random_uniform(-0.5, 0.5) * pert) /
                            (float)n_stars;
Loic Hausammann's avatar
Loic Hausammann committed
133
        spart->x[1] =
134 135
            offset[1] + size * (y + 0.5 + random_uniform(-0.5, 0.5) * pert) /
                            (float)n_stars;
Loic Hausammann's avatar
Loic Hausammann committed
136
        spart->x[2] =
137 138
            offset[2] + size * (z + 0.5 + random_uniform(-0.5, 0.5) * pert) /
                            (float)n_stars;
Loic Hausammann's avatar
Loic Hausammann committed
139

140 141 142 143 144 145 146
        spart->v[0] = 0;
        spart->v[1] = 0;
        spart->v[2] = 0;
        if (h_pert)
          spart->h = size * h * random_uniform(1.f, h_pert) / (float)n_stars;
        else
          spart->h = size * h / (float)n_stars;
Loic Hausammann's avatar
Loic Hausammann committed
147
        stars_h_max = fmaxf(stars_h_max, spart->h);
148
        spart->id = ++(*spartId);
Loic Hausammann's avatar
Loic Hausammann committed
149

150
        spart->time_bin = 1;
Loic Hausammann's avatar
Loic Hausammann committed
151 152

#ifdef SWIFT_DEBUG_CHECKS
153 154
        spart->ti_drift = 8;
        spart->ti_kick = 8;
Loic Hausammann's avatar
Loic Hausammann committed
155
#endif
156
        ++spart;
Loic Hausammann's avatar
Loic Hausammann committed
157 158 159 160 161 162
      }
    }
  }

  /* Cell properties */
  cell->split = 0;
163 164
  cell->hydro.h_max = h_max;
  cell->hydro.count = count;
Loic Hausammann's avatar
Loic Hausammann committed
165
  cell->stars.h_max = stars_h_max;
166 167
  cell->stars.count = scount;
  cell->hydro.dx_max_part = 0.;
168
  cell->hydro.dx_max_sort = 0.;
Loic Hausammann's avatar
Loic Hausammann committed
169
  cell->stars.dx_max_sort = 0.;
Loic Hausammann's avatar
Loic Hausammann committed
170 171 172 173 174 175 176
  cell->width[0] = size;
  cell->width[1] = size;
  cell->width[2] = size;
  cell->loc[0] = offset[0];
  cell->loc[1] = offset[1];
  cell->loc[2] = offset[2];

177 178 179
  cell->stars.ti_old_part = 8;
  cell->stars.ti_end_min = 8;
  cell->stars.ti_end_max = 8;
180
  cell->hydro.ti_old_part = 8;
181 182
  cell->hydro.ti_end_min = 8;
  cell->hydro.ti_end_max = 8;
Loic Hausammann's avatar
Loic Hausammann committed
183
  cell->grav.ti_old_part = 8;
184 185
  cell->grav.ti_end_min = 8;
  cell->grav.ti_end_max = 8;
Loic Hausammann's avatar
Loic Hausammann committed
186 187
  cell->nodeID = NODE_ID;

188
  shuffle_particles(cell->hydro.parts, cell->hydro.count);
189
  shuffle_sparticles(cell->stars.parts, cell->stars.count);
Loic Hausammann's avatar
Loic Hausammann committed
190

191
  cell->hydro.sorted = 0;
192
  cell->hydro.sort = NULL;
Loic Hausammann's avatar
Loic Hausammann committed
193

194
  cell->stars.sorted = 0;
195
  cell->stars.sort = NULL;
196

Loic Hausammann's avatar
Loic Hausammann committed
197 198 199 200
  return cell;
}

void clean_up(struct cell *ci) {
201
  free(ci->hydro.parts);
202
  free(ci->stars.parts);
203 204
  free(ci->hydro.sort);
  free(ci->stars.sort);
Loic Hausammann's avatar
Loic Hausammann committed
205 206 207 208 209 210 211
  free(ci);
}

/**
 * @brief Initializes all particles field to be ready for a density calculation
 */
void zero_particle_fields(struct cell *c) {
212 213
  for (int pid = 0; pid < c->stars.count; pid++) {
    stars_init_spart(&c->stars.parts[pid]);
Loic Hausammann's avatar
Loic Hausammann committed
214 215 216 217 218 219 220
  }
}

/**
 * @brief Ends the loop by adding the appropriate coefficients
 */
void end_calculation(struct cell *c, const struct cosmology *cosmo) {
221 222
  for (int pid = 0; pid < c->stars.count; pid++) {
    stars_end_density(&c->stars.parts[pid], cosmo);
Loic Hausammann's avatar
Loic Hausammann committed
223 224

    /* Recover the common "Neighbour number" definition */
225 226
    c->stars.parts[pid].density.wcount *= pow_dimension(c->stars.parts[pid].h);
    c->stars.parts[pid].density.wcount *= kernel_norm;
Loic Hausammann's avatar
Loic Hausammann committed
227 228 229 230 231 232 233 234 235 236 237
  }
}

/**
 * @brief Dump all the particles to a file
 */
void dump_particle_fields(char *fileName, struct cell *main_cell,
                          struct cell **cells) {
  FILE *file = fopen(fileName, "w");

  /* Write header */
238 239
  fprintf(file, "# %4s %10s %10s %10s %13s %13s\n", "ID", "pos_x", "pos_y",
          "pos_z", "wcount", "wcount_dh");
Loic Hausammann's avatar
Loic Hausammann committed
240 241 242 243

  fprintf(file, "# Main cell --------------------------------------------\n");

  /* Write main cell */
244 245 246 247 248 249
  for (int pid = 0; pid < main_cell->stars.count; pid++) {
    fprintf(file, "%6llu %10f %10f %10f %13e %13e\n",
            main_cell->stars.parts[pid].id, main_cell->stars.parts[pid].x[0],
            main_cell->stars.parts[pid].x[1], main_cell->stars.parts[pid].x[2],
            main_cell->stars.parts[pid].density.wcount,
            main_cell->stars.parts[pid].density.wcount_dh);
Loic Hausammann's avatar
Loic Hausammann committed
250 251 252 253 254 255 256 257 258 259 260 261 262
  }

  /* Write all other cells */
  for (int i = 0; i < 3; ++i) {
    for (int j = 0; j < 3; ++j) {
      for (int k = 0; k < 3; ++k) {
        struct cell *cj = cells[i * 9 + j * 3 + k];
        if (cj == main_cell) continue;

        fprintf(file,
                "# Offset: [%2d %2d %2d] -----------------------------------\n",
                i - 1, j - 1, k - 1);

263 264 265 266 267 268
        for (int pjd = 0; pjd < cj->stars.count; pjd++) {
          fprintf(file, "%6llu %10f %10f %10f %13e %13e\n",
                  cj->stars.parts[pjd].id, cj->stars.parts[pjd].x[0],
                  cj->stars.parts[pjd].x[1], cj->stars.parts[pjd].x[2],
                  cj->stars.parts[pjd].density.wcount,
                  cj->stars.parts[pjd].density.wcount_dh);
Loic Hausammann's avatar
Loic Hausammann committed
269 270 271 272 273 274 275 276
        }
      }
    }
  }
  fclose(file);
}

/* Just a forward declaration... */
277
void runner_dopair_branch_stars_density(struct runner *r, struct cell *ci,
278
                                        struct cell *cj);
279 280
void runner_doself_branch_stars_density(struct runner *r, struct cell *c);
void runner_dopair_subset_branch_stars_density(struct runner *r,
281 282 283 284
                                               struct cell *restrict ci,
                                               struct spart *restrict sparts_i,
                                               int *restrict ind, int scount,
                                               struct cell *restrict cj);
285
void runner_doself_subset_branch_stars_density(struct runner *r,
286 287 288
                                               struct cell *restrict ci,
                                               struct spart *restrict sparts,
                                               int *restrict ind, int scount);
Loic Hausammann's avatar
Loic Hausammann committed
289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331

/* And go... */
int main(int argc, char *argv[]) {

#ifdef HAVE_SETAFFINITY
  engine_pin();
#endif

  size_t runs = 0, particles = 0;
  size_t sparticles = 0;
  double h = 1.23485, size = 1.;
  double perturbation = 0., h_pert = 0.;
  char outputFileNameExtension[100] = "";
  char outputFileName[200] = "";

  /* Initialize CPU frequency, this also starts time. */
  unsigned long long cpufreq = 0;
  clocks_set_cpufreq(cpufreq);

/* Choke on FP-exceptions */
#ifdef HAVE_FE_ENABLE_EXCEPT
  feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW);
#endif

  /* Get some randomness going */
  srand(0);

  char c;
  while ((c = getopt(argc, argv, "s:h:p:n:N:r:t:d:f:")) != -1) {
    switch (c) {
      case 'h':
        sscanf(optarg, "%lf", &h);
        break;
      case 'p':
        sscanf(optarg, "%lf", &h_pert);
        break;
      case 's':
        sscanf(optarg, "%lf", &size);
        break;
      case 'n':
        sscanf(optarg, "%zu", &particles);
        break;
      case 'N':
332 333
        sscanf(optarg, "%zu", &sparticles);
        break;
Loic Hausammann's avatar
Loic Hausammann committed
334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350
      case 'r':
        sscanf(optarg, "%zu", &runs);
        break;
      case 'd':
        sscanf(optarg, "%lf", &perturbation);
        break;
      case 'f':
        strcpy(outputFileNameExtension, optarg);
        break;
      case '?':
        error("Unknown option.");
        break;
    }
  }

  if (h < 0 || particles == 0 || runs == 0 || sparticles == 0) {
    printf(
351 352
        "\nUsage: %s -n PARTICLES_PER_AXIS -N SPARTICLES_PER_AXIS -r "
        "NUMBER_OF_RUNS [OPTIONS...]\n"
Loic Hausammann's avatar
Loic Hausammann committed
353
        "\nGenerates 27 cells, filled with particles on a Cartesian grid."
354 355
        "\nThese are then interacted using runner_dopair_stars_density() and "
        "runner_doself_stars_density()."
Loic Hausammann's avatar
Loic Hausammann committed
356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388
        "\n\nOptions:"
        "\n-h DISTANCE=1.2348 - Smoothing length in units of <x>"
        "\n-p                 - Random fractional change in h, h=h*random(1,p)"
        "\n-s size            - Physical size of the cell"
        "\n-d pert            - Perturbation to apply to the particles [0,1["
        "\n-f fileName        - Part of the file name used to save the dumps\n",
        argv[0]);
    exit(1);
  }

  /* Help users... */
  message("DOSELF1 function called: %s", DOSELF1_NAME);
  message("DOPAIR1 function called: %s", DOPAIR1_NAME);
  message("Smoothing length: h = %f", h * size);
  message("Kernel:               %s", kernel_name);
  message("Neighbour target: N = %f", pow_dimension(h) * kernel_norm);

  printf("\n");

  /* Build the infrastructure */
  struct space space;
  space.periodic = 1;
  space.dim[0] = 3.;
  space.dim[1] = 3.;
  space.dim[2] = 3.;

  struct hydro_props hp;
  hp.eta_neighbours = h;
  hp.h_tolerance = 1e0;
  hp.h_max = FLT_MAX;
  hp.max_smoothing_iterations = 1;
  hp.CFL_condition = 0.1;

389 390 391 392
  struct stars_props stars_p;
  stars_p.eta_neighbours = h;
  stars_p.h_tolerance = 1e0;
  stars_p.max_smoothing_iterations = 1;
Loic Hausammann's avatar
Loic Hausammann committed
393 394 395 396 397 398 399

  struct engine engine;
  engine.s = &space;
  engine.time = 0.1f;
  engine.ti_current = 8;
  engine.max_active_bin = num_time_bins;
  engine.hydro_properties = &hp;
400
  engine.stars_properties = &stars_p;
Loic Hausammann's avatar
Loic Hausammann committed
401 402 403 404 405 406 407 408 409 410 411 412 413
  engine.nodeID = NODE_ID;

  struct cosmology cosmo;
  cosmology_init_no_cosmo(&cosmo);
  engine.cosmology = &cosmo;

  struct runner runner;
  runner.e = &engine;

  /* Construct some cells */
  struct cell *cells[27];
  struct cell *main_cell;
  static long long partId = 0;
414 415
  long long spartId = particles * particles * particles * 27;

Loic Hausammann's avatar
Loic Hausammann committed
416 417 418 419 420
  for (int i = 0; i < 3; ++i) {
    for (int j = 0; j < 3; ++j) {
      for (int k = 0; k < 3; ++k) {
        double offset[3] = {i * size, j * size, k * size};
        cells[i * 9 + j * 3 + k] =
421 422
            make_cell(particles, sparticles, offset, size, h, &partId, &spartId,
                      perturbation, h_pert);
Loic Hausammann's avatar
Loic Hausammann committed
423 424

        runner_do_drift_part(&runner, cells[i * 9 + j * 3 + k], 0);
425
        runner_do_drift_spart(&runner, cells[i * 9 + j * 3 + k], 0);
Loic Hausammann's avatar
Loic Hausammann committed
426

Loic Hausammann's avatar
Loic Hausammann committed
427 428
        runner_do_hydro_sort(&runner, cells[i * 9 + j * 3 + k], 0x1FFF, 0, 0);
        runner_do_stars_sort(&runner, cells[i * 9 + j * 3 + k], 0x1FFF, 0, 0);
Loic Hausammann's avatar
Loic Hausammann committed
429 430 431
      }
    }
  }
432

Loic Hausammann's avatar
Loic Hausammann committed
433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448
  /* Store the main cell for future use */
  main_cell = cells[13];

  ticks timings[27];
  for (int i = 0; i < 27; i++) timings[i] = 0;

  ticks time = 0;
  for (size_t i = 0; i < runs; ++i) {
    /* Zero the fields */
    for (int j = 0; j < 27; ++j) zero_particle_fields(cells[j]);

    const ticks tic = getticks();

#if defined(TEST_DOSELF_SUBSET) || defined(TEST_DOPAIR_SUBSET)
    int *pid = NULL;
    int scount = 0;
449
    if ((pid = (int *)malloc(sizeof(int) * main_cell->stars.count)) == NULL)
Loic Hausammann's avatar
Loic Hausammann committed
450
      error("Can't allocate memory for pid.");
451 452
    for (int k = 0; k < main_cell->stars.count; k++)
      if (spart_is_active(&main_cell->stars.parts[k], &engine)) {
Loic Hausammann's avatar
Loic Hausammann committed
453 454 455 456 457 458 459 460 461 462 463
        pid[scount] = k;
        ++scount;
      }
#endif

    /* Run all the pairs */
    for (int j = 0; j < 27; ++j) {
      if (cells[j] != main_cell) {
        const ticks sub_tic = getticks();

#ifdef TEST_DOPAIR_SUBSET
464
        DOPAIR1_SUBSET(&runner, main_cell, main_cell->stars.parts, pid, scount,
Loic Hausammann's avatar
Loic Hausammann committed
465 466 467 468 469 470 471 472 473 474 475 476 477
                       cells[j]);
#else
        DOPAIR1(&runner, main_cell, cells[j]);
#endif

        timings[j] += getticks() - sub_tic;
      }
    }

    /* And now the self-interaction */
    const ticks self_tic = getticks();

#ifdef TEST_DOSELF_SUBSET
478
    DOSELF1_SUBSET(&runner, main_cell, main_cell->stars.parts, pid, scount);
Loic Hausammann's avatar
Loic Hausammann committed
479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524
#else
    DOSELF1(&runner, main_cell);
#endif

    timings[13] += getticks() - self_tic;

    const ticks toc = getticks();
    time += toc - tic;

    /* Let's get physical ! */
    end_calculation(main_cell, &cosmo);

    /* Dump if necessary */
    if (i % 50 == 0) {
      sprintf(outputFileName, "swift_star_dopair_27_%.150s.dat",
              outputFileNameExtension);
      dump_particle_fields(outputFileName, main_cell, cells);
    }
  }

  /* Output timing */
  ticks corner_time = timings[0] + timings[2] + timings[6] + timings[8] +
                      timings[18] + timings[20] + timings[24] + timings[26];

  ticks edge_time = timings[1] + timings[3] + timings[5] + timings[7] +
                    timings[9] + timings[11] + timings[15] + timings[17] +
                    timings[19] + timings[21] + timings[23] + timings[25];

  ticks face_time = timings[4] + timings[10] + timings[12] + timings[14] +
                    timings[16] + timings[22];

  message("Corner calculations took       : %15lli ticks.", corner_time / runs);
  message("Edge calculations took         : %15lli ticks.", edge_time / runs);
  message("Face calculations took         : %15lli ticks.", face_time / runs);
  message("Self calculations took         : %15lli ticks.", timings[13] / runs);
  message("SWIFT calculation took         : %15lli ticks.", time / runs);

  /* Now perform a brute-force version for accuracy tests */

  /* Zero the fields */
  for (int i = 0; i < 27; ++i) zero_particle_fields(cells[i]);

  const ticks tic = getticks();

  /* Run all the brute-force pairs */
  for (int j = 0; j < 27; ++j)
525 526
    if (cells[j] != main_cell)
      pairs_all_stars_density(&runner, main_cell, cells[j]);
Loic Hausammann's avatar
Loic Hausammann committed
527 528

  /* And now the self-interaction */
529
  self_all_stars_density(&runner, main_cell);
Loic Hausammann's avatar
Loic Hausammann committed
530 531 532 533 534 535 536

  const ticks toc = getticks();

  /* Let's get physical ! */
  end_calculation(main_cell, &cosmo);

  /* Dump */
537 538
  sprintf(outputFileName, "star_brute_force_27_%.150s.dat",
          outputFileNameExtension);
Loic Hausammann's avatar
Loic Hausammann committed
539 540 541 542 543 544 545 546 547 548
  dump_particle_fields(outputFileName, main_cell, cells);

  /* Output timing */
  message("Brute force calculation took : %15lli ticks.", toc - tic);

  /* Clean things to make the sanitizer happy ... */
  for (int i = 0; i < 27; ++i) clean_up(cells[i]);

  return 0;
}