testPeriodicBC.c 20.4 KB
Newer Older
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
33
34
35
/*******************************************************************************
 * 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"

#define ACC_THRESHOLD 1e-5

#if defined(WITH_VECTORIZATION)
36
#define DOSELF1 runner_doself1_branch_density
37
#define DOPAIR1 runner_dopair1_branch_density
38
39
40
41
42
#define DOSELF1_NAME "runner_doself1_density_vec"
#define DOPAIR1_NAME "runner_dopair1_density_vec"
#endif

#ifndef DOSELF1
43
#define DOSELF1 runner_doself1_branch_density
44
45
46
47
#define DOSELF1_NAME "runner_doself1_density"
#endif

#ifndef DOPAIR1
48
#define DOPAIR1 runner_dopair1_branch_density
49
50
51
#define DOPAIR1_NAME "runner_dopair1_density"
#endif

52
#define NODE_ID 0
53

54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
enum velocity_types {
  velocity_zero,
  velocity_random,
  velocity_divergent,
  velocity_rotating
};

/**
 * @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.
 * @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.
 * @param density The density of the fluid.
 * @param partId The running counter of IDs.
 * @param pert The perturbation to apply to the particles in the cell in units
 *of the inter-particle separation.
 * @param vel The type of velocity field (0, random, divergent, rotating)
 */
struct cell *make_cell(size_t n, double *offset, double size, double h,
77
78
                       double density, long long *partId, double pert,
                       enum velocity_types vel) {
79
80
  const size_t count = n * n * n;
  const double volume = size * size * size;
81
82
83
84
  struct cell *cell = NULL;
  if (posix_memalign((void **)&cell, cell_align, sizeof(struct cell)) != 0) {
    error("couldn't allocate cell");
  }
85
86
  bzero(cell, sizeof(struct cell));

87
  if (posix_memalign((void **)&cell->hydro.parts, part_align,
88
                     count * sizeof(struct part)) != 0) {
89
90
    error("couldn't allocate particles, no. of particles: %d", (int)count);
  }
91
  bzero(cell->hydro.parts, count * sizeof(struct part));
92
93
94
95

  float h_max = 0.f;

  /* Construct the parts */
96
  struct part *part = cell->hydro.parts;
97
98
99
100
  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] =
101
102
            offset[0] +
            size * (x + 0.5 + random_uniform(-0.5, 0.5) * pert) / (float)n;
103
        part->x[1] =
104
105
            offset[1] +
            size * (y + 0.5 + random_uniform(-0.5, 0.5) * pert) / (float)n;
106
        part->x[2] =
107
108
            offset[2] +
            size * (z + 0.5 + random_uniform(-0.5, 0.5) * pert) / (float)n;
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
        switch (vel) {
          case velocity_zero:
            part->v[0] = 0.f;
            part->v[1] = 0.f;
            part->v[2] = 0.f;
            break;
          case velocity_random:
            part->v[0] = random_uniform(-0.05, 0.05);
            part->v[1] = random_uniform(-0.05, 0.05);
            part->v[2] = random_uniform(-0.05, 0.05);
            break;
          case velocity_divergent:
            part->v[0] = part->x[0] - 1.5 * size;
            part->v[1] = part->x[1] - 1.5 * size;
            part->v[2] = part->x[2] - 1.5 * size;
            break;
          case velocity_rotating:
            part->v[0] = part->x[1];
            part->v[1] = -part->x[0];
            part->v[2] = 0.f;
            break;
        }
        part->h = size * h / (float)n;
        h_max = fmax(h_max, part->h);
        part->id = ++(*partId);

135
#if defined(GIZMO_MFV_SPH) || defined(SHADOWFAX_SPH)
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
        part->conserved.mass = density * volume / count;

#ifdef SHADOWFAX_SPH
        double anchor[3] = {0., 0., 0.};
        double side[3] = {1., 1., 1.};
        voronoi_cell_init(&part->cell, part->x, anchor, side);
#endif

#else
        part->mass = density * volume / count;
#endif

#if defined(HOPKINS_PE_SPH)
        part->entropy = 1.f;
        part->entropy_one_over_gamma = 1.f;
#endif

        part->time_bin = 1;

#ifdef SWIFT_DEBUG_CHECKS
        part->ti_drift = 8;
        part->ti_kick = 8;
#endif

        ++part;
      }
    }
  }

  /* Cell properties */
  cell->split = 0;
167
168
  cell->hydro.h_max = h_max;
  cell->hydro.count = count;
169
  cell->hydro.dx_max_part = 0.;
170
  cell->hydro.dx_max_sort = 0.;
171
172
173
174
175
176
177
  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];

178
  cell->hydro.ti_old_part = 8;
179
180
  cell->hydro.ti_end_min = 8;
  cell->hydro.ti_end_max = 8;
181
  cell->nodeID = NODE_ID;
182

183
  shuffle_particles(cell->hydro.parts, cell->hydro.count);
184

185
186
  cell->hydro.sorted = 0;
  for (int k = 0; k < 13; k++) cell->hydro.sort[k] = NULL;
187
188
189
190
191

  return cell;
}

void clean_up(struct cell *ci) {
192
  free(ci->hydro.parts);
193
  for (int k = 0; k < 13; k++)
194
    if (ci->hydro.sort[k] != NULL) free(ci->hydro.sort[k]);
195
196
197
198
199
200
201
  free(ci);
}

/**
 * @brief Initializes all particles field to be ready for a density calculation
 */
void zero_particle_fields(struct cell *c) {
202
203
  for (int pid = 0; pid < c->hydro.count; pid++) {
    hydro_init_part(&c->hydro.parts[pid], NULL);
204
205
206
207
208
209
  }
}

/**
 * @brief Ends the loop by adding the appropriate coefficients
 */
210
void end_calculation(struct cell *c, const struct cosmology *cosmo) {
211
212
  for (int pid = 0; pid < c->hydro.count; pid++) {
    hydro_end_density(&c->hydro.parts[pid], cosmo);
213
214
215
216
217
218
  }
}

/**
 * @brief Dump all the particles to a file
 */
Matthieu Schaller's avatar
Matthieu Schaller committed
219
220
void dump_particle_fields(char *fileName, struct cell *main_cell, int i, int j,
                          int k) {
221
  FILE *file = fopen(fileName, "a");
222
223
224

  /* Write header */
  fprintf(file,
225
226
227
228
          "# %4s %10s %10s %10s %10s %10s %10s %13s %13s %13s %13s %13s "
          "%13s %13s %13s\n",
          "ID", "pos_x", "pos_y", "pos_z", "v_x", "v_y", "v_z", "rho", "rho_dh",
          "wcount", "wcount_dh", "div_v", "curl_vx", "curl_vy", "curl_vz");
229

Matthieu Schaller's avatar
Matthieu Schaller committed
230
231
  fprintf(file, "# Centre cell at (i,j,k)=(%d, %d, %d) ---------------------\n",
          i, j, k);
232
233

  /* Write main cell */
234
  for (int pid = 0; pid < main_cell->hydro.count; pid++) {
235
    fprintf(file,
236
237
            "%6llu %10f %10f %10f %10f %10f %10f %13e %13e %13e %13e %13e "
            "%13e %13e %13e\n",
238
239
240
241
242
            main_cell->hydro.parts[pid].id, main_cell->hydro.parts[pid].x[0],
            main_cell->hydro.parts[pid].x[1], main_cell->hydro.parts[pid].x[2],
            main_cell->hydro.parts[pid].v[0], main_cell->hydro.parts[pid].v[1],
            main_cell->hydro.parts[pid].v[2],
            hydro_get_comoving_density(&main_cell->hydro.parts[pid]),
243
#if defined(GIZMO_MFV_SPH) || defined(SHADOWFAX_SPH)
244
            0.f,
245
#else
246
            main_cell->hydro.parts[pid].density.rho_dh,
247
#endif
248
249
            main_cell->hydro.parts[pid].density.wcount,
            main_cell->hydro.parts[pid].density.wcount_dh,
250
#if defined(GADGET2_SPH) || defined(HOPKINS_PE_SPH)
251
252
253
254
            main_cell->hydro.parts[pid].density.div_v,
            main_cell->hydro.parts[pid].density.rot_v[0],
            main_cell->hydro.parts[pid].density.rot_v[1],
            main_cell->hydro.parts[pid].density.rot_v[2]
Josh Borrow's avatar
Josh Borrow committed
255
#elif defined(DEFAULT_SPH) || defined(ANARCHY_PU_SPH) || defined(SPHENIX_SPH)
256
257
258
259
            main_cell->hydro.parts[pid].viscosity.div_v,
            main_cell->hydro.parts[pid].density.rot_v[0],
            main_cell->hydro.parts[pid].density.rot_v[1],
            main_cell->hydro.parts[pid].density.rot_v[2]
260
#else
261
            0., 0., 0., 0.
262
#endif
263
    );
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
  }
  fclose(file);
}

/**
 * @brief Compares the vectorised result against
 * the serial result of the interaction.
 *
 * @param serial_parts Particle array that has been interacted serially
 * @param vec_parts Particle array to be interacted using vectors
 * @param count No. of particles that have been interacted
 * @param threshold Level of accuracy needed
 *
 * @return Non-zero value if difference found, 0 otherwise
 */
int check_results(struct part *serial_parts, struct part *vec_parts, int count,
280
                  double threshold) {
281
282
283
  int result = 0;

  for (int i = 0; i < count; i++)
284
    result += compare_particles(&serial_parts[i], &vec_parts[i], threshold);
285
286
287
288
289
290
291

  return result;
}

/* Just a forward declaration... */
void runner_doself1_density(struct runner *r, struct cell *ci);
void runner_doself1_density_vec(struct runner *r, struct cell *ci);
292
293
void runner_dopair1_branch_density(struct runner *r, struct cell *ci,
                                   struct cell *cj);
294
void runner_doself1_branch_density(struct runner *r, struct cell *c);
295

296
void test_boundary_conditions(struct cell **cells, struct runner *runner,
297
298
299
                              const int loc_i, const int loc_j, const int loc_k,
                              const int dim, char *swiftOutputFileName,
                              char *bruteForceOutputFileName) {
300
301

  /* Store the main cell for future use */
302
  struct cell *main_cell = cells[loc_i * (dim * dim) + loc_j * dim + loc_k];
303
304

  /* Zero the fields */
James Willis's avatar
James Willis committed
305
  for (int j = 0; j < dim * dim * dim; ++j) zero_particle_fields(cells[j]);
306

307
/* Run all the pairs */
308
#ifdef WITH_VECTORIZATION
309
310
311
312
  runner->ci_cache.count = 0;
  cache_init(&runner->ci_cache, 512);
  runner->cj_cache.count = 0;
  cache_init(&runner->cj_cache, 512);
313
314
#endif

315
  /* Now loop over all the neighbours of this cell
316
317
318
319
320
321
322
323
324
325
326
327
   * and perform the pair interactions. */
  for (int ii = -1; ii < 2; ii++) {
    int iii = loc_i + ii;
    iii = (iii + dim) % dim;
    for (int jj = -1; jj < 2; jj++) {
      int jjj = loc_j + jj;
      jjj = (jjj + dim) % dim;
      for (int kk = -1; kk < 2; kk++) {
        int kkk = loc_k + kk;
        kkk = (kkk + dim) % dim;

        /* Get the neighbouring cell */
328
        struct cell *cj = cells[iii * (dim * dim) + jjj * dim + kkk];
329

330
        if (cj != main_cell) DOPAIR1(runner, main_cell, cj);
331
332
333
334
335
336
      }
    }
  }

  /* And now the self-interaction */

337
  DOSELF1(runner, main_cell);
338
339

  /* Let's get physical ! */
340
  end_calculation(main_cell, runner->e->cosmology);
341
342

  /* Dump particles from the main cell. */
343
  dump_particle_fields(swiftOutputFileName, main_cell, loc_i, loc_j, loc_k);
344
345
346
347

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

  /* Zero the fields */
James Willis's avatar
James Willis committed
348
  for (int i = 0; i < dim * dim * dim; ++i) zero_particle_fields(cells[i]);
349

350
  /* Now loop over all the neighbours of this cell
351
352
353
354
355
356
357
358
359
360
361
362
   * and perform the pair interactions. */
  for (int ii = -1; ii < 2; ii++) {
    int iii = loc_i + ii;
    iii = (iii + dim) % dim;
    for (int jj = -1; jj < 2; jj++) {
      int jjj = loc_j + jj;
      jjj = (jjj + dim) % dim;
      for (int kk = -1; kk < 2; kk++) {
        int kkk = loc_k + kk;
        kkk = (kkk + dim) % dim;

        /* Get the neighbouring cell */
363
        struct cell *cj = cells[iii * (dim * dim) + jjj * dim + kkk];
364

365
        if (cj != main_cell) pairs_all_density(runner, main_cell, cj);
366
367
368
369
370
      }
    }
  }

  /* And now the self-interaction */
371
  self_all_density(runner, main_cell);
372
373

  /* Let's get physical ! */
374
  end_calculation(main_cell, runner->e->cosmology);
375
376

  /* Dump */
Matthieu Schaller's avatar
Matthieu Schaller committed
377
378
  dump_particle_fields(bruteForceOutputFileName, main_cell, loc_i, loc_j,
                       loc_k);
379
380
}

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

384
#ifdef HAVE_SETAFFINITY
385
  engine_pin();
386
387
#endif

388
389
390
391
  size_t runs = 0, particles = 0;
  double h = 1.23485, size = 1., rho = 1.;
  double perturbation = 0.;
  double threshold = ACC_THRESHOLD;
392
  char outputFileNameExtension[100] = "";
393
394
  char swiftOutputFileName[200] = "";
  char bruteForceOutputFileName[200] = "";
395
396
397
398
399
400
  enum velocity_types vel = velocity_zero;

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

401
402
/* Choke on FP-exceptions */
#ifdef HAVE_FE_ENABLE_EXCEPT
403
  feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW);
404
#endif
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478

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

  char c;
  while ((c = getopt(argc, argv, "m:s:h:n:r:t:d:f:v:a:")) != -1) {
    switch (c) {
      case 'h':
        sscanf(optarg, "%lf", &h);
        break;
      case 's':
        sscanf(optarg, "%lf", &size);
        break;
      case 'n':
        sscanf(optarg, "%zu", &particles);
        break;
      case 'r':
        sscanf(optarg, "%zu", &runs);
        break;
      case 'd':
        sscanf(optarg, "%lf", &perturbation);
        break;
      case 'm':
        sscanf(optarg, "%lf", &rho);
        break;
      case 'f':
        strcpy(outputFileNameExtension, optarg);
        break;
      case 'v':
        sscanf(optarg, "%d", (int *)&vel);
        break;
      case 'a':
        sscanf(optarg, "%lf", &threshold);
        break;
      case '?':
        error("Unknown option.");
        break;
    }
  }

  if (h < 0 || particles == 0 || runs == 0) {
    printf(
        "\nUsage: %s -n PARTICLES_PER_AXIS -r NUMBER_OF_RUNS [OPTIONS...]\n"
        "\nGenerates 27 cells, filled with particles on a Cartesian grid."
        "\nThese are then interacted using runner_dopair1_density() and "
        "runner_doself1_density()."
        "\n\nOptions:"
        "\n-h DISTANCE=1.2348 - Smoothing length in units of <x>"
        "\n-m rho             - Physical density in the cell"
        "\n-s size            - Physical size of the cell"
        "\n-d pert            - Perturbation to apply to the particles [0,1["
        "\n-v type (0,1,2,3)  - Velocity field: (zero, random, divergent, "
        "rotating)"
        "\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("Vector size: %d", VEC_SIZE);
  message("Adiabatic index: ga = %f", hydro_gamma);
  message("Hydro implementation: %s", SPH_IMPLEMENTATION);
  message("Smoothing length: h = %f", h * size);
  message("Kernel:               %s", kernel_name);
  message("Neighbour target: N = %f", pow_dimension(h) * kernel_norm);
  message("Density target: rho = %f", rho);
  message("div_v target:   div = %f", vel == 2 ? 3.f : 0.f);
  message("curl_v target: curl = [0., 0., %f]", vel == 3 ? -2.f : 0.f);

  printf("\n");

  /* Build the infrastructure */
479
  const int dim = 8;
480
481
  struct space space;
  space.periodic = 1;
482
483
484
  space.dim[0] = dim;
  space.dim[1] = dim;
  space.dim[2] = dim;
485
486
487
488
489
490
491
492
493
494

  struct hydro_props hp;
  hp.h_max = FLT_MAX;

  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;
495
  engine.nodeID = NODE_ID;
496

497
498
499
  struct runner real_runner;
  struct runner *runner = &real_runner;
  runner->e = &engine;
500

501
502
503
504
  struct cosmology cosmo;
  cosmology_init_no_cosmo(&cosmo);
  engine.cosmology = &cosmo;

505
  /* Construct some cells */
James Willis's avatar
James Willis committed
506
  struct cell *cells[dim * dim * dim];
507
508
509
510
511
  static long long partId = 0;
  for (int i = 0; i < dim; ++i) {
    for (int j = 0; j < dim; ++j) {
      for (int k = 0; k < dim; ++k) {
        double offset[3] = {i * size, j * size, k * size};
512
513
        cells[i * (dim * dim) + j * dim + k] = make_cell(
            particles, offset, size, h, rho, &partId, perturbation, vel);
514

515
        runner_do_drift_part(runner, cells[i * (dim * dim) + j * dim + k], 0);
516

517
        runner_do_hydro_sort(runner, cells[i * (dim * dim) + j * dim + k],
Loic Hausammann's avatar
Loic Hausammann committed
518
                             0x1FFF, 0, 0);
519
520
521
522
      }
    }
  }

523
  /* Create output file names. */
lhausamm's avatar
lhausamm committed
524
  sprintf(swiftOutputFileName, "swift_periodic_BC_%.150s.dat",
525
          outputFileNameExtension);
lhausamm's avatar
lhausamm committed
526
  sprintf(bruteForceOutputFileName, "brute_force_periodic_BC_%.150s.dat",
527
          outputFileNameExtension);
528

529
530
531
  /* Delete files if they already exist. */
  remove(swiftOutputFileName);
  remove(bruteForceOutputFileName);
532

533
534
  const int half_dim = (dim - 1) / 2;

James Willis's avatar
James Willis committed
535
536
  /* Test the periodic boundary conditions for each of the 8 corners. Interact
   * each corner with all of its 26 neighbours.*/
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
  test_boundary_conditions(cells, runner, 0, 0, 0, dim, swiftOutputFileName,
                           bruteForceOutputFileName);
  test_boundary_conditions(cells, runner, dim - 1, 0, 0, dim,
                           swiftOutputFileName, bruteForceOutputFileName);
  test_boundary_conditions(cells, runner, dim - 1, 0, dim - 1, dim,
                           swiftOutputFileName, bruteForceOutputFileName);
  test_boundary_conditions(cells, runner, 0, 0, dim - 1, dim,
                           swiftOutputFileName, bruteForceOutputFileName);
  test_boundary_conditions(cells, runner, 0, dim - 1, 0, dim,
                           swiftOutputFileName, bruteForceOutputFileName);
  test_boundary_conditions(cells, runner, dim - 1, dim - 1, 0, dim,
                           swiftOutputFileName, bruteForceOutputFileName);
  test_boundary_conditions(cells, runner, 0, dim - 1, dim - 1, dim,
                           swiftOutputFileName, bruteForceOutputFileName);
  test_boundary_conditions(cells, runner, dim - 1, dim - 1, dim - 1, dim,
                           swiftOutputFileName, bruteForceOutputFileName);

  /* Test the boundary conditions for cells at the centre of each face of the
   * box. */
  test_boundary_conditions(cells, runner, half_dim, half_dim, 0, dim,
                           swiftOutputFileName, bruteForceOutputFileName);
  test_boundary_conditions(cells, runner, dim - 1, half_dim, half_dim, dim,
                           swiftOutputFileName, bruteForceOutputFileName);
  test_boundary_conditions(cells, runner, half_dim, half_dim, dim - 1, dim,
                           swiftOutputFileName, bruteForceOutputFileName);
  test_boundary_conditions(cells, runner, 0, half_dim, half_dim, dim,
                           swiftOutputFileName, bruteForceOutputFileName);
  test_boundary_conditions(cells, runner, half_dim, 0, half_dim, dim,
                           swiftOutputFileName, bruteForceOutputFileName);
  test_boundary_conditions(cells, runner, half_dim, dim - 1, half_dim, dim,
                           swiftOutputFileName, bruteForceOutputFileName);

  /* Test the boundary conditions for cells at the centre of each edge of the
   * box. */
  test_boundary_conditions(cells, runner, half_dim, dim - 1, 0, dim,
                           swiftOutputFileName, bruteForceOutputFileName);
  test_boundary_conditions(cells, runner, dim - 1, dim - 1, half_dim, dim,
                           swiftOutputFileName, bruteForceOutputFileName);
  test_boundary_conditions(cells, runner, half_dim, dim - 1, dim - 1, dim,
                           swiftOutputFileName, bruteForceOutputFileName);
  test_boundary_conditions(cells, runner, 0, dim - 1, half_dim, dim,
                           swiftOutputFileName, bruteForceOutputFileName);

  test_boundary_conditions(cells, runner, 0, half_dim, 0, dim,
                           swiftOutputFileName, bruteForceOutputFileName);
  test_boundary_conditions(cells, runner, dim - 1, half_dim, 0, dim,
                           swiftOutputFileName, bruteForceOutputFileName);
  test_boundary_conditions(cells, runner, dim - 1, half_dim, dim - 1, dim,
                           swiftOutputFileName, bruteForceOutputFileName);
  test_boundary_conditions(cells, runner, 0, half_dim, dim - 1, dim,
                           swiftOutputFileName, bruteForceOutputFileName);

  test_boundary_conditions(cells, runner, half_dim, 0, 0, dim,
                           swiftOutputFileName, bruteForceOutputFileName);
  test_boundary_conditions(cells, runner, dim - 1, 0, half_dim, dim,
                           swiftOutputFileName, bruteForceOutputFileName);
  test_boundary_conditions(cells, runner, half_dim, 0, dim - 1, dim,
                           swiftOutputFileName, bruteForceOutputFileName);
  test_boundary_conditions(cells, runner, 0, 0, half_dim, dim,
                           swiftOutputFileName, bruteForceOutputFileName);
597
598

  /* Clean things to make the sanitizer happy ... */
James Willis's avatar
James Willis committed
599
  for (int i = 0; i < dim * dim * dim; ++i) clean_up(cells[i]);
600
601
602

  return 0;
}