Skip to content
Snippets Groups Projects
Commit cde5f99c authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Fix the tests with the new removal of particle fields.

parent 72945cae
Branches
Tags
1 merge request!223Merge Gizmo-SPH into the master branch
......@@ -197,12 +197,11 @@ void reset_particles(struct cell *c, enum velocity_field vel,
set_energy_state(p, press, size, density);
#if defined(GIZMO_SPH)
p->geometry.volume = p->mass / density;
p->geometry.volume = p->conserved.mass / density;
p->primitives.rho = density;
p->primitives.v[0] = p->v[0];
p->primitives.v[1] = p->v[1];
p->primitives.v[2] = p->v[2];
p->conserved.mass = p->mass;
p->conserved.momentum[0] = p->conserved.mass * p->v[0];
p->conserved.momentum[1] = p->conserved.mass * p->v[1];
p->conserved.momentum[2] = p->conserved.mass * p->v[2];
......@@ -258,7 +257,12 @@ struct cell *make_cell(size_t n, const double offset[3], double size, double h,
part->x[1] = offset[1] + size * (y + 0.5) / (float)n;
part->x[2] = offset[2] + size * (z + 0.5) / (float)n;
part->h = size * h / (float)n;
#ifdef GIZMO_SPH
part->conserved.mass = density * volume / count;
#else
part->mass = density * volume / count;
#endif
set_velocity(part, vel, size);
set_energy_state(part, press, size, density);
......@@ -270,12 +274,11 @@ struct cell *make_cell(size_t n, const double offset[3], double size, double h,
hydro_first_init_part(part, xpart);
#if defined(GIZMO_SPH)
part->geometry.volume = part->mass / density;
part->geometry.volume = part->conserved.mass / density;
part->primitives.rho = density;
part->primitives.v[0] = part->v[0];
part->primitives.v[1] = part->v[1];
part->primitives.v[2] = part->v[2];
part->conserved.mass = part->mass;
part->conserved.momentum[0] = part->conserved.mass * part->v[0];
part->conserved.momentum[1] = part->conserved.mass * part->v[1];
part->conserved.momentum[2] = part->conserved.mass * part->v[2];
......@@ -352,7 +355,7 @@ void dump_particle_fields(char *fileName, struct cell *main_cell,
main_cell->parts[pid].x[1], main_cell->parts[pid].x[2],
main_cell->parts[pid].v[0], main_cell->parts[pid].v[1],
main_cell->parts[pid].v[2], main_cell->parts[pid].h,
main_cell->parts[pid].rho,
hydro_get_density(&main_cell->parts[pid]),
#ifdef MINIMAL_SPH
0.f,
#else
......
......@@ -104,7 +104,11 @@ struct cell *make_cell(size_t n, double *offset, double size, double h,
}
part->h = size * h / (float)n;
part->id = ++(*partId);
#ifdef GIZMO_SPH
part->conserved.mass = density * volume / count;
#else
part->mass = density * volume / count;
#endif
part->ti_begin = 0;
part->ti_end = 1;
++part;
......@@ -184,7 +188,7 @@ void dump_particle_fields(char *fileName, struct cell *main_cell,
main_cell->parts[pid].id, main_cell->parts[pid].x[0],
main_cell->parts[pid].x[1], main_cell->parts[pid].x[2],
main_cell->parts[pid].v[0], main_cell->parts[pid].v[1],
main_cell->parts[pid].v[2], main_cell->parts[pid].rho,
main_cell->parts[pid].v[2], hydro_get_density(&main_cell->parts[pid]),
#if defined(GIZMO_SPH)
0.f,
#else
......@@ -226,7 +230,7 @@ void dump_particle_fields(char *fileName, struct cell *main_cell,
"%13e %13e %13e\n",
cj->parts[pjd].id, cj->parts[pjd].x[0], cj->parts[pjd].x[1],
cj->parts[pjd].x[2], cj->parts[pjd].v[0], cj->parts[pjd].v[1],
cj->parts[pjd].v[2], cj->parts[pjd].rho,
cj->parts[pjd].v[2], hydro_get_density(&cj->parts[pjd]),
#if defined(GIZMO_SPH)
0.f,
#else
......
......@@ -63,7 +63,11 @@ struct cell *make_cell(size_t n, double *offset, double size, double h,
part->v[2] = random_uniform(-0.05, 0.05);
part->h = size * h / (float)n;
part->id = ++(*partId);
#ifdef GIZMO_SPH
part->conserved.mass = density * volume / count;
#else
part->mass = density * volume / count;
#endif
part->ti_begin = 0;
part->ti_end = 1;
++part;
......@@ -131,7 +135,7 @@ void dump_particle_fields(char *fileName, struct cell *ci, struct cell *cj) {
"%13e %13e %13e\n",
ci->parts[pid].id, ci->parts[pid].x[0], ci->parts[pid].x[1],
ci->parts[pid].x[2], ci->parts[pid].v[0], ci->parts[pid].v[1],
ci->parts[pid].v[2], ci->parts[pid].rho,
ci->parts[pid].v[2], hydro_get_density(&ci->parts[pid]),
#if defined(GIZMO_SPH)
0.f,
#else
......@@ -155,7 +159,7 @@ void dump_particle_fields(char *fileName, struct cell *ci, struct cell *cj) {
"%13e %13e %13e\n",
cj->parts[pjd].id, cj->parts[pjd].x[0], cj->parts[pjd].x[1],
cj->parts[pjd].x[2], cj->parts[pjd].v[0], cj->parts[pjd].v[1],
cj->parts[pjd].v[2], cj->parts[pjd].rho,
cj->parts[pjd].v[2], hydro_get_density(&cj->parts[pjd]),
#if defined(GIZMO_SPH)
0.f,
#else
......
......@@ -62,7 +62,7 @@ int main() {
assert(index < Ngas);
/* Check masses */
float mass = parts[n].mass;
float mass = hydro_get_mass(&parts[n]);
float correct_mass = boxSize * boxSize * boxSize * rho / Ngas;
assert(mass == correct_mass);
......
......@@ -77,4 +77,9 @@ int main(int argc, char *argv[]) {
fflush(stdout);
threadpool_map(&tp, map_function_first, data, N, sizeof(int), 2, NULL);
}
/* Be clean */
threadpool_clean(&tp);
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment