From bcf70b8bd823c6858c11fef289a27f3e8337867a Mon Sep 17 00:00:00 2001 From: Pedro Gonnet <pedro.gonnet@durham.ac.uk> Date: Wed, 29 Aug 2012 19:50:45 +0000 Subject: [PATCH] add count of lowest-level cells. Former-commit-id: e6ec27b2b732846158fc345c1d29dd77ac1b7019 --- test.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/test.c b/test.c index 1a1a3a024d..01a39f2d33 100644 --- a/test.c +++ b/test.c @@ -108,6 +108,23 @@ void map_cells_plot ( struct cell *c , void *data ) { } */ +/** + * @brief Mapping function for neighbour count. + */ + +void map_maxdepth ( struct cell *c , void *data ) { + + int maxdepth = ((int *)data)[0]; + int *count = &((int *)data)[1]; + + // printf( "%e\n" , p->count ); + + if ( c->depth == maxdepth ) + *count += 1; + + } + + /** * @brief Mapping function for neighbour count. */ @@ -377,7 +394,9 @@ void pairs_single ( double *dim , struct part *__restrict__ parts , int N , int int main ( int argc , char *argv[] ) { - int c, icount, j, k, N = 100, periodic = 1, nr_threads = 1, nr_queues = -1, runs = 1; + int c, icount, j, k, N = 100, periodic = 1; + int nr_threads = 1, nr_queues = -1, runs = 1; + int data[2]; double dim[3] = { 1.0 , 1.0 , 1.0 }, shift[3] = { 0.0 , 0.0 , 0.0 }; double r_min = 0.01, r_max = 0.1, h_max = -1.0 , scaling = 1.0, count = 0.0; struct part *parts = NULL; @@ -493,6 +512,10 @@ int main ( int argc , char *argv[] ) { printf( "main: maximum depth is %d.\n" , s.maxdepth ); printf( "main: cutoffs in [ %.3f %.3f ].\n" , s.r_min , s.r_max ); fflush(stdout); + data[0] = s.maxdepth; data[1] = 0; + space_map_cells( &s , &map_maxdepth , data ); + printf( "main: nr of cells at depth %i is %i.\n" , data[0] , data[1] ); + /* Dump the particle positions. */ // space_map_parts( &s , &map_dump , shift ); -- GitLab