Commit 8810779b authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Print some timing information in the PM calculation when verbosity is on.

parent 835167a0
......@@ -3905,7 +3905,7 @@ void engine_rebuild(struct engine *e, int clean_smoothing_length_values) {
/* Re-compute the mesh forces */
if ((e->policy & engine_policy_self_gravity) && e->s->periodic)
pm_mesh_compute_potential(e->mesh, e);
pm_mesh_compute_potential(e->mesh, e->s, e->verbose);
/* Re-compute the maximal RMS displacement constraint */
if (e->policy & engine_policy_cosmology)
......
......@@ -278,13 +278,14 @@ void mesh_to_gparts_CIC(struct gpart* gp, const double* pot, int N, double fac,
* Note that there is no multiplication by G_newton at this stage.
*
* @param mesh The #pm_mesh used to store the potential.
* @param e The #engine from which to compute the forces.
* @param s The #space containing the particles.
* @param verbose Are we talkative?
*/
void pm_mesh_compute_potential(struct pm_mesh* mesh, const struct engine* e) {
void pm_mesh_compute_potential(struct pm_mesh* mesh, const struct space* s,
int verbose) {
#ifdef HAVE_FFTW
const struct space* s = e->s;
const double r_s = mesh->r_s;
const double box_size = s->dim[0];
const double dim[3] = {s->dim[0], s->dim[1], s->dim[2]};
......@@ -313,14 +314,24 @@ void pm_mesh_compute_potential(struct pm_mesh* mesh, const struct engine* e) {
fftw_plan inverse_plan = fftw_plan_dft_c2r_3d(
N, N, N, frho, rho, FFTW_ESTIMATE | FFTW_DESTROY_INPUT);
const ticks tic = getticks();
/* Zero everything */
bzero(rho, N * N * N * sizeof(double));
/* Do a CIC mesh assignment of the gparts */
for (size_t i = 0; i < e->s->nr_gparts; ++i)
gpart_to_mesh_CIC(&e->s->gparts[i], rho, N, cell_fac, dim);
for (size_t i = 0; i < s->nr_gparts; ++i)
gpart_to_mesh_CIC(&s->gparts[i], rho, N, cell_fac, dim);
if(verbose)
message("gpart assignment took %.3f %s.", clocks_from_ticks(getticks() - tic),
clocks_getunit());
/* message("\n\n\n DENSITY"); */
/* print_array(rho, N); */
const ticks tic2 = getticks();
/* Fourier transform to go to magic-land */
fftw_execute(forward_plan);
......@@ -396,6 +407,10 @@ void pm_mesh_compute_potential(struct pm_mesh* mesh, const struct engine* e) {
/* Let's store it in the structure */
mesh->potential = rho;
if(verbose)
message("Fourier-space PM took %.3f %s.", clocks_from_ticks(getticks() - tic2),
clocks_getunit());
/* message("\n\n\n POTENTIAL"); */
/* print_array(potential, N); */
......
......@@ -27,7 +27,7 @@
#include "restart.h"
/* Forward declarations */
struct engine;
struct space;
struct gpart;
/**
......@@ -66,7 +66,8 @@ struct pm_mesh {
void pm_mesh_init(struct pm_mesh *mesh, const struct gravity_props *props,
double dim[3]);
void pm_mesh_init_no_mesh(struct pm_mesh *mesh, double dim[3]);
void pm_mesh_compute_potential(struct pm_mesh *mesh, const struct engine *e);
void pm_mesh_compute_potential(struct pm_mesh *mesh, const struct space *s,
int verbose);
void pm_mesh_interpolate_forces(const struct pm_mesh *mesh,
const struct engine *e, struct gpart *gparts,
int gcount);
......
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