testActivePair.c 19.7 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
/*******************************************************************************
 * 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/>.
 *
 ******************************************************************************/
#include "../config.h"

/* Some standard headers. */
#include <fenv.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
26
#include <time.h>
James Willis's avatar
James Willis committed
27
#include <unistd.h>
28
29
30
31

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

32
33
#define NODE_ID 1

34
35
36
/* Typdef function pointer for interaction function. */
typedef void (*interaction_func)(struct runner *, struct cell *, struct cell *);

37
38
39
40
41
42
43
44
45
46
47
48
49
50
/**
 * @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 h_pert The perturbation to apply to the smoothing length.
51
52
 * @param fraction_active The fraction of particles that should be active in the
 * cell.
53
54
 */
struct cell *make_cell(size_t n, double *offset, double size, double h,
55
                       double density, long long *partId, double pert,
56
                       double h_pert, double fraction_active) {
57
58
  const size_t count = n * n * n;
  const double volume = size * size * size;
59
  float h_max = 0.f;
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
  struct cell *cell = malloc(sizeof(struct cell));
  bzero(cell, sizeof(struct cell));

  if (posix_memalign((void **)&cell->parts, part_align,
                     count * sizeof(struct part)) != 0) {
    error("couldn't allocate particles, no. of particles: %d", (int)count);
  }
  bzero(cell->parts, count * sizeof(struct part));

  /* Construct the parts */
  struct part *part = cell->parts;
  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] =
James Willis's avatar
James Willis committed
75
76
            offset[0] +
            size * (x + 0.5 + random_uniform(-0.5, 0.5) * pert) / (float)n;
77
        part->x[1] =
James Willis's avatar
James Willis committed
78
79
            offset[1] +
            size * (y + 0.5 + random_uniform(-0.5, 0.5) * pert) / (float)n;
80
        part->x[2] =
James Willis's avatar
James Willis committed
81
82
            offset[2] +
            size * (z + 0.5 + random_uniform(-0.5, 0.5) * pert) / (float)n;
83
84
85
        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);
86
87
88
89
90
91

        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);
92
        part->id = ++(*partId);
93

94
95
#if defined(GIZMO_SPH) || defined(SHADOWFAX_SPH)
        part->conserved.mass = density * volume / count;
96
97
98
99
100
101
102

#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

103
104
105
#else
        part->mass = density * volume / count;
#endif
106
107
108
109
110

#if defined(HOPKINS_PE_SPH)
        part->entropy = 1.f;
        part->entropy_one_over_gamma = 1.f;
#endif
James Willis's avatar
James Willis committed
111
112
        if (random_uniform(0, 1.f) < fraction_active)
          part->time_bin = 1;
113
114
        else
          part->time_bin = num_time_bins + 1;
115

116
117
118
119
120
121
        part->rho = 1.f;
        part->force.f = 1.f;
        part->force.P_over_rho2 = 1.f;
        part->force.balsara = 1.f;
        part->force.soundspeed = 1.f;

122
123
124
125
126
127
128
129
130
131
132
133
#ifdef SWIFT_DEBUG_CHECKS
        part->ti_drift = 8;
        part->ti_kick = 8;
#endif

        ++part;
      }
    }
  }

  /* Cell properties */
  cell->split = 0;
134
  cell->h_max = h_max;
135
136
137
  cell->count = count;
  cell->dx_max_part = 0.;
  cell->dx_max_sort = 0.;
138
139
140
  cell->width[0] = size;
  cell->width[1] = size;
  cell->width[2] = size;
141
142
143
144
145
  cell->loc[0] = offset[0];
  cell->loc[1] = offset[1];
  cell->loc[2] = offset[2];

  cell->ti_old_part = 8;
146
147
  cell->ti_hydro_end_min = 8;
  cell->ti_hydro_end_max = 10;
Matthieu Schaller's avatar
Matthieu Schaller committed
148
  cell->nodeID = NODE_ID;
149
150
151
152

  shuffle_particles(cell->parts, cell->count);

  cell->sorted = 0;
James Willis's avatar
James Willis committed
153
  for (int k = 0; k < 13; k++) cell->sort[k] = NULL;
James Willis's avatar
James Willis committed
154

155
156
157
158
159
  return cell;
}

void clean_up(struct cell *ci) {
  free(ci->parts);
James Willis's avatar
James Willis committed
160
161
  for (int k = 0; k < 13; k++)
    if (ci->sort[k] != NULL) free(ci->sort[k]);
162
163
164
165
166
167
168
169
170
  free(ci);
}

/**
 * @brief Initializes all particles field to be ready for a density calculation
 */
void zero_particle_fields(struct cell *c) {
  for (int pid = 0; pid < c->count; pid++) {
    hydro_init_part(&c->parts[pid], NULL);
171
172
173
174
175
    c->parts[pid].rho = 1.f;
    c->parts[pid].force.f = 1.f;
    c->parts[pid].force.P_over_rho2 = 1.f;
    c->parts[pid].force.balsara = 1.f;
    c->parts[pid].force.soundspeed = 1.f;
176
177
178
  }
}

179
180
181
/**
 * @brief Ends the loop by adding the appropriate coefficients
 */
182
void end_calculation(struct cell *c, const struct cosmology *cosmo) {
183
  for (int pid = 0; pid < c->count; pid++) {
184
    hydro_end_density(&c->parts[pid], cosmo);
185
186
187
188
189
190
191

    /* Recover the common "Neighbour number" definition */
    c->parts[pid].density.wcount *= pow_dimension(c->parts[pid].h);
    c->parts[pid].density.wcount *= kernel_norm;
  }
}

192
193
194
195
/**
 * @brief Dump all the particles to a file
 */
void dump_particle_fields(char *fileName, struct cell *ci, struct cell *cj) {
196
  FILE *file = fopen(fileName, "a");
197
198

  /* Write header */
199
  fprintf(file, "# %4s %13s %13s\n", "ID", "wcount", "h_dt");
200
201
202
203

  fprintf(file, "# ci --------------------------------------------\n");

  for (int pid = 0; pid < ci->count; pid++) {
204
    fprintf(file, "%6llu %13e %13e\n", ci->parts[pid].id,
James Willis's avatar
James Willis committed
205
            ci->parts[pid].density.wcount, ci->parts[pid].force.h_dt);
206
207
208
209
210
  }

  fprintf(file, "# cj --------------------------------------------\n");

  for (int pjd = 0; pjd < cj->count; pjd++) {
211
    fprintf(file, "%6llu %13e %13e\n", cj->parts[pjd].id,
James Willis's avatar
James Willis committed
212
            cj->parts[pjd].density.wcount, cj->parts[pjd].force.h_dt);
213
214
215
216
217
218
219
  }

  fclose(file);
}

/* Just a forward declaration... */
void runner_dopair1_density(struct runner *r, struct cell *ci, struct cell *cj);
James Willis's avatar
James Willis committed
220
221
void runner_dopair2_force_vec(struct runner *r, struct cell *ci,
                              struct cell *cj);
222
223
224
void runner_doself1_density_vec(struct runner *r, struct cell *ci);
void runner_dopair1_branch_density(struct runner *r, struct cell *ci,
                                   struct cell *cj);
225
void runner_dopair2_branch_force(struct runner *r, struct cell *ci,
James Willis's avatar
James Willis committed
226
                                 struct cell *cj);
227

228
/**
James Willis's avatar
James Willis committed
229
230
 * @brief Computes the pair interactions of two cells using SWIFT and a brute
 * force implementation.
231
 */
James Willis's avatar
James Willis committed
232
233
void test_pair_interactions(struct runner *runner, struct cell **ci,
                            struct cell **cj, char *swiftOutputFileName,
James Willis's avatar
James Willis committed
234
235
236
                            char *bruteForceOutputFileName,
                            interaction_func serial_interaction,
                            interaction_func vec_interaction) {
237

238
239
  runner_do_sort(runner, *ci, 0x1FFF, 0, 0);
  runner_do_sort(runner, *cj, 0x1FFF, 0, 0);
240
241
242
243
244
245

  /* Zero the fields */
  zero_particle_fields(*ci);
  zero_particle_fields(*cj);

  /* Run the test */
246
  vec_interaction(runner, *ci, *cj);
247
248

  /* Let's get physical ! */
249
250
  end_calculation(*ci, runner->e->cosmology);
  end_calculation(*cj, runner->e->cosmology);
James Willis's avatar
James Willis committed
251

252
253
254
255
256
257
258
259
260
261
  /* Dump if necessary */
  dump_particle_fields(swiftOutputFileName, *ci, *cj);

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

  /* Zero the fields */
  zero_particle_fields(*ci);
  zero_particle_fields(*cj);

  /* Run the brute-force test */
262
  serial_interaction(runner, *ci, *cj);
263
264

  /* Let's get physical ! */
265
266
  end_calculation(*ci, runner->e->cosmology);
  end_calculation(*cj, runner->e->cosmology);
267
268
269
270

  dump_particle_fields(bruteForceOutputFileName, *ci, *cj);
}

271
272
273
/**
 * @brief Computes the pair interactions of two cells in various configurations.
 */
James Willis's avatar
James Willis committed
274
275
276
277
278
void test_all_pair_interactions(
    struct runner *runner, double *offset2, size_t particles, double size,
    double h, double rho, long long *partId, double perturbation, double h_pert,
    char *swiftOutputFileName, char *bruteForceOutputFileName,
    interaction_func serial_interaction, interaction_func vec_interaction) {
279
280
281
282

  double offset1[3] = {0, 0, 0};
  struct cell *ci, *cj;

283
  /* Only one particle in each cell. */
James Willis's avatar
James Willis committed
284
285
  ci = make_cell(1, offset1, size, h, rho, partId, perturbation, h_pert, 1.);
  cj = make_cell(1, offset2, size, h, rho, partId, perturbation, h_pert, 1.);
286
287

  test_pair_interactions(runner, &ci, &cj, swiftOutputFileName,
James Willis's avatar
James Willis committed
288
289
                         bruteForceOutputFileName, serial_interaction,
                         vec_interaction);
290
291
292
293

  clean_up(ci);
  clean_up(cj);

294
  /* All active particles. */
James Willis's avatar
James Willis committed
295
296
297
298
  ci = make_cell(particles, offset1, size, h, rho, partId, perturbation, h_pert,
                 1.);
  cj = make_cell(particles, offset2, size, h, rho, partId, perturbation, h_pert,
                 1.);
299

James Willis's avatar
James Willis committed
300
  test_pair_interactions(runner, &ci, &cj, swiftOutputFileName,
James Willis's avatar
James Willis committed
301
302
                         bruteForceOutputFileName, serial_interaction,
                         vec_interaction);
303
304
305
306
307

  clean_up(ci);
  clean_up(cj);

  /* Half particles are active. */
James Willis's avatar
James Willis committed
308
309
310
311
312
313
  ci = make_cell(particles, offset1, size, h, rho, partId, perturbation, h_pert,
                 0.5);
  cj = make_cell(particles, offset2, size, h, rho, partId, perturbation, h_pert,
                 0.5);

  test_pair_interactions(runner, &ci, &cj, swiftOutputFileName,
James Willis's avatar
James Willis committed
314
315
                         bruteForceOutputFileName, serial_interaction,
                         vec_interaction);
316
317
318
319
320

  clean_up(ci);
  clean_up(cj);

  /* All particles inactive. */
James Willis's avatar
James Willis committed
321
322
323
324
  ci = make_cell(particles, offset1, size, h, rho, partId, perturbation, h_pert,
                 0.);
  cj = make_cell(particles, offset2, size, h, rho, partId, perturbation, h_pert,
                 0.);
325

James Willis's avatar
James Willis committed
326
  test_pair_interactions(runner, &ci, &cj, swiftOutputFileName,
James Willis's avatar
James Willis committed
327
328
                         bruteForceOutputFileName, serial_interaction,
                         vec_interaction);
329
330
331
332
333

  clean_up(ci);
  clean_up(cj);

  /* 10% of particles active. */
James Willis's avatar
James Willis committed
334
335
336
337
338
339
  ci = make_cell(particles, offset1, size, h, rho, partId, perturbation, h_pert,
                 0.1);
  cj = make_cell(particles, offset2, size, h, rho, partId, perturbation, h_pert,
                 0.1);

  test_pair_interactions(runner, &ci, &cj, swiftOutputFileName,
James Willis's avatar
James Willis committed
340
341
                         bruteForceOutputFileName, serial_interaction,
                         vec_interaction);
342
343
344
345
346

  clean_up(ci);
  clean_up(cj);

  /* One active cell one inactive cell. */
James Willis's avatar
James Willis committed
347
348
349
350
351
352
  ci = make_cell(particles, offset1, size, h, rho, partId, perturbation, h_pert,
                 1.0);
  cj = make_cell(particles, offset2, size, h, rho, partId, perturbation, h_pert,
                 0.);

  test_pair_interactions(runner, &ci, &cj, swiftOutputFileName,
James Willis's avatar
James Willis committed
353
354
                         bruteForceOutputFileName, serial_interaction,
                         vec_interaction);
355
356
357
358
359

  clean_up(ci);
  clean_up(cj);

  /* One active cell one inactive cell. */
James Willis's avatar
James Willis committed
360
361
362
363
364
365
  ci = make_cell(particles, offset1, size, h, rho, partId, perturbation, h_pert,
                 0.);
  cj = make_cell(particles, offset2, size, h, rho, partId, perturbation, h_pert,
                 1.0);

  test_pair_interactions(runner, &ci, &cj, swiftOutputFileName,
James Willis's avatar
James Willis committed
366
367
                         bruteForceOutputFileName, serial_interaction,
                         vec_interaction);
368
369
370
371
372
373
374
375

  clean_up(ci);
  clean_up(cj);

  /* Smaller cells, all active. */
  ci = make_cell(2, offset1, size, h, rho, partId, perturbation, h_pert, 1.0);
  cj = make_cell(2, offset2, size, h, rho, partId, perturbation, h_pert, 1.0);

James Willis's avatar
James Willis committed
376
  test_pair_interactions(runner, &ci, &cj, swiftOutputFileName,
James Willis's avatar
James Willis committed
377
378
                         bruteForceOutputFileName, serial_interaction,
                         vec_interaction);
James Willis's avatar
James Willis committed
379

380
381
382
383
384
385
386
  clean_up(ci);
  clean_up(cj);

  /* Different numbers of particles in each cell. */
  ci = make_cell(10, offset1, size, h, rho, partId, perturbation, h_pert, 0.5);
  cj = make_cell(3, offset2, size, h, rho, partId, perturbation, h_pert, 0.75);

James Willis's avatar
James Willis committed
387
  test_pair_interactions(runner, &ci, &cj, swiftOutputFileName,
James Willis's avatar
James Willis committed
388
389
                         bruteForceOutputFileName, serial_interaction,
                         vec_interaction);
James Willis's avatar
James Willis committed
390

391
392
393
394
  clean_up(ci);
  clean_up(cj);

  /* One cell inactive and the other only half active. */
James Willis's avatar
James Willis committed
395
396
397
398
399
400
  ci = make_cell(particles, offset1, size, h, rho, partId, perturbation, h_pert,
                 0.5);
  cj = make_cell(particles, offset2, size, h, rho, partId, perturbation, h_pert,
                 0.);

  test_pair_interactions(runner, &ci, &cj, swiftOutputFileName,
James Willis's avatar
James Willis committed
401
402
                         bruteForceOutputFileName, serial_interaction,
                         vec_interaction);
403
404
405

  clean_up(ci);
  clean_up(cj);
James Willis's avatar
James Willis committed
406

407
  /* One cell inactive and the other only half active. */
James Willis's avatar
James Willis committed
408
409
410
411
412
413
  ci = make_cell(particles, offset1, size, h, rho, partId, perturbation, h_pert,
                 0.);
  cj = make_cell(particles, offset2, size, h, rho, partId, perturbation, h_pert,
                 0.5);

  test_pair_interactions(runner, &ci, &cj, swiftOutputFileName,
James Willis's avatar
James Willis committed
414
415
                         bruteForceOutputFileName, serial_interaction,
                         vec_interaction);
416
417
418
419
420
421

  /* Clean things to make the sanitizer happy ... */
  clean_up(ci);
  clean_up(cj);
}

422
int main(int argc, char *argv[]) {
423
  size_t particles = 0, runs = 0, type = 0;
424
  double h = 1.23485, size = 1., rho = 1.;
425
  double perturbation = 0.1, h_pert = 1.1;
426
427
  struct space space;
  struct engine engine;
428
  struct cosmology cosmo;
429
  struct runner *runner;
430
  char c;
431
  static long long partId = 0;
432
  char outputFileNameExtension[100] = "";
433
434
  char swiftOutputFileName[200] = "";
  char bruteForceOutputFileName[200] = "";
435
436
437
438
439

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

440
441
/* Choke on FP-exceptions */
#ifdef HAVE_FE_ENABLE_EXCEPT
442
  feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW);
443
#endif
444

445
446
  /* Generate a RNG seed from time. */
  unsigned int seed = time(NULL);
447

448
  while ((c = getopt(argc, argv, "h:p:n:r:t:d:s:f:")) != -1) {
449
450
451
452
453
    switch (c) {
      case 'h':
        sscanf(optarg, "%lf", &h);
        break;
      case 'p':
454
455
456
        sscanf(optarg, "%lf", &h_pert);
        break;
      case 'n':
457
458
459
460
461
462
463
464
465
466
467
        sscanf(optarg, "%zu", &particles);
        break;
      case 'r':
        sscanf(optarg, "%zu", &runs);
        break;
      case 't':
        sscanf(optarg, "%zu", &type);
        break;
      case 'd':
        sscanf(optarg, "%lf", &perturbation);
        break;
468
469
470
      case 's':
        sscanf(optarg, "%u", &seed);
        break;
471
472
473
474
475
476
477
478
479
480
481
      case 'f':
        strcpy(outputFileNameExtension, optarg);
        break;
      case '?':
        error("Unknown option.");
        break;
    }
  }

  if (h < 0 || particles == 0 || runs == 0 || type > 2) {
    printf(
482
        "\nUsage: %s -n PARTICLES_PER_AXIS -r NUMBER_OF_RUNS [OPTIONS...]\n"
483
484
485
486
        "\nGenerates a cell pair, filled with particles on a Cartesian grid."
        "\nThese are then interacted using runner_dopair1_density."
        "\n\nOptions:"
        "\n-t TYPE=0          - cells share face (0), edge (1) or corner (2)"
487
488
        "\n-h DISTANCE=1.2348 - smoothing length"
        "\n-p                 - Random fractional change in h, h=h*random(1,p)"
489
        "\n-d pert            - perturbation to apply to the particles [0,1["
490
        "\n-s seed            - seed for RNG"
491
492
493
494
495
        "\n-f fileName        - part of the file name used to save the dumps\n",
        argv[0]);
    exit(1);
  }

496
497
498
  /* Seed RNG. */
  message("Seed used for RNG: %d", seed);
  srand(seed);
James Willis's avatar
James Willis committed
499

500
  space.periodic = 0;
James Willis's avatar
James Willis committed
501
502
503
  space.dim[0] = 3.;
  space.dim[1] = 3.;
  space.dim[2] = 3.;
504
505
506
507
508

  engine.s = &space;
  engine.time = 0.1f;
  engine.ti_current = 8;
  engine.max_active_bin = num_time_bins;
509
  engine.nodeID = NODE_ID;
James Willis's avatar
James Willis committed
510

511
512
513
  cosmology_init_no_cosmo(&cosmo);
  engine.cosmology = &cosmo;

514
515
  if (posix_memalign((void **)&runner, SWIFT_STRUCT_ALIGNMENT,
                     sizeof(struct runner)) != 0) {
516
517
    error("couldn't allocate runner");
  }
James Willis's avatar
James Willis committed
518

519
  runner->e = &engine;
520

521
  /* Create output file names. */
James Willis's avatar
James Willis committed
522
  sprintf(swiftOutputFileName, "swift_dopair_%s.dat", outputFileNameExtension);
523
  sprintf(bruteForceOutputFileName, "brute_force_pair_%s.dat",
524
          outputFileNameExtension);
James Willis's avatar
James Willis committed
525

526
527
528
529
530
531
532
533
534
535
536
  /* Delete files if they already exist. */
  remove(swiftOutputFileName);
  remove(bruteForceOutputFileName);

#ifdef WITH_VECTORIZATION
  runner->ci_cache.count = 0;
  cache_init(&runner->ci_cache, 512);
  runner->cj_cache.count = 0;
  cache_init(&runner->cj_cache, 512);
#endif

James Willis's avatar
James Willis committed
537
  double offset[3] = {1., 0., 0.};
538

539
540
541
542
  /* Define which interactions to call */
  interaction_func serial_inter_func = &pairs_all_density;
  interaction_func vec_inter_func = &runner_dopair1_branch_density;

543
  /* Test a pair of cells face-on. */
James Willis's avatar
James Willis committed
544
545
  test_all_pair_interactions(runner, offset, particles, size, h, rho, &partId,
                             perturbation, h_pert, swiftOutputFileName,
James Willis's avatar
James Willis committed
546
547
                             bruteForceOutputFileName, serial_inter_func,
                             vec_inter_func);
548
549
550
551
552
553
554

  /* Test a pair of cells edge-on. */
  offset[0] = 1.;
  offset[1] = 1.;
  offset[2] = 0.;
  test_all_pair_interactions(runner, offset, particles, size, h, rho, &partId,
                             perturbation, h_pert, swiftOutputFileName,
James Willis's avatar
James Willis committed
555
556
                             bruteForceOutputFileName, serial_inter_func,
                             vec_inter_func);
557
558
559
560
561
562
563

  /* Test a pair of cells corner-on. */
  offset[0] = 1.;
  offset[1] = 1.;
  offset[2] = 1.;
  test_all_pair_interactions(runner, offset, particles, size, h, rho, &partId,
                             perturbation, h_pert, swiftOutputFileName,
James Willis's avatar
James Willis committed
564
565
566
                             bruteForceOutputFileName, serial_inter_func,
                             vec_inter_func);

567
568
  /* Re-assign function pointers. */
  serial_inter_func = &pairs_all_force;
569
  vec_inter_func = &runner_dopair2_branch_force;
570
571

  /* Create new output file names. */
James Willis's avatar
James Willis committed
572
573
  sprintf(swiftOutputFileName, "swift_dopair2_force_%s.dat",
          outputFileNameExtension);
574
575
576
577
578
579
  sprintf(bruteForceOutputFileName, "brute_force_dopair2_%s.dat",
          outputFileNameExtension);

  /* Delete files if they already exist. */
  remove(swiftOutputFileName);
  remove(bruteForceOutputFileName);
James Willis's avatar
James Willis committed
580

581
  /* Test a pair of cells face-on. */
582
583
584
  offset[0] = 1.;
  offset[1] = 0.;
  offset[2] = 0.;
James Willis's avatar
James Willis committed
585
586
  test_all_pair_interactions(runner, offset, particles, size, h, rho, &partId,
                             perturbation, h_pert, swiftOutputFileName,
James Willis's avatar
James Willis committed
587
588
                             bruteForceOutputFileName, serial_inter_func,
                             vec_inter_func);
James Willis's avatar
James Willis committed
589

590
  /* Test a pair of cells edge-on. */
James Willis's avatar
James Willis committed
591
592
593
594
595
  offset[0] = 1.;
  offset[1] = 1.;
  offset[2] = 0.;
  test_all_pair_interactions(runner, offset, particles, size, h, rho, &partId,
                             perturbation, h_pert, swiftOutputFileName,
James Willis's avatar
James Willis committed
596
597
                             bruteForceOutputFileName, serial_inter_func,
                             vec_inter_func);
598

599
  /* Test a pair of cells corner-on. */
James Willis's avatar
James Willis committed
600
601
602
603
604
  offset[0] = 1.;
  offset[1] = 1.;
  offset[2] = 1.;
  test_all_pair_interactions(runner, offset, particles, size, h, rho, &partId,
                             perturbation, h_pert, swiftOutputFileName,
James Willis's avatar
James Willis committed
605
606
                             bruteForceOutputFileName, serial_inter_func,
                             vec_inter_func);
607
608
  return 0;
}