Commit 9fd4d911 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Call generic functions in tools.c to alow for different particle definitions.

parent 6ff8d705
......@@ -108,7 +108,7 @@ __attribute__((always_inline)) INLINE static int get_part_timestep(
e->external_potential, e->physical_constants, p->gpart);
/* const float new_dt_self = */
/* gravity_compute_timestep_self(e->physical_constants, p->gpart); */
const float new_dt_self = FLT_MAX; // MATTHIEU
const float new_dt_self = FLT_MAX; // MATTHIEU
new_dt_grav = fminf(new_dt_external, new_dt_self);
}
......
......@@ -144,10 +144,7 @@ void pairs_single_density(double *dim, long long int pid,
p = parts[k];
printf("pairs_single: part[%i].id == %lli.\n", k, pid);
p.rho = 0.0;
p.density.wcount = 0.0;
// p.icount = 0;
p.rho_dh = 0.0;
hydro_init_part(&p);
/* Loop over all particle pairs. */
for (k = 0; k < N; k++) {
......@@ -487,25 +484,24 @@ void density_dump(int N) {
*/
void engine_single_density(double *dim, long long int pid,
struct part *restrict parts, int N, int periodic) {
int i, k;
double r2, dx[3];
float fdx[3], ih;
float fdx[3];
struct part p;
/* Find "our" part. */
int k;
for (k = 0; k < N && parts[k].id != pid; k++)
;
if (k == N) error("Part not found.");
p = parts[k];
/* Clear accumulators. */
ih = 1.0f / p.h;
hydro_init_part(&p);
/* Loop over all particle pairs (force). */
for (k = 0; k < N; k++) {
for (int k = 0; k < N; k++) {
if (parts[k].id == p.id) continue;
for (i = 0; i < 3; i++) {
for (int i = 0; i < 3; i++) {
dx[i] = p.x[i] - parts[k].x[i];
if (periodic) {
if (dx[i] < -dim[i] / 2)
......@@ -522,10 +518,7 @@ void engine_single_density(double *dim, long long int pid,
}
/* Dump the result. */
p.rho = ih * ih * ih * (p.rho + p.mass * kernel_root);
p.rho_dh = p.rho_dh * ih * ih * ih * ih;
p.density.wcount =
(p.density.wcount + kernel_root) * (4.0f / 3.0 * M_PI * kernel_gamma3);
hydro_end_density(&p, 0);
message("part %lli (h=%e) has wcount=%e, rho=%e, rho_dh=%e.", p.id, p.h,
p.density.wcount, p.rho, p.rho_dh);
fflush(stdout);
......
......@@ -328,15 +328,16 @@ void dump_particle_fields(char *fileName, struct cell *main_cell,
hydro_get_soundspeed(&main_cell->parts[pid], 0.f),
main_cell->parts[pid].a_hydro[0], main_cell->parts[pid].a_hydro[1],
main_cell->parts[pid].a_hydro[2], main_cell->parts[pid].force.h_dt,
main_cell->parts[pid].force.v_sig,
#if defined(GADGET2_SPH)
main_cell->parts[pid].entropy_dt, 0.f
main_cell->parts[pid].force.v_sig, main_cell->parts[pid].entropy_dt,
0.f
#elif defined(DEFAULT_SPH)
0.f, main_cell->parts[pid].force.u_dt
main_cell->parts[pid].force.v_sig, 0.f,
main_cell->parts[pid].force.u_dt
#elif defined(MINIMAL_SPH)
0.f, main_cell->parts[pid].u_dt
main_cell->parts[pid].force.v_sig, 0.f, main_cell->parts[pid].u_dt
#else
0.f, 0.f
0.f, 0.f, 0.f
#endif
);
}
......
......@@ -17,6 +17,12 @@
*
******************************************************************************/
#include "../config.h"
#ifndef WITH_VECTORIZATION
int main() { return 0; }
#else
#include <fenv.h>
#include <stdio.h>
#include <stdlib.h>
......@@ -138,7 +144,7 @@ void write_header(char *fileName) {
fclose(file);
}
/*
/**
* @brief Calls the serial and vectorised version of the non-symmetrical density
* interaction.
*
......@@ -324,3 +330,5 @@ int main(int argc, char *argv[]) {
return 0;
}
#endif /* WITH_VECTORIZATION */
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment