diff --git a/examples/main.c b/examples/main.c index e2fd7f289c17a6c2df538948da807285dec70d6e..eba14faffcd3a6e89ac75cef18a192f95a320c67 100644 --- a/examples/main.c +++ b/examples/main.c @@ -56,9 +56,6 @@ #define ENGINE_POLICY engine_policy_none #endif - - - /** * @brief Main routine that loads a few particles and generates some output. * @@ -86,17 +83,19 @@ int main(int argc, char *argv[]) { FILE *file_thread; int with_outputs = 1; - /* Choke on FP-exceptions. */ - //feenableexcept( FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW ); +/* Choke on FP-exceptions. */ +// feenableexcept( FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW ); #ifdef WITH_MPI /* Start by initializing MPI. */ int res, prov; - if ((res = MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE, &prov)) != MPI_SUCCESS) + if ((res = MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE, &prov)) != + MPI_SUCCESS) error("Call to MPI_Init failed with error %i.", res); if (prov != MPI_THREAD_MULTIPLE) - error("MPI does not provide the level of threading required " - "(MPI_THREAD_MULTIPLE)."); + error( + "MPI does not provide the level of threading required " + "(MPI_THREAD_MULTIPLE)."); if ((res = MPI_Comm_size(MPI_COMM_WORLD, &nr_nodes)) != MPI_SUCCESS) error("MPI_Comm_size failed with error %i.", res); if ((res = MPI_Comm_rank(MPI_COMM_WORLD, &myrank)) != MPI_SUCCESS) @@ -146,7 +145,8 @@ int main(int argc, char *argv[]) { fflush(stdout); break; case 'c': - if (sscanf(optarg, "%lf", &time_end) != 1) error("Error parsing final time."); + if (sscanf(optarg, "%lf", &time_end) != 1) + error("Error parsing final time."); if (myrank == 0) message("time_end set to %.3e.", time_end); fflush(stdout); break; @@ -198,7 +198,7 @@ int main(int argc, char *argv[]) { if (myrank == 0) message("sub size set to %i.", space_subsize); break; case 'y': - if(sscanf(optarg, "%d", &dump_tasks) != 1) + if (sscanf(optarg, "%d", &dump_tasks) != 1) error("Error parsing dump_tasks (-y)"); break; case 'z': @@ -218,7 +218,7 @@ int main(int argc, char *argv[]) { if (nr_nodes == 1) { message("WARNING: you are running with one MPI rank."); - message("WARNING: you should use the non-MPI version of this program." ); + message("WARNING: you should use the non-MPI version of this program."); } fflush(stdout); } @@ -229,7 +229,8 @@ int main(int argc, char *argv[]) { /* How large are the parts? */ if (myrank == 0) { message("sizeof(struct part) is %li bytes.", (long int)sizeof(struct part)); - message("sizeof(struct xpart) is %li bytes.", (long int)sizeof(struct xpart)); + message("sizeof(struct xpart) is %li bytes.", + (long int)sizeof(struct xpart)); message("sizeof(struct gpart) is %li bytes.", (long int)sizeof(struct gpart)); } @@ -251,9 +252,9 @@ int main(int argc, char *argv[]) { } /* Check we have sensible time step bounds */ - if ( dt_min > dt_max ) + if (dt_min > dt_max) error("Minimal time step size must be large than maximal time step size "); - + /* Check whether an IC file has been provided */ if (strcmp(ICfileName, "") == 0) error("An IC file name must be provided via the option -f"); @@ -334,7 +335,6 @@ int main(int argc, char *argv[]) { message("nr of cells at depth %i is %i.", data[0], data[1]); } - /* Initialize the engine with this space. */ tic = getticks(); if (myrank == 0) message("nr_nodes is %i.", nr_nodes); @@ -379,19 +379,21 @@ int main(int argc, char *argv[]) { if (myrank == 0) { message( - "Running on %lld particles until t=%.3e with %i threads and %i " - "queues (dt_min=%.3e, dt_max=%.3e)...", - N_total, time_end, e.nr_threads, e.sched.nr_queues, e.dt_min, e.dt_max); + "Running on %lld particles until t=%.3e with %i threads and %i " + "queues (dt_min=%.3e, dt_max=%.3e)...", + N_total, time_end, e.nr_threads, e.sched.nr_queues, e.dt_min, e.dt_max); fflush(stdout); } /* Initialise the particles */ engine_init_particles(&e); - + /* Legend */ if (myrank == 0) - printf("# Step Time time-step Number of updates CPU Wall-clock time [ms]\n"); - + printf( + "# Step Time time-step Number of updates CPU Wall-clock time " + "[ms]\n"); + /* Let loose a runner on the space. */ for (j = 0; e.time < time_end; j++) { @@ -423,15 +425,15 @@ int main(int argc, char *argv[]) { #endif } - /* Dump the task data using the given frequency. */ + /* Dump the task data using the given frequency. */ if (dump_tasks && (dump_tasks == 1 || j % dump_tasks == 1)) { #ifdef WITH_MPI /* Make sure output file is empty, only on one rank. */ sprintf(dumpfile, "thread_info_MPI-step%d.dat", j); if (myrank == 0) { - file_thread = fopen(dumpfile, "w"); - fclose(file_thread); + file_thread = fopen(dumpfile, "w"); + fclose(file_thread); } MPI_Barrier(MPI_COMM_WORLD); @@ -451,14 +453,15 @@ int main(int argc, char *argv[]) { int count = 0; for (int l = 0; l < e.sched.nr_tasks; l++) if (!e.sched.tasks[l].skip && !e.sched.tasks[l].implicit) { - fprintf( - file_thread, " %03i %i %i %i %i %lli %lli %i %i %i\n", myrank, - e.sched.tasks[l].rid, e.sched.tasks[l].type, - e.sched.tasks[l].subtype, (e.sched.tasks[l].cj == NULL), - e.sched.tasks[l].tic, e.sched.tasks[l].toc, - (e.sched.tasks[l].ci != NULL) ? e.sched.tasks[l].ci->count : 0, - (e.sched.tasks[l].cj != NULL) ? e.sched.tasks[l].cj->count : 0, - e.sched.tasks[l].flags); + fprintf(file_thread, " %03i %i %i %i %i %lli %lli %i %i %i\n", + myrank, e.sched.tasks[l].rid, e.sched.tasks[l].type, + e.sched.tasks[l].subtype, (e.sched.tasks[l].cj == NULL), + e.sched.tasks[l].tic, e.sched.tasks[l].toc, + (e.sched.tasks[l].ci != NULL) ? e.sched.tasks[l].ci->count + : 0, + (e.sched.tasks[l].cj != NULL) ? e.sched.tasks[l].cj->count + : 0, + e.sched.tasks[l].flags); fflush(stdout); count++; } @@ -476,12 +479,13 @@ int main(int argc, char *argv[]) { file_thread = fopen(dumpfile, "w"); for (int l = 0; l < e.sched.nr_tasks; l++) if (!e.sched.tasks[l].skip && !e.sched.tasks[l].implicit) - fprintf(file_thread, " %i %i %i %i %lli %lli %i %i\n", - e.sched.tasks[l].rid, e.sched.tasks[l].type, - e.sched.tasks[l].subtype, (e.sched.tasks[l].cj == NULL), - e.sched.tasks[l].tic, e.sched.tasks[l].toc, - (e.sched.tasks[l].ci == NULL) ? 0 : e.sched.tasks[l].ci->count, - (e.sched.tasks[l].cj == NULL) ? 0 : e.sched.tasks[l].cj->count); + fprintf( + file_thread, " %i %i %i %i %lli %lli %i %i\n", + e.sched.tasks[l].rid, e.sched.tasks[l].type, + e.sched.tasks[l].subtype, (e.sched.tasks[l].cj == NULL), + e.sched.tasks[l].tic, e.sched.tasks[l].toc, + (e.sched.tasks[l].ci == NULL) ? 0 : e.sched.tasks[l].ci->count, + (e.sched.tasks[l].cj == NULL) ? 0 : e.sched.tasks[l].cj->count); fclose(file_thread); #endif } @@ -499,7 +503,6 @@ int main(int argc, char *argv[]) { /* fflush(stdout); */ /* } */ - /* if (myrank == 0) { */ /* printf("%i %e", j, e.time); */ /* printf(" %.3f", ((double)timers[timer_count - 1]) / CPU_TPS * 1000); */ @@ -519,7 +522,6 @@ int main(int argc, char *argv[]) { (double)runner_hist_bins[k]); #endif - if (with_outputs) { /* Write final output. */ #if defined(WITH_MPI) diff --git a/src/cell.c b/src/cell.c index ef258bf23af217024ae1cf25a16dc3e63370c5b5..cdb41872fa5fbe41eeb5c7b376ed901620dda5e4 100644 --- a/src/cell.c +++ b/src/cell.c @@ -557,8 +557,8 @@ void cell_init_parts(struct cell *c, void *data) { struct part *p = c->parts; struct xpart *xp = c->xparts; - - for(int i=0; i<c->count; ++i) { + + for (int i = 0; i < c->count; ++i) { p[i].t_begin = 0.; p[i].t_end = 0.; xp[i].v_full[0] = p[i].v[0]; @@ -571,7 +571,8 @@ void cell_init_parts(struct cell *c, void *data) { } /** - * @brief Converts hydro quantities to a valid state after the initial density calculation + * @brief Converts hydro quantities to a valid state after the initial density + *calculation * * @param c Cell to act upon * @param data Unused parameter @@ -579,24 +580,22 @@ void cell_init_parts(struct cell *c, void *data) { void cell_convert_hydro(struct cell *c, void *data) { struct part *p = c->parts; - - for(int i=0; i<c->count; ++i) { + + for (int i = 0; i < c->count; ++i) { hydro_convert_quantities(&p[i]); } } - /** * @brief Cleans the links in a given cell. * * @param c Cell to act upon * @param data Unused parameter */ -void cell_clean_links(struct cell * c, void * data) { +void cell_clean_links(struct cell *c, void *data) { c->density = NULL; c->nr_density = 0; - + c->force = NULL; c->nr_force = 0; } - diff --git a/src/cell.h b/src/cell.h index 0341278a9e83cd88a1b3b35d1128e78b4b2883ae..e821d0438f96a7dbc20db6da78d00cf48c4c85cc 100644 --- a/src/cell.h +++ b/src/cell.h @@ -27,9 +27,9 @@ /* Forward declaration of space, needed for cell_unpack. */ struct space; -/* Max tag size set to 2^29 to take into account some MPI implementations - * that use 2^31 as the upper bound on MPI tags and the fact that - * cell_next_tag is multiplied by 2 when passed to an MPI function. +/* Max tag size set to 2^29 to take into account some MPI implementations + * that use 2^31 as the upper bound on MPI tags and the fact that + * cell_next_tag is multiplied by 2 when passed to an MPI function. * The maximum was lowered by a further factor of 2 to be on the safe side.*/ #define cell_max_tag (1 << 29) @@ -161,12 +161,10 @@ struct cell { } __attribute__((aligned(64))); - /* Convert cell location to ID. */ #define cell_getid(cdim, i, j, k) \ ((int)(k) + (cdim)[2] * ((int)(j) + (cdim)[1] * (int)(i))) - /* Function prototypes. */ void cell_split(struct cell *c); int cell_locktree(struct cell *c); @@ -179,6 +177,6 @@ int cell_getsize(struct cell *c); int cell_link(struct cell *c, struct part *parts); void cell_init_parts(struct cell *c, void *data); void cell_convert_hydro(struct cell *c, void *data); -void cell_clean_links(struct cell * c, void * data); +void cell_clean_links(struct cell *c, void *data); #endif /* SWIFT_CELL_H */ diff --git a/src/common_io.c b/src/common_io.c index 4646c133f4bb85e689723c85845d562827e5ebb1..b7a9a887e450b3fcc664650688a19910efcfab3d 100644 --- a/src/common_io.c +++ b/src/common_io.c @@ -364,8 +364,8 @@ void writeCodeDescription(hid_t h_file) { #ifdef WITH_MPI writeAttribute_s(h_grpcode, "MPI library", mpi_version()); #ifdef HAVE_METIS - writeAttribute_s(h_grpcode,"METIS library version", metis_version()); -#endif + writeAttribute_s(h_grpcode, "METIS library version", metis_version()); +#endif #else writeAttribute_s(h_grpcode, "MPI library", "Non-MPI version of SWIFT"); #endif diff --git a/src/debug.c b/src/debug.c index dd89f8c6ca78a9424680bc94144f98fb30eb9ea3..e04dc069870646a1324711b0c4e8e18662763390 100644 --- a/src/debug.c +++ b/src/debug.c @@ -38,7 +38,8 @@ * (Should be used for debugging only as it runs in O(N).) */ -void printParticle(struct part *parts, struct xpart *xparts, long long int id, int N) { +void printParticle(struct part *parts, struct xpart *xparts, long long int id, + int N) { int i, found = 0; @@ -47,28 +48,21 @@ void printParticle(struct part *parts, struct xpart *xparts, long long int id, i if (parts[i].id == id) { printf( "## Particle[%d]:\n id=%lld, x=[%.3e,%.3e,%.3e], " - "v=[%.3e,%.3e,%.3e],v_full=[%.3e,%.3e,%.3e] \n a=[%.3e,%.3e,%.3e],\n h=%.3e, " - "wcount=%d, m=%.3e, dh_drho=%.3e, rho=%.3e, P=%.3e, S=%.3e, dS/dt=%.3e,\n" - "divV=%.3e, curlV=%.3e, rotV=[%.3e,%.3e,%.3e] \n " - "v_sig=%e t_begin=%.3e, t_end=%.3e\n", + "v=[%.3e,%.3e,%.3e],v_full=[%.3e,%.3e,%.3e] \n a=[%.3e,%.3e,%.3e],\n " + "h=%.3e, " + "wcount=%d, m=%.3e, dh_drho=%.3e, rho=%.3e, P=%.3e, S=%.3e, " + "dS/dt=%.3e,\n" + "divV=%.3e, curlV=%.3e, rotV=[%.3e,%.3e,%.3e] \n " + "v_sig=%e t_begin=%.3e, t_end=%.3e\n", i, parts[i].id, parts[i].x[0], parts[i].x[1], parts[i].x[2], - parts[i].v[0], parts[i].v[1], parts[i].v[2], - xparts[i].v_full[0], xparts[i].v_full[1], xparts[i].v_full[2], - parts[i].a[0], - parts[i].a[1], parts[i].a[2], 2.*parts[i].h, - (int)parts[i].density.wcount, parts[i].mass, - parts[i].rho_dh, - parts[i].rho, - parts[i].pressure, - parts[i].entropy, - parts[i].entropy_dt, - parts[i].div_v, - parts[i].curl_v, - parts[i].rot_v[0], - parts[i].rot_v[1], - parts[i].rot_v[2], - parts[i].v_sig, - parts[i].t_begin, parts[i].t_end); + parts[i].v[0], parts[i].v[1], parts[i].v[2], xparts[i].v_full[0], + xparts[i].v_full[1], xparts[i].v_full[2], parts[i].a[0], + parts[i].a[1], parts[i].a[2], 2. * parts[i].h, + (int)parts[i].density.wcount, parts[i].mass, parts[i].rho_dh, + parts[i].rho, parts[i].pressure, parts[i].entropy, + parts[i].entropy_dt, parts[i].div_v, parts[i].curl_v, + parts[i].rot_v[0], parts[i].rot_v[1], parts[i].rot_v[2], + parts[i].v_sig, parts[i].t_begin, parts[i].t_end); found = 1; } @@ -86,10 +80,10 @@ void printgParticle(struct gpart *parts, long long int id, int N) { "## gParticle[%d]: id=%lld, x=[%.16e,%.16e,%.16e], " "v=[%.3e,%.3e,%.3e], a=[%.3e,%.3e,%.3e], m=%.3e, t_begin=%.3e, " "t_end=%.3e\n", - i, parts[i].part->id, - parts[i].x[0], parts[i].x[1], parts[i].x[2], parts[i].v[0], - parts[i].v[1], parts[i].v[2], parts[i].a[0], parts[i].a[1], - parts[i].a[2], parts[i].mass, parts[i].t_begin, parts[i].t_end); + i, parts[i].part->id, parts[i].x[0], parts[i].x[1], parts[i].x[2], + parts[i].v[0], parts[i].v[1], parts[i].v[2], parts[i].a[0], + parts[i].a[1], parts[i].a[2], parts[i].mass, parts[i].t_begin, + parts[i].t_end); found = 1; } @@ -107,11 +101,15 @@ void printParticle_single(struct part *p) { /* printf( */ /* "## Particle: id=%lld, x=[%e,%e,%e], v=[%.3e,%.3e,%.3e], " */ - /* "a=[%.3e,%.3e,%.3e], h=%.3e, h_dt=%.3e, wcount=%.3e, m=%.3e, rho=%.3e, " */ - /* "rho_dh=%.3e, div_v=%.3e, u=%.3e, dudt=%.3e, bals=%.3e, POrho2=%.3e, " */ + /* "a=[%.3e,%.3e,%.3e], h=%.3e, h_dt=%.3e, wcount=%.3e, m=%.3e, rho=%.3e, + * " */ + /* "rho_dh=%.3e, div_v=%.3e, u=%.3e, dudt=%.3e, bals=%.3e, POrho2=%.3e, " + */ /* "v_sig=%.3e, t_begin=%.3e, t_end=%.3e\n", */ - /* p->id, p->x[0], p->x[1], p->x[2], p->v[0], p->v[1], p->v[2], p->a[0], */ - /* p->a[1], p->a[2], p->h, p->force.h_dt, p->density.wcount, p->mass, p->rho, */ + /* p->id, p->x[0], p->x[1], p->x[2], p->v[0], p->v[1], p->v[2], p->a[0], + */ + /* p->a[1], p->a[2], p->h, p->force.h_dt, p->density.wcount, p->mass, + * p->rho, */ /* p->rho_dh, p->density.div_v, p->u, p->force.u_dt, p->force.balsara, */ /* p->force.POrho2, p->force.v_sig, p->t_begin, p->t_end); */ @@ -130,7 +128,8 @@ void printParticle_single(struct part *p) { * minus the cell connectivity. * * The output filenames are generated from the prefix and the sequence number - * of calls. So the first is called {prefix}_std_001.dat, {prefix}_simple_001.dat, + * of calls. So the first is called {prefix}_std_001.dat, + *{prefix}_simple_001.dat, * {prefix}_weights_001.dat, etc. * * @param prefix base output filename @@ -143,7 +142,7 @@ void printParticle_single(struct part *p) { * @param edgeweights weights of edges */ void dumpMETISGraph(const char *prefix, idx_t nvertices, idx_t nvertexweights, - idx_t *cellconruns, idx_t *cellcon, idx_t *vertexweights, + idx_t *cellconruns, idx_t *cellcon, idx_t *vertexweights, idx_t *vertexsizes, idx_t *edgeweights) { FILE *stdfile = NULL; FILE *simplefile = NULL; @@ -186,24 +185,28 @@ void dumpMETISGraph(const char *prefix, idx_t nvertices, idx_t nvertexweights, /* Open output files. */ sprintf(fname, "%s_std_%03d.dat", prefix, nseq); - stdfile = fopen( fname, "w" ); + stdfile = fopen(fname, "w"); sprintf(fname, "%s_simple_%03d.dat", prefix, nseq); - simplefile = fopen( fname, "w" ); + simplefile = fopen(fname, "w"); if (havevertexweight || havevertexsize || haveedgeweight) { sprintf(fname, "%s_weights_%03d.dat", prefix, nseq); - weightfile = fopen( fname, "w" ); + weightfile = fopen(fname, "w"); } /* Write the header lines. */ fprintf(stdfile, "%" PRIDX " %" PRIDX, nvertices, cellconruns[nvertices] / 2); - fprintf(simplefile, "%" PRIDX " %" PRIDX, nvertices, cellconruns[nvertices] / 2); + fprintf(simplefile, "%" PRIDX " %" PRIDX, nvertices, + cellconruns[nvertices] / 2); if (havevertexweight || havevertexsize || haveedgeweight) { - fprintf(weightfile, "%" PRIDX " %" PRIDX, nvertices, cellconruns[nvertices] / 2); + fprintf(weightfile, "%" PRIDX " %" PRIDX, nvertices, + cellconruns[nvertices] / 2); - fprintf(stdfile, " %d%d%d", havevertexsize, havevertexweight, haveedgeweight); - fprintf(weightfile, " %d%d%d", havevertexsize, havevertexweight, haveedgeweight); + fprintf(stdfile, " %d%d%d", havevertexsize, havevertexweight, + haveedgeweight); + fprintf(weightfile, " %d%d%d", havevertexsize, havevertexweight, + haveedgeweight); if (havevertexweight) { fprintf(stdfile, " %d", (int)nvertexweights); @@ -216,7 +219,7 @@ void dumpMETISGraph(const char *prefix, idx_t nvertices, idx_t nvertexweights, fprintf(stdfile, "\n"); fprintf(simplefile, "\n"); if (weightfile != NULL) { - fprintf(weightfile, "\n"); + fprintf(weightfile, "\n"); } if (havevertexsize) { @@ -243,7 +246,7 @@ void dumpMETISGraph(const char *prefix, idx_t nvertices, idx_t nvertexweights, fprintf(stdfile, "\n"); fprintf(simplefile, "\n"); if (weightfile != NULL) { - fprintf(weightfile, "\n"); + fprintf(weightfile, "\n"); } fclose(stdfile); diff --git a/src/debug.h b/src/debug.h index 37653c3fa5e08103edd7c3f0f1cf51b31be338de..2ca1d7da35c72127c67714e96d0ef61afcb09763 100644 --- a/src/debug.h +++ b/src/debug.h @@ -23,15 +23,15 @@ #include "cell.h" #include "part.h" -void printParticle(struct part *parts, struct xpart *xparts, long long int i, int N); +void printParticle(struct part *parts, struct xpart *xparts, long long int i, + int N); void printgParticle(struct gpart *parts, long long int i, int N); void printParticle_single(struct part *p); #ifdef HAVE_METIS #include "metis.h" -void dumpMETISGraph(const char *prefix, idx_t nvtxs, idx_t ncon, - idx_t *xadj, idx_t *adjncy, idx_t *vwgt, idx_t *vsize, - idx_t *adjwgt); +void dumpMETISGraph(const char *prefix, idx_t nvtxs, idx_t ncon, idx_t *xadj, + idx_t *adjncy, idx_t *vwgt, idx_t *vsize, idx_t *adjwgt); #endif #endif /* SWIFT_DEBUG_H */ diff --git a/src/engine.c b/src/engine.c index dd421398ab3f0d0bb3ad25cbe39e070daf744141..879d5a077fd50da5dc32902808d39184ba187fbd 100644 --- a/src/engine.c +++ b/src/engine.c @@ -55,9 +55,9 @@ #include "part.h" #include "timers.h" -const char *engine_policy_names[10] = { - "none", "rand", "steal", "keep", "block", - "fix_dt", "cpu_tight", "mpi", "numa_affinity"}; +const char *engine_policy_names[10] = {"none", "rand", "steal", + "keep", "block", "fix_dt", + "cpu_tight", "mpi", "numa_affinity"}; /** The rank of the engine as a global variable (for messages). */ int engine_rank; @@ -1429,8 +1429,8 @@ int engine_marktasks(struct engine *e) { /* Init? */ else if (t->type == task_type_init) { - /* Set this task's skip. */ - t->skip = (t->ci->t_end_min > t_end); + /* Set this task's skip. */ + t->skip = (t->ci->t_end_min > t_end); } /* None? */ @@ -1667,7 +1667,8 @@ void engine_collect_kick(struct cell *c) { * @param submask The sub-task mask to launch. */ - void engine_launch(struct engine *e, int nr_runners, unsigned int mask, unsigned int submask) { +void engine_launch(struct engine *e, int nr_runners, unsigned int mask, + unsigned int submask) { /* Prepare the scheduler. */ atomic_inc(&e->sched.waiting); @@ -1677,7 +1678,7 @@ void engine_collect_kick(struct cell *c) { e->barrier_launchcount = nr_runners; if (pthread_cond_broadcast(&e->barrier_cond) != 0) error("Failed to broadcast barrier open condition."); - + /* Load the tasks. */ pthread_mutex_unlock(&e->barrier_mutex); scheduler_start(&e->sched, mask, submask); @@ -1714,29 +1715,29 @@ void engine_init_particles(struct engine *e) { message("Initialising particles"); space_map_cells_pre(s, 1, cell_init_parts, NULL); - //printParticle(e->s->parts, 1000, e->s->nr_parts); - //printParticle(e->s->parts, 515050, e->s->nr_parts); + // printParticle(e->s->parts, 1000, e->s->nr_parts); + // printParticle(e->s->parts, 515050, e->s->nr_parts); + + // message("\n0th DENSITY CALC\n"); - //message("\n0th DENSITY CALC\n"); - /* Now do a density calculation */ TIMER_TIC; engine_launch(e, e->nr_threads, (1 << task_type_sort) | (1 << task_type_self) | - (1 << task_type_pair) | (1 << task_type_sub) | - (1 << task_type_init) | (1 << task_type_ghost) | - (1 << task_type_send) | (1 << task_type_recv), - 1 << task_subtype_density); + (1 << task_type_pair) | (1 << task_type_sub) | + (1 << task_type_init) | (1 << task_type_ghost) | + (1 << task_type_send) | (1 << task_type_recv), + 1 << task_subtype_density); TIMER_TOC(timer_runners); - - //message("\n0th ENTROPY CONVERSION\n"); + + // message("\n0th ENTROPY CONVERSION\n"); space_map_cells_pre(s, 1, cell_convert_hydro, NULL); - //printParticle(e->s->parts, e->s->xparts,1000, e->s->nr_parts); - //printParticle(e->s->parts, e->s->xparts,515050, e->s->nr_parts); - + // printParticle(e->s->parts, e->s->xparts,1000, e->s->nr_parts); + // printParticle(e->s->parts, e->s->xparts,515050, e->s->nr_parts); + /* Ready to go */ e->step = -1; } @@ -1807,25 +1808,24 @@ if ( e->nodeID == 0 ) message( "nr_parts=%i." , nr_parts ); */ #endif - //message("\nDRIFT\n"); + // message("\nDRIFT\n"); /* Move forward in time */ e->timeOld = e->time; e->time = t_end_min; e->step += 1; e->timeStep = e->time - e->timeOld; - + /* Drift everybody */ engine_launch(e, e->nr_threads, 1 << task_type_drift, 0); - //printParticle(e->s->parts, e->s->xparts, 1000, e->s->nr_parts); - //printParticle(e->s->parts, e->s->xparts, 515050, e->s->nr_parts); + // printParticle(e->s->parts, e->s->xparts, 1000, e->s->nr_parts); + // printParticle(e->s->parts, e->s->xparts, 515050, e->s->nr_parts); + + // if(e->step == 2) exit(0); + // message("\nACCELERATION AND KICK\n"); - //if(e->step == 2) exit(0); - - //message("\nACCELERATION AND KICK\n"); - /* Re-distribute the particles amongst the nodes? */ if (e->forcerepart) engine_repartition(e); @@ -1836,23 +1836,22 @@ if ( e->nodeID == 0 ) TIMER_TIC; engine_launch(e, e->nr_threads, (1 << task_type_sort) | (1 << task_type_self) | - (1 << task_type_pair) | (1 << task_type_sub) | - (1 << task_type_init) | (1 << task_type_ghost) | - (1 << task_type_kick) | (1 << task_type_send) | - (1 << task_type_recv), - (1 << task_subtype_density) | (1 << task_subtype_force)); + (1 << task_type_pair) | (1 << task_type_sub) | + (1 << task_type_init) | (1 << task_type_ghost) | + (1 << task_type_kick) | (1 << task_type_send) | + (1 << task_type_recv), + (1 << task_subtype_density) | (1 << task_subtype_force)); TIMER_TOC(timer_runners); TIMER_TOC2(timer_step); - printf("%d %f %f %d %.3f\n", e->step, e->time, e->timeStep, updates, ((double)timers[timer_count - 1]) / CPU_TPS * 1000); + printf("%d %f %f %d %.3f\n", e->step, e->time, e->timeStep, updates, + ((double)timers[timer_count - 1]) / CPU_TPS * 1000); fflush(stdout); - - //printParticle(e->s->parts, e->s->xparts,1000, e->s->nr_parts); - //printParticle(e->s->parts, e->s->xparts,515050, e->s->nr_parts); - + // printParticle(e->s->parts, e->s->xparts,1000, e->s->nr_parts); + // printParticle(e->s->parts, e->s->xparts,515050, e->s->nr_parts); } /** @@ -1951,11 +1950,9 @@ void engine_makeproxies(struct engine *e) { } } - #else error("SWIFT was not compiled with MPI support."); #endif - } /** @@ -1968,7 +1965,7 @@ void engine_makeproxies(struct engine *e) { void engine_split(struct engine *e, int *grid) { #ifdef WITH_MPI - + int j, k; int ind[3]; struct space *s = e->s; @@ -2013,7 +2010,6 @@ void engine_split(struct engine *e, int *grid) { #else error("SWIFT was not compiled with MPI support."); #endif - } #if defined(HAVE_LIBNUMA) && defined(_GNU_SOURCE) @@ -2167,10 +2163,10 @@ void engine_init(struct engine *e, struct space *s, float dt, int nr_threads, engine_print_policy(e); /* Deal with timestep */ - if(e->policy & engine_policy_fixdt) { + if (e->policy & engine_policy_fixdt) { e->dt_min = e->dt_max; } - + /* Construct types for MPI communications */ #ifdef WITH_MPI part_create_mpi_type(&e->part_mpi_type); @@ -2256,7 +2252,7 @@ void engine_init(struct engine *e, struct space *s, float dt, int nr_threads, void engine_print_policy(struct engine *e) { #ifdef WITH_MPI - if(e->nodeID == 0) { + if (e->nodeID == 0) { printf("[000] engine_policy: engine policies are [ "); for (int k = 1; k < 32; k++) if (e->policy & 1 << k) printf(" %s,", engine_policy_names[k + 1]); diff --git a/src/engine.h b/src/engine.h index 53956e8976dc5346f864911fc834783521cedd67..4cc1d5079867a8e7493692e6610fc21156494e09 100644 --- a/src/engine.h +++ b/src/engine.h @@ -155,7 +155,8 @@ void engine_barrier(struct engine *e, int tid); void engine_init(struct engine *e, struct space *s, float dt, int nr_threads, int nr_queues, int nr_nodes, int nodeID, int policy, float timeBegin, float timeEnd, float dt_min, float dt_max); -void engine_launch(struct engine *e, int nr_runners, unsigned int mask, unsigned int submask); +void engine_launch(struct engine *e, int nr_runners, unsigned int mask, + unsigned int submask); void engine_prepare(struct engine *e); void engine_print(struct engine *e); void engine_init_particles(struct engine *e); diff --git a/src/gravity/Default/gravity.h b/src/gravity/Default/gravity.h index 6e739546e1ebaedb948fa1d795bc72317d7af45f..82bc52ad3e05794c8c05896075edc463a69197ff 100644 --- a/src/gravity/Default/gravity.h +++ b/src/gravity/Default/gravity.h @@ -33,4 +33,3 @@ __attribute__((always_inline)) INLINE static float gravity_compute_timestep( /* Currently no limit is imposed */ return FLT_MAX; } - diff --git a/src/gravity/Default/gravity_part.h b/src/gravity/Default/gravity_part.h index edc4eb61e87152a1aad86f327e320c89b598d67d..bad5c7318ec13457c934b1e4106012bcc65ef070 100644 --- a/src/gravity/Default/gravity_part.h +++ b/src/gravity/Default/gravity_part.h @@ -19,7 +19,6 @@ /* Some standard headers. */ #include <stdlib.h> - /* Gravity particle. */ struct gpart { diff --git a/src/hydro/Default/hydro.h b/src/hydro/Default/hydro.h index 73ab61d7b751dc8a9c79d441dad6d130c7c7e75b..fd18233b122337036631d926d75b16ba6aa2e209 100644 --- a/src/hydro/Default/hydro.h +++ b/src/hydro/Default/hydro.h @@ -43,16 +43,16 @@ __attribute__((always_inline)) INLINE static float hydro_compute_timestep( return fminf(dt_cfl, fminf(dt_h_change, dt_u_change)); } - /** * @brief Prepares a particle for the density calculation. * - * Zeroes all the relevant arrays in preparation for the sums taking place in + * Zeroes all the relevant arrays in preparation for the sums taking place in * the variaous density tasks * * @param p The particle to act upon */ -__attribute__((always_inline)) INLINE static void hydro_init_part(struct part* p) { +__attribute__((always_inline)) + INLINE static void hydro_init_part(struct part* p) { p->density.wcount = 0.f; p->density.wcount_dh = 0.f; p->rho = 0.f; @@ -63,33 +63,32 @@ __attribute__((always_inline)) INLINE static void hydro_init_part(struct part* p p->density.curl_v[2] = 0.f; } - /** - * @brief Finishes the density calculation. + * @brief Finishes the density calculation. * - * Multiplies the density and number of neighbours by the appropiate constants + * Multiplies the density and number of neighbours by the appropiate constants * and add the self-contribution term. * * @param p The particle to act upon */ -__attribute__((always_inline)) INLINE static void hydro_end_density(struct part* p) { +__attribute__((always_inline)) + INLINE static void hydro_end_density(struct part* p) { /* Some smoothing length multiples. */ const float h = p->h; const float ih = 1.0f / h; const float ih2 = ih * ih; const float ih4 = ih2 * ih2; - + /* Final operation on the density. */ p->rho = ih * ih2 * (p->rho + p->mass * kernel_root); p->rho_dh = (p->rho_dh - 3.0f * p->mass * kernel_root) * ih4; - p->density.wcount = (p->density.wcount + kernel_root) * - (4.0f / 3.0 * M_PI * kernel_gamma3); - p->density.wcount_dh = p->density.wcount_dh * ih * (4.0f / 3.0 * M_PI * kernel_gamma3); - + p->density.wcount = + (p->density.wcount + kernel_root) * (4.0f / 3.0 * M_PI * kernel_gamma3); + p->density.wcount_dh = + p->density.wcount_dh * ih * (4.0f / 3.0 * M_PI * kernel_gamma3); } - /** * @brief Prepare a particle for the force calculation. * @@ -98,8 +97,8 @@ __attribute__((always_inline)) INLINE static void hydro_end_density(struct part* * @param p The particle to act upon * @param xp The extended particle data to act upon */ -__attribute__((always_inline)) INLINE static void hydro_prepare_force(struct part* p, - struct xpart* xp) { +__attribute__((always_inline)) + INLINE static void hydro_prepare_force(struct part* p, struct xpart* xp) { /* Some smoothing length multiples. */ const float h = p->h; @@ -110,22 +109,21 @@ __attribute__((always_inline)) INLINE static void hydro_prepare_force(struct par /* Pre-compute some stuff for the balsara switch. */ const float normDiv_v = fabs(p->density.div_v / p->rho * ih4); const float normCurl_v = sqrtf(p->density.curl_v[0] * p->density.curl_v[0] + - p->density.curl_v[1] * p->density.curl_v[1] + - p->density.curl_v[2] * p->density.curl_v[2]) / - p->rho * ih4; + p->density.curl_v[1] * p->density.curl_v[1] + + p->density.curl_v[2] * p->density.curl_v[2]) / + p->rho * ih4; /* Compute this particle's sound speed. */ const float u = p->u; - const float fc = p->force.c = - sqrtf(const_hydro_gamma * (const_hydro_gamma - 1.0f) * u); + const float fc = p->force.c = + sqrtf(const_hydro_gamma * (const_hydro_gamma - 1.0f) * u); /* Compute the P/Omega/rho2. */ xp->omega = 1.0f + 0.3333333333f * h * p->rho_dh / p->rho; p->force.POrho2 = u * (const_hydro_gamma - 1.0f) / (p->rho * xp->omega); /* Balsara switch */ - p->force.balsara = - normDiv_v / (normDiv_v + normCurl_v + 0.0001f * fc * ih); + p->force.balsara = normDiv_v / (normDiv_v + normCurl_v + 0.0001f * fc * ih); /* Viscosity parameter decay time */ const float tau = h / (2.f * const_viscosity_length * p->force.c); @@ -135,13 +133,12 @@ __attribute__((always_inline)) INLINE static void hydro_prepare_force(struct par /* Compute the particle's viscosity parameter time derivative */ const float alpha_dot = (const_viscosity_alpha_min - p->alpha) / tau + - (const_viscosity_alpha_max - p->alpha) * S; + (const_viscosity_alpha_max - p->alpha) * S; /* Update particle's viscosity paramter */ p->alpha += alpha_dot * (p->t_end - p->t_begin); } - /** * @brief Reset acceleration fields of a particle * @@ -150,13 +147,14 @@ __attribute__((always_inline)) INLINE static void hydro_prepare_force(struct par * * @param p The particle to act upon */ -__attribute__((always_inline)) INLINE static void hydro_reset_acceleration(struct part* p) { +__attribute__((always_inline)) + INLINE static void hydro_reset_acceleration(struct part* p) { /* Reset the acceleration. */ p->a[0] = 0.0f; p->a[1] = 0.0f; p->a[2] = 0.0f; - + /* Reset the time derivatives. */ p->force.u_dt = 0.0f; p->force.h_dt = 0.0f; @@ -170,34 +168,31 @@ __attribute__((always_inline)) INLINE static void hydro_reset_acceleration(struc * @param xp The extended data of the particle * @param dt The time-step over which to drift */ -__attribute__((always_inline)) INLINE static void hydro_predict_extra(struct part* p, - struct xpart* xp, - float dt) { +__attribute__((always_inline)) INLINE static void hydro_predict_extra( + struct part* p, struct xpart* xp, float dt) { float u, w; /* Predict internal energy */ w = p->force.u_dt / p->u * dt; if (fabsf(w) < 0.01f) /* 1st order expansion of exp(w) */ u = p->u *= - 1.0f + - w * (1.0f + w * (0.5f + w * (1.0f / 6.0f + 1.0f / 24.0f * w))); + 1.0f + w * (1.0f + w * (0.5f + w * (1.0f / 6.0f + 1.0f / 24.0f * w))); else u = p->u *= expf(w); - + /* Predict gradient term */ p->force.POrho2 = u * (const_hydro_gamma - 1.0f) / (p->rho * xp->omega); - } /** - * @brief Finishes the force calculation. + * @brief Finishes the force calculation. * - * Multiplies the forces and accelerationsby the appropiate constants + * Multiplies the forces and accelerationsby the appropiate constants * * @param p The particle to act upon */ -__attribute__((always_inline)) INLINE static void hydro_end_force(struct part* p) { +__attribute__((always_inline)) + INLINE static void hydro_end_force(struct part* p) { - p->force.h_dt *= p->h * 0.333333333f; - + p->force.h_dt *= p->h * 0.333333333f; } diff --git a/src/hydro/Default/hydro_part.h b/src/hydro/Default/hydro_part.h index e8fb93516f493b3d5e037aab2b3d04b68e62ab4e..6bfe81822f1519b1239428234a72a48868cf170e 100644 --- a/src/hydro/Default/hydro_part.h +++ b/src/hydro/Default/hydro_part.h @@ -37,7 +37,6 @@ struct xpart { } __attribute__((aligned(xpart_align))); - /* Data of a single particle. */ struct part { @@ -73,45 +72,45 @@ struct part { float alpha; /* Store density/force specific stuff. */ - //union { - - struct { - - /* Particle velocity divergence. */ - float div_v; - - /* Derivative of particle number density. */ - float wcount_dh; - - /* Particle velocity curl. */ - float curl_v[3]; - - /* Particle number density. */ - float wcount; - - } density; - - struct { - - /* Balsara switch */ - float balsara; - - /* Aggregate quantities. */ - float POrho2; - - /* Change in particle energy over time. */ - float u_dt; - - /* Change in smoothing length over time. */ - float h_dt; - - /* Signal velocity */ - float v_sig; - - /* Sound speed */ - float c; - - } force; + // union { + + struct { + + /* Particle velocity divergence. */ + float div_v; + + /* Derivative of particle number density. */ + float wcount_dh; + + /* Particle velocity curl. */ + float curl_v[3]; + + /* Particle number density. */ + float wcount; + + } density; + + struct { + + /* Balsara switch */ + float balsara; + + /* Aggregate quantities. */ + float POrho2; + + /* Change in particle energy over time. */ + float u_dt; + + /* Change in smoothing length over time. */ + float h_dt; + + /* Signal velocity */ + float v_sig; + + /* Sound speed */ + float c; + + } force; //}; /* Particle mass. */ @@ -122,5 +121,5 @@ struct part { /* Pointer to corresponding gravity part. */ struct gpart* gpart; - + } __attribute__((aligned(part_align))); diff --git a/src/hydro/Gadget2/hydro.h b/src/hydro/Gadget2/hydro.h index 143c5af0628ce578d906996bd5284e5a67a0b42d..7ac07f499e1b1997f07dde6361d9f80c4c42ba1e 100644 --- a/src/hydro/Gadget2/hydro.h +++ b/src/hydro/Gadget2/hydro.h @@ -28,28 +28,27 @@ __attribute__((always_inline)) INLINE static float hydro_compute_timestep( struct part* p, struct xpart* xp) { /* Acceleration */ - float ac = sqrtf(p->a[0]*p->a[0] + p->a[1]*p->a[1] + p->a[2]*p->a[2]); + float ac = sqrtf(p->a[0] * p->a[0] + p->a[1] * p->a[1] + p->a[2] * p->a[2]); ac = fmaxf(ac, 1e-30); - const float dt_accel = sqrtf(2.f); //MATTHIEU - + const float dt_accel = sqrtf(2.f); // MATTHIEU + /* CFL condition */ const float dt_cfl = 2.f * const_cfl * p->h / p->v_sig; - return fminf(dt_cfl, dt_accel); + return fminf(dt_cfl, dt_accel); } - - /** * @brief Prepares a particle for the density calculation. * - * Zeroes all the relevant arrays in preparation for the sums taking place in + * Zeroes all the relevant arrays in preparation for the sums taking place in * the variaous density tasks * * @param p The particle to act upon */ -__attribute__((always_inline)) INLINE static void hydro_init_part(struct part* p) { +__attribute__((always_inline)) + INLINE static void hydro_init_part(struct part* p) { p->density.wcount = 0.f; p->density.wcount_dh = 0.f; p->rho = 0.f; @@ -62,33 +61,34 @@ __attribute__((always_inline)) INLINE static void hydro_init_part(struct part* p } /** - * @brief Finishes the density calculation. + * @brief Finishes the density calculation. * - * Multiplies the density and number of neighbours by the appropiate constants + * Multiplies the density and number of neighbours by the appropiate constants * and add the self-contribution term. * * @param p The particle to act upon * @param time The current time */ -__attribute__((always_inline)) INLINE static void hydro_end_density(struct part* p, float time) { +__attribute__((always_inline)) + INLINE static void hydro_end_density(struct part* p, float time) { /* Some smoothing length multiples. */ const float h = p->h; const float ih = 1.0f / h; const float ih2 = ih * ih; const float ih4 = ih2 * ih2; - + /* Final operation on the density (add self-contribution). */ p->rho += p->mass * kernel_root; p->rho_dh -= 3.0f * p->mass * kernel_root * kernel_igamma; p->density.wcount += kernel_root; - + /* Finish the calculation by inserting the missing h-factors */ p->rho *= ih * ih2; - p->rho_dh *= ih4; + p->rho_dh *= ih4; p->density.wcount *= (4.0f / 3.0 * M_PI * kernel_gamma3); p->density.wcount_dh *= ih * (4.0f / 3.0 * M_PI * kernel_gamma3); - + /* Compute the derivative term */ p->rho_dh = 1.f / (1.f + 0.33333333f * p->h * p->rho_dh / p->rho); @@ -98,20 +98,19 @@ __attribute__((always_inline)) INLINE static void hydro_end_density(struct part* p->rot_v[2] *= ih4; /* And compute the norm of the curl */ - p->curl_v = sqrtf(p->rot_v[0] * p->rot_v[0] + - p->rot_v[1] * p->rot_v[1] + - p->rot_v[2] * p->rot_v[2]) / p->rho; - + p->curl_v = sqrtf(p->rot_v[0] * p->rot_v[0] + p->rot_v[1] * p->rot_v[1] + + p->rot_v[2] * p->rot_v[2]) / + p->rho; + /* Finish calculation of the velocity divergence */ p->div_v *= ih4 / p->rho; - - /* Compute the pressure */ - const float dt = time - 0.5f*(p->t_begin + p->t_end); - p->pressure = (p->entropy + p->entropy_dt * dt) * powf(p->rho, const_hydro_gamma); + /* Compute the pressure */ + const float dt = time - 0.5f * (p->t_begin + p->t_end); + p->pressure = + (p->entropy + p->entropy_dt * dt) * powf(p->rho, const_hydro_gamma); } - /** * @brief Prepare a particle for the force calculation. * @@ -120,8 +119,8 @@ __attribute__((always_inline)) INLINE static void hydro_end_density(struct part* * @param p The particle to act upon * @param xp The extended particle data to act upon */ -__attribute__((always_inline)) INLINE static void hydro_prepare_force(struct part* p, - struct xpart* xp) { +__attribute__((always_inline)) + INLINE static void hydro_prepare_force(struct part* p, struct xpart* xp) { /* Some smoothing length multiples. */ /* const float h = p->h; */ @@ -129,30 +128,30 @@ __attribute__((always_inline)) INLINE static void hydro_prepare_force(struct par /* const float ih2 = ih * ih; */ /* const float ih4 = ih2 * ih2; */ - /* /\* Pre-compute some stuff for the balsara switch. *\/ */ /* const float normDiv_v = fabs(p->density.div_v / p->rho * ih4); */ - /* const float normCurl_v = sqrtf(p->density.curl_v[0] * p->density.curl_v[0] + */ - /* p->density.curl_v[1] * p->density.curl_v[1] + */ - /* p->density.curl_v[2] * p->density.curl_v[2]) / */ + /* const float normCurl_v = sqrtf(p->density.curl_v[0] * p->density.curl_v[0] + * + */ + /* p->density.curl_v[1] * p->density.curl_v[1] + + */ + /* p->density.curl_v[2] * p->density.curl_v[2]) / + */ /* p->rho * ih4; */ /* /\* Compute this particle's sound speed. *\/ */ /* const float u = p->u; */ /* const float fc = p->force.c = */ /* sqrtf(const_hydro_gamma * (const_hydro_gamma - 1.0f) * u); */ - + /* /\* Compute the P/Omega/rho2. *\/ */ /* xp->omega = 1.0f + 0.3333333333f * h * p->rho_dh / p->rho; */ /* p->force.POrho2 = u * (const_hydro_gamma - 1.0f) / (p->rho * xp->omega); */ - + /* /\* Balsara switch *\/ */ /* p->force.balsara = */ /* normDiv_v / (normDiv_v + normCurl_v + 0.0001f * fc * ih); */ } - - /** * @brief Reset acceleration fields of a particle * @@ -161,21 +160,21 @@ __attribute__((always_inline)) INLINE static void hydro_prepare_force(struct par * * @param p The particle to act upon */ -__attribute__((always_inline)) INLINE static void hydro_reset_acceleration(struct part* p) { +__attribute__((always_inline)) + INLINE static void hydro_reset_acceleration(struct part* p) { /* Reset the acceleration. */ p->a[0] = 0.0f; p->a[1] = 0.0f; p->a[2] = 0.0f; - + /* Reset the time derivatives. */ p->entropy_dt = 0.0f; - + /* Reset maximal signal velocity */ p->v_sig = 0.0f; } - /** * @brief Predict additional particle fields forward in time when drifting * @@ -184,34 +183,31 @@ __attribute__((always_inline)) INLINE static void hydro_reset_acceleration(struc * @param t0 The time at the start of the drift * @param t1 The time at the end of the drift */ -__attribute__((always_inline)) INLINE static void hydro_predict_extra(struct part* p, - struct xpart* xp, - float t0, - float t1) { +__attribute__((always_inline)) INLINE static void hydro_predict_extra( + struct part* p, struct xpart* xp, float t0, float t1) { const float dt = t1 - t0; - + p->rho *= expf(-p->div_v * dt); - p->h *= expf( 0.33333333f * p->div_v * dt); + p->h *= expf(0.33333333f * p->div_v * dt); - const float dt_entr = t1 - 0.5f*(p->t_begin + p->t_end); - p->pressure = (p->entropy + p->entropy_dt * dt_entr) * powf(p->rho, const_hydro_gamma); - + const float dt_entr = t1 - 0.5f * (p->t_begin + p->t_end); + p->pressure = + (p->entropy + p->entropy_dt * dt_entr) * powf(p->rho, const_hydro_gamma); } - - /** - * @brief Finishes the force calculation. + * @brief Finishes the force calculation. * - * Multiplies the forces and accelerationsby the appropiate constants + * Multiplies the forces and accelerationsby the appropiate constants * * @param p The particle to act upon */ -__attribute__((always_inline)) INLINE static void hydro_end_force(struct part* p) { +__attribute__((always_inline)) + INLINE static void hydro_end_force(struct part* p) { - p->entropy_dt *= (const_hydro_gamma - 1.f) * powf(p->rho, -(const_hydro_gamma - 1.f)); - + p->entropy_dt *= + (const_hydro_gamma - 1.f) * powf(p->rho, -(const_hydro_gamma - 1.f)); } /** @@ -219,31 +215,31 @@ __attribute__((always_inline)) INLINE static void hydro_end_force(struct part* p * * @param p The particle to act upon */ -__attribute__((always_inline)) INLINE static void hydro_kick_extra(struct part* p, float dt) { +__attribute__((always_inline)) + INLINE static void hydro_kick_extra(struct part* p, float dt) { /* Do not decrease the entropy (temperature) by more than a factor of 2*/ const float entropy_change = p->entropy_dt * dt; - if( entropy_change > -0.5f * p->entropy) + if (entropy_change > -0.5f * p->entropy) p->entropy += entropy_change; else p->entropy *= 0.5f; /* Do not 'overcool' when timestep increases */ - if(p->entropy + 0.5f * p->entropy_dt * dt < 0.5f * p->entropy) + if (p->entropy + 0.5f * p->entropy_dt * dt < 0.5f * p->entropy) p->entropy_dt = -0.5f * p->entropy / dt; - } - /** - * @brief Converts hydro quantity of a particle + * @brief Converts hydro quantity of a particle * * Requires the density to be known * * @param p The particle to act upon */ -__attribute__((always_inline)) INLINE static void hydro_convert_quantities(struct part* p) { - - p->entropy = (const_hydro_gamma - 1.f) * p->entropy * powf(p->rho, -(const_hydro_gamma - 1.f)); +__attribute__((always_inline)) + INLINE static void hydro_convert_quantities(struct part* p) { + p->entropy = (const_hydro_gamma - 1.f) * p->entropy * + powf(p->rho, -(const_hydro_gamma - 1.f)); } diff --git a/src/hydro/Gadget2/hydro_iact.h b/src/hydro/Gadget2/hydro_iact.h index 832f735eabd8f8f3742b13f45addbb0784f363c0..31528b63f5b3dc89ce533a3a7acafabee3c91332 100644 --- a/src/hydro/Gadget2/hydro_iact.h +++ b/src/hydro/Gadget2/hydro_iact.h @@ -26,7 +26,6 @@ #include "part.h" #include "vector.h" - /** * @brief SPH interaction functions following the Gadget-2 version of SPH. * @@ -69,12 +68,11 @@ __attribute__((always_inline)) INLINE static void runner_iact_density( /* Compute contribution to the density */ pi->rho += mj * wi; pi->rho_dh -= mj * kernel_igamma * (3.f * wi + ui * wi_dx); - + /* Compute contribution to the number of neighbours */ pi->density.wcount += wi; pi->density.wcount_dh -= ui * wi_dx; - /* Compute the kernel function for pj */ const float hj_inv = 1.f / hj; const float uj = r * hj_inv; @@ -83,15 +81,14 @@ __attribute__((always_inline)) INLINE static void runner_iact_density( /* Compute contribution to the density */ pj->rho += mi * wj; pj->rho_dh -= mi * kernel_igamma * (3.f * wj + uj * wj_dx); - + /* Compute contribution to the number of neighbours */ pj->density.wcount += wj; pj->density.wcount_dh -= uj * wj_dx; - const float faci = mj * wi_dx * r_inv; const float facj = mi * wj_dx * r_inv; - + /* Compute dv dot r */ dv[0] = pi->v[0] - pj->v[0]; dv[1] = pi->v[1] - pj->v[1]; @@ -115,7 +112,6 @@ __attribute__((always_inline)) INLINE static void runner_iact_density( pj->rot_v[2] += facj * curlvr[2]; } - /** * @brief Density loop (non-symmetric version) */ @@ -132,7 +128,7 @@ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_density( /* Get r and r inverse. */ const float r = sqrtf(r2); const float ri = 1.0f / r; - + /* Compute the kernel function */ const float h_inv = 1.0f / hi; const float u = r * h_inv; @@ -148,9 +144,9 @@ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_density( /* const float ih3 = h_inv * h_inv * h_inv; */ /* const float ih4 = h_inv * h_inv * h_inv * h_inv; */ - + const float fac = mj * wi_dx * ri; - + /* Compute dv dot r */ dv[0] = pi->v[0] - pj->v[0]; dv[1] = pi->v[1] - pj->v[1]; @@ -159,7 +155,8 @@ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_density( pi->div_v -= fac * dvdr; /* if(pi->id == 515050 && pj->id == 504849) */ - /* message("Interacting with %lld. r=%e hi=%e u=%e W=%e dW/dx=%e dh_drho1=%e dh_drho2=%e\n fac=%e dvdr=%e pj->v=[%.3e,%.3e,%.3e]", */ + /* message("Interacting with %lld. r=%e hi=%e u=%e W=%e dW/dx=%e dh_drho1=%e + * dh_drho2=%e\n fac=%e dvdr=%e pj->v=[%.3e,%.3e,%.3e]", */ /* pj->id, */ /* r, */ /* hi, */ @@ -175,7 +172,6 @@ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_density( /* pj->v[2] */ /* ); */ - /* Compute dv cross r */ curlvr[0] = dv[1] * dx[2] - dv[2] * dx[1]; curlvr[1] = dv[2] * dx[0] - dv[0] * dx[2]; @@ -183,10 +179,9 @@ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_density( pi->rot_v[0] += fac * curlvr[0]; pi->rot_v[1] += fac * curlvr[1]; - pi->rot_v[2] += fac * curlvr[2]; + pi->rot_v[2] += fac * curlvr[2]; } - /** * @brief Force loop */ @@ -197,12 +192,12 @@ __attribute__((always_inline)) INLINE static void runner_iact_force( float wi, wj, wi_dx, wj_dx; const float fac_mu = 1.f; /* Will change with cosmological integration */ - + const float r = sqrtf(r2); const float r_inv = 1.0f / r; /* Get some values in local variables. */ - //const float mi = pi->mass; + // const float mi = pi->mass; const float mj = pj->mass; const float rhoi = pi->rho; const float rhoj = pj->rho; @@ -231,10 +226,11 @@ __attribute__((always_inline)) INLINE static void runner_iact_force( const float ci = sqrtf(const_hydro_gamma * pressurei / rhoi); const float cj = sqrtf(const_hydro_gamma * pressurej / rhoj); float v_sig = ci + cj; - + /* Compute dv dot r. */ - const float dvdr = (pi->v[0] - pj->v[0]) * dx[0] + (pi->v[1] - pj->v[1]) * dx[1] + - (pi->v[2] - pj->v[2]) * dx[2]; + const float dvdr = (pi->v[0] - pj->v[0]) * dx[0] + + (pi->v[1] - pj->v[1]) * dx[1] + + (pi->v[2] - pj->v[2]) * dx[2]; /* Artificial viscosity term */ float visc = 0.f; @@ -242,22 +238,26 @@ __attribute__((always_inline)) INLINE static void runner_iact_force( const float mu_ij = fac_mu * dvdr * r_inv; v_sig -= 3.f * mu_ij; const float rho_ij = 0.5f * (rhoi + rhoj); - const float balsara_i = fabsf(pi->div_v) / (fabsf(pi->div_v) + pi->curl_v + 0.0001 * ci / fac_mu / hi); - const float balsara_j = fabsf(pj->div_v) / (fabsf(pj->div_v) + pj->curl_v + 0.0001 * cj / fac_mu / hj); - visc = -0.25f * const_viscosity_alpha * v_sig * mu_ij / rho_ij * (balsara_i + balsara_j); + const float balsara_i = fabsf(pi->div_v) / (fabsf(pi->div_v) + pi->curl_v + + 0.0001 * ci / fac_mu / hi); + const float balsara_j = fabsf(pj->div_v) / (fabsf(pj->div_v) + pj->curl_v + + 0.0001 * cj / fac_mu / hj); + visc = -0.25f * const_viscosity_alpha * v_sig * mu_ij / rho_ij * + (balsara_i + balsara_j); } /* Now, convolve with the kernel */ const float visc_term = 0.5f * mj * visc * (wi_dr + wj_dr) * r_inv; - const float sph_term = mj * (P_over_rho_i * wi_dr + P_over_rho_j * wj_dr) * r_inv; + const float sph_term = + mj * (P_over_rho_i * wi_dr + P_over_rho_j * wj_dr) * r_inv; /* Eventually got the acceleration */ const float acc = visc_term + sph_term; - /* //if(pi->id == 1000 && pj->id == 1100) */ /* if(pi->id == 515050 && pj->id == 504849) */ - /* message("Interacting with %lld. r=%e hi=%e hj=%e dWi/dx=%e dWj/dx=%3e dvdr=%e visc=%e sph=%e", */ + /* message("Interacting with %lld. r=%e hi=%e hj=%e dWi/dx=%e dWj/dx=%3e + * dvdr=%e visc=%e sph=%e", */ /* pj->id, */ /* r, */ /* 2*hi, */ @@ -271,7 +271,6 @@ __attribute__((always_inline)) INLINE static void runner_iact_force( /* if(pi->id == 1100 && pj->id == 1000) */ /* message("oO"); */ - /* Use the force Luke ! */ pi->a[0] -= acc * dx[0]; pi->a[1] -= acc * dx[1]; @@ -282,15 +281,14 @@ __attribute__((always_inline)) INLINE static void runner_iact_force( pj->a[2] += acc * dx[2]; /* Update the signal velocity. */ - pi->v_sig = fmaxf(pi->v_sig, v_sig) ; - pj->v_sig = fmaxf(pj->v_sig, v_sig) ; - + pi->v_sig = fmaxf(pi->v_sig, v_sig); + pj->v_sig = fmaxf(pj->v_sig, v_sig); + /* Change in entropy */ pi->entropy_dt += 0.5f * visc_term * dvdr; pj->entropy_dt -= 0.5f * visc_term * dvdr; } - /** * @brief Force loop (non-symmetric version) */ @@ -301,12 +299,12 @@ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_force( float wi, wj, wi_dx, wj_dx; const float fac_mu = 1.f; /* Will change with cosmological integration */ - + const float r = sqrtf(r2); const float r_inv = 1.0f / r; /* Get some values in local variables. */ - //const float mi = pi->mass; + // const float mi = pi->mass; const float mj = pj->mass; const float rhoi = pi->rho; const float rhoj = pj->rho; @@ -335,10 +333,11 @@ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_force( const float ci = sqrtf(const_hydro_gamma * pressurei / rhoi); const float cj = sqrtf(const_hydro_gamma * pressurej / rhoj); float v_sig = ci + cj; - + /* Compute dv dot r. */ - const float dvdr = (pi->v[0] - pj->v[0]) * dx[0] + (pi->v[1] - pj->v[1]) * dx[1] + - (pi->v[2] - pj->v[2]) * dx[2]; + const float dvdr = (pi->v[0] - pj->v[0]) * dx[0] + + (pi->v[1] - pj->v[1]) * dx[1] + + (pi->v[2] - pj->v[2]) * dx[2]; /* Artificial viscosity term */ float visc = 0.f; @@ -346,29 +345,32 @@ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_force( const float mu_ij = fac_mu * dvdr * r_inv; v_sig -= 3.f * mu_ij; const float rho_ij = 0.5f * (rhoi + rhoj); - const float balsara_i = fabsf(pi->div_v) / (fabsf(pi->div_v) + pi->curl_v + 0.0001 * ci / fac_mu / hi); - const float balsara_j = fabsf(pj->div_v) / (fabsf(pj->div_v) + pj->curl_v + 0.0001 * cj / fac_mu / hj); - visc = -0.25f * const_viscosity_alpha * v_sig * mu_ij / rho_ij * (balsara_i + balsara_j); + const float balsara_i = fabsf(pi->div_v) / (fabsf(pi->div_v) + pi->curl_v + + 0.0001 * ci / fac_mu / hi); + const float balsara_j = fabsf(pj->div_v) / (fabsf(pj->div_v) + pj->curl_v + + 0.0001 * cj / fac_mu / hj); + visc = -0.25f * const_viscosity_alpha * v_sig * mu_ij / rho_ij * + (balsara_i + balsara_j); } /* Now, convolve with the kernel */ const float visc_term = 0.5f * mj * visc * (wi_dr + wj_dr) * r_inv; - const float sph_term = mj * (P_over_rho_i * wi_dr + P_over_rho_j * wj_dr) * r_inv; + const float sph_term = + mj * (P_over_rho_i * wi_dr + P_over_rho_j * wj_dr) * r_inv; /* Eventually got the acceleration */ const float acc = visc_term + sph_term; - + /* Use the force Luke ! */ pi->a[0] -= acc * dx[0]; pi->a[1] -= acc * dx[1]; pi->a[2] -= acc * dx[2]; /* Update the signal velocity. */ - pi->v_sig = fmaxf(pi->v_sig, v_sig) ; - + pi->v_sig = fmaxf(pi->v_sig, v_sig); + /* Change in entropy */ pi->entropy_dt += 0.5f * visc_term * dvdr; } - #endif /* SWIFT_RUNNER_IACT_LEGACY_H */ diff --git a/src/hydro/Gadget2/hydro_part.h b/src/hydro/Gadget2/hydro_part.h index 1624d99907a0a3a64efc78ea3ab3797731f3c9a3..8ad6a6ef24add67f6fcfea0059738b44b3f20175 100644 --- a/src/hydro/Gadget2/hydro_part.h +++ b/src/hydro/Gadget2/hydro_part.h @@ -37,7 +37,6 @@ struct xpart { } __attribute__((aligned(xpart_align))); - /* Data of a single particle. */ struct part { @@ -60,15 +59,15 @@ struct part { float t_end; struct { - + /* Number of neighbours */ float wcount; - + /* Number of neighbours spatial derivative */ float wcount_dh; } density; - + /* Particle entropy. */ float entropy; @@ -87,7 +86,7 @@ struct part { /* Entropy time derivative */ float entropy_dt; - + /* Velocity divergence */ float div_v; @@ -97,7 +96,7 @@ struct part { /* Signal velocity */ float v_sig; - + /* Particle ID. */ unsigned long long id; @@ -105,5 +104,3 @@ struct part { struct gpart* gpart; } __attribute__((aligned(part_align))); - - diff --git a/src/parallel_io.c b/src/parallel_io.c index 6320709f3595c4e03237e36a03a5e55fa4f52969..3d006a65801e7b4c6ba941959dec5a548cbb8231 100644 --- a/src/parallel_io.c +++ b/src/parallel_io.c @@ -270,8 +270,8 @@ void read_ic_parallel(char* fileName, double dim[3], struct part** parts, COMPULSORY); readArray(h_grp, "SmoothingLength", FLOAT, *N, 1, *parts, N_total, offset, h, COMPULSORY); - readArray(h_grp, "InternalEnergy", FLOAT, *N, 1, *parts, N_total, offset, entropy, - COMPULSORY); + readArray(h_grp, "InternalEnergy", FLOAT, *N, 1, *parts, N_total, offset, + entropy, COMPULSORY); readArray(h_grp, "ParticleIDs", ULONGLONG, *N, 1, *parts, N_total, offset, id, COMPULSORY); /* readArray(h_grp, "TimeStep", FLOAT, *N, 1, *parts, N_total, offset, dt, */ @@ -580,7 +580,8 @@ void write_output_parallel(struct engine* e, struct UnitSystem* us, writeArray(h_grp, fileName, xmfFile, "SmoothingLength", FLOAT, N, 1, parts, N_total, mpi_rank, offset, h, us, UNIT_CONV_LENGTH); writeArray(h_grp, fileName, xmfFile, "InternalEnergy", FLOAT, N, 1, parts, - N_total, mpi_rank, offset, entropy, us, UNIT_CONV_ENERGY_PER_UNIT_MASS); + N_total, mpi_rank, offset, entropy, us, + UNIT_CONV_ENERGY_PER_UNIT_MASS); writeArray(h_grp, fileName, xmfFile, "ParticleIDs", ULONGLONG, N, 1, parts, N_total, mpi_rank, offset, id, us, UNIT_CONV_NO_UNITS); /* writeArray(h_grp, fileName, xmfFile, "TimeStep", FLOAT, N, 1, parts, diff --git a/src/part.c b/src/part.c index 6d49887ad72d6afdd1f419cfdaca88090e781f3e..6a99325ef23a7062fafb387fa3f3bd6b2203d057 100644 --- a/src/part.c +++ b/src/part.c @@ -55,10 +55,10 @@ void part_create_mpi_type(MPI_Datatype* part_type) { void xpart_create_mpi_type(MPI_Datatype* xpart_type) { /* This is not the recommended way of doing this. - One should define the structure field by field - But as long as we don't do serialization via MPI-IO - we don't really care. - Also we would have to modify this function everytime something + One should define the structure field by field + But as long as we don't do serialization via MPI-IO + we don't really care. + Also we would have to modify this function everytime something is added to the part structure. */ MPI_Type_contiguous(sizeof(struct xpart) / sizeof(unsigned char), MPI_BYTE, xpart_type); diff --git a/src/part.h b/src/part.h index 99e7f9d9a3d5357d70cd69964277cf707779a955..3aaa28939c240bb24fb7053ad949f8b7ec999a88 100644 --- a/src/part.h +++ b/src/part.h @@ -46,7 +46,6 @@ #include "./gravity/Default/gravity_part.h" - #ifdef WITH_MPI void part_create_mpi_type(MPI_Datatype* part_type); void xpart_create_mpi_type(MPI_Datatype* xpart_type); diff --git a/src/queue.c b/src/queue.c index af84c4b1f5e7e80fac05e5b122703fa718b7fead..a7321155100df9225526c2f19fac2b99531307e4 100644 --- a/src/queue.c +++ b/src/queue.c @@ -130,7 +130,8 @@ void queue_init(struct queue *q, struct task *tasks) { * @param blocking Block until access to the queue is granted. */ -struct task *queue_gettask(struct queue *q, const struct task *prev, int blocking) { +struct task *queue_gettask(struct queue *q, const struct task *prev, + int blocking) { lock_type *qlock = &q->lock; struct task *res = NULL; @@ -212,7 +213,7 @@ struct task *queue_gettask(struct queue *q, const struct task *prev, int blockin /* Another one bites the dust. */ const int qcount = q->count -= 1; - + /* Get a pointer on the task that we want to return. */ res = &qtasks[tid]; diff --git a/src/queue.h b/src/queue.h index 7f6d13c425f80cac20125bf422fe9da1ed06361f..9ce52ea5404db727f29d0f1cf898f5f5a4f6d935 100644 --- a/src/queue.h +++ b/src/queue.h @@ -55,7 +55,8 @@ struct queue { } __attribute__((aligned(64))); /* Function prototypes. */ -struct task *queue_gettask(struct queue *q, const struct task *prev, int blocking); +struct task *queue_gettask(struct queue *q, const struct task *prev, + int blocking); void queue_init(struct queue *q, struct task *tasks); void queue_insert(struct queue *q, struct task *t); diff --git a/src/runner.c b/src/runner.c index c068618f570912d69425d3867c4758ac732d7833..a32651693d99e0c9b48663fb9f184101fcb03be3 100644 --- a/src/runner.c +++ b/src/runner.c @@ -497,30 +497,27 @@ void runner_doinit(struct runner *r, struct cell *c, int timer) { const float t_end = r->e->time; TIMER_TIC; - + /* Recurse? */ if (c->split) { for (int k = 0; k < 8; k++) if (c->progeny[k] != NULL) runner_doinit(r, c->progeny[k], 0); return; - } - else { - + } else { + /* Loop over the parts in this cell. */ for (int i = 0; i < count; i++) { - + /* Get a direct pointer on the part. */ p = &parts[i]; if (p->t_end <= t_end) { - /* if(p->id == 1000) message("init 1000!"); */ - /* if(p->id == 515050) message("init 515050!"); */ - + /* if(p->id == 1000) message("init 1000!"); */ + /* if(p->id == 515050) message("init 515050!"); */ - - /* Get ready for a density calculation */ - hydro_init_part(p); + /* Get ready for a density calculation */ + hydro_init_part(p); } } } @@ -534,8 +531,6 @@ void runner_doinit(struct runner *r, struct cell *c, int timer) { TIMER_TOC(timer_init); #endif } - - } /** @@ -585,12 +580,12 @@ void runner_doghost(struct runner *r, struct cell *c) { /* if(p->id == 1000) message("ghost 1000"); */ /* if(p->id == 515050) message("ghost 515050"); */ - + /* Is this part within the timestep? */ if (p->t_end <= t_end) { - /* Finish the density calculation */ - hydro_end_density(p, t_end); + /* Finish the density calculation */ + hydro_end_density(p, t_end); /* If no derivative, double the smoothing length. */ if (p->density.wcount_dh == 0.0f) h_corr = p->h; @@ -606,7 +601,7 @@ void runner_doghost(struct runner *r, struct cell *c) { /* Did we get the right number density? */ if (p->density.wcount > kernel_nwneigh + const_delta_nwneigh || - p->density. wcount < kernel_nwneigh - const_delta_nwneigh) { + p->density.wcount < kernel_nwneigh - const_delta_nwneigh) { /* Ok, correct then */ p->h += h_corr; @@ -615,26 +610,25 @@ void runner_doghost(struct runner *r, struct cell *c) { pid[redo] = pid[i]; redo += 1; - /* Re-initialise everything */ - hydro_init_part(p); + /* Re-initialise everything */ + hydro_init_part(p); - /* Off we go ! */ + /* Off we go ! */ continue; } /* We now have a particle whose smoothing length has converged */ - //if(p->id == 1000) - // printParticle(parts, 1000, count); - + // if(p->id == 1000) + // printParticle(parts, 1000, count); + /* As of here, particle force variables will be set. Do _NOT_ try to read any particle density variables! */ - /* Compute variables required for the force loop */ - hydro_prepare_force(p, xp); - - /* Prepare the particle for the force loop over neighbours */ - hydro_reset_acceleration(p); + /* Compute variables required for the force loop */ + hydro_prepare_force(p, xp); + /* Prepare the particle for the force loop over neighbours */ + hydro_reset_acceleration(p); } } @@ -710,7 +704,7 @@ void runner_dodrift(struct runner *r, struct cell *c, int timer) { struct part *restrict p, *restrict parts = c->parts; struct xpart *restrict xp, *restrict xparts = c->xparts; float dx_max = 0.f, h_max = 0.f; - + TIMER_TIC /* No children? */ @@ -727,7 +721,7 @@ void runner_dodrift(struct runner *r, struct cell *c, int timer) { p->x[0] += xp->v_full[0] * dt; p->x[1] += xp->v_full[1] * dt; p->x[2] += xp->v_full[2] * dt; - + /* Predict velocities */ p->v[0] += p->a[0] * dt; p->v[1] += p->a[1] * dt; @@ -738,28 +732,29 @@ void runner_dodrift(struct runner *r, struct cell *c, int timer) { /* if (fabsf(w) < 0.01f) /\* 1st order expansion of exp(w) *\/ */ /* p->h *= */ /* 1.0f + */ - /* w * (1.0f + w * (0.5f + w * (1.0f / 6.0f + 1.0f / 24.0f * w))); */ + /* w * (1.0f + w * (0.5f + w * (1.0f / 6.0f + 1.0f / 24.0f * + * w))); */ /* else */ /* p->h *= expf(w); */ - //MATTHIEU - + // MATTHIEU + /* /\* Predict density *\/ */ /* w = -3.0f * p->force.h_dt * ih * dt; */ /* if (fabsf(w) < 0.1f) */ /* p->rho *= */ /* 1.0f + */ - /* w * (1.0f + w * (0.5f + w * (1.0f / 6.0f + 1.0f / 24.0f * w))); */ + /* w * (1.0f + w * (0.5f + w * (1.0f / 6.0f + 1.0f / 24.0f * + * w))); */ /* else */ /* p->rho *= expf(w); */ - - /* Predict the values of the extra fields */ hydro_predict_extra(p, xp, r->e->timeOld, r->e->time); /* if(p->id == 1000 || p->id == 515050 || p->id == 504849) */ - /* message("%lld: current_t=%f t0=%f t1=%f v=[%.3e %.3e %.3e]\n", */ + /* message("%lld: current_t=%f t0=%f t1=%f v=[%.3e %.3e %.3e]\n", + */ /* p->id, */ /* r->e->time, */ /* r->e->timeOld, */ @@ -768,11 +763,11 @@ void runner_dodrift(struct runner *r, struct cell *c, int timer) { /* p->v[1], */ /* p->v[2]); */ - /* Compute motion since last cell construction */ - const float dx = sqrtf((p->x[0] - xp->x_old[0]) * (p->x[0] - xp->x_old[0]) + - (p->x[1] - xp->x_old[1]) * (p->x[1] - xp->x_old[1]) + - (p->x[2] - xp->x_old[2]) * (p->x[2] - xp->x_old[2])); + const float dx = + sqrtf((p->x[0] - xp->x_old[0]) * (p->x[0] - xp->x_old[0]) + + (p->x[1] - xp->x_old[1]) * (p->x[1] - xp->x_old[1]) + + (p->x[2] - xp->x_old[2]) * (p->x[2] - xp->x_old[2])); dx_max = fmaxf(dx_max, dx); /* Maximal smoothing length */ @@ -789,15 +784,15 @@ void runner_dodrift(struct runner *r, struct cell *c, int timer) { struct cell *cp = c->progeny[k]; runner_dodrift(r, cp, 0); - dx_max = fmaxf(dx_max, cp->dx_max); - h_max = fmaxf(h_max, cp->h_max); + dx_max = fmaxf(dx_max, cp->dx_max); + h_max = fmaxf(h_max, cp->h_max); } } /* Store the values */ c->h_max = h_max; c->dx_max = dx_max; - + if (timer) { #ifdef TIMER_VERBOSE message("runner %02i: %i parts at depth %i took %.3f ms.", r->id, c->count, @@ -823,7 +818,8 @@ void runner_dokick(struct runner *r, struct cell *c, int timer) { const float global_dt_min = r->e->dt_min, global_dt_max = r->e->dt_max; const float t_current = r->e->time; const int count = c->count; - const int is_fixdt = (r->e->policy & engine_policy_fixdt) == engine_policy_fixdt; + const int is_fixdt = + (r->e->policy & engine_policy_fixdt) == engine_policy_fixdt; float new_dt; float dt_timeline; @@ -854,52 +850,52 @@ void runner_dokick(struct runner *r, struct cell *c, int timer) { x[2] = p->x[2]; /* If particle needs to be kicked */ - if ( is_fixdt || p->t_end <= t_current ) { + if (is_fixdt || p->t_end <= t_current) { /* First, finish the force loop */ - hydro_end_force(p); - - if( is_fixdt ) { - - /* Now we have a time step, proceed with the kick */ - new_dt = global_dt_max; - - } else { - - /* Compute the next timestep */ - const float new_dt_hydro = hydro_compute_timestep(p, xp); - const float new_dt_grav = gravity_compute_timestep(p, xp); - - new_dt = fminf(new_dt_hydro, new_dt_grav); - - /* Recover the current timestep */ - const float current_dt = p->t_end - p->t_begin; - - /* Limit timestep increase */ - if (current_dt > 0.0f) new_dt = fminf(new_dt, 2.0f * current_dt); - - /* Limit timestep within the allowed range */ - new_dt = fminf(new_dt, global_dt_max); - new_dt = fmaxf(new_dt, global_dt_min); - - /* Put this timestep on the time line */ - dt_timeline = dt_max_timeline; - while (new_dt < dt_timeline) dt_timeline /= 2.; - - /* Now we have a time step, proceed with the kick */ - new_dt = dt_timeline; - } + hydro_end_force(p); + + if (is_fixdt) { + + /* Now we have a time step, proceed with the kick */ + new_dt = global_dt_max; + + } else { + + /* Compute the next timestep */ + const float new_dt_hydro = hydro_compute_timestep(p, xp); + const float new_dt_grav = gravity_compute_timestep(p, xp); + + new_dt = fminf(new_dt_hydro, new_dt_grav); + + /* Recover the current timestep */ + const float current_dt = p->t_end - p->t_begin; + + /* Limit timestep increase */ + if (current_dt > 0.0f) new_dt = fminf(new_dt, 2.0f * current_dt); + + /* Limit timestep within the allowed range */ + new_dt = fminf(new_dt, global_dt_max); + new_dt = fmaxf(new_dt, global_dt_min); + + /* Put this timestep on the time line */ + dt_timeline = dt_max_timeline; + while (new_dt < dt_timeline) dt_timeline /= 2.; + + /* Now we have a time step, proceed with the kick */ + new_dt = dt_timeline; + } /* Compute the time step for this kick */ const float t_start = 0.5f * (p->t_begin + p->t_end); const float t_end = p->t_end + 0.5f * new_dt; const float dt = t_end - t_start; - const float half_dt = t_end - p->t_end; + const float half_dt = t_end - p->t_end; /* Move particle forward in time */ p->t_begin = p->t_end; p->t_end = p->t_begin + new_dt; - + /* Kick particles in momentum space */ xp->v_full[0] += p->a[0] * dt; xp->v_full[1] += p->a[1] * dt; @@ -909,20 +905,20 @@ void runner_dokick(struct runner *r, struct cell *c, int timer) { p->v[1] = xp->v_full[1] - half_dt * p->a[1]; p->v[2] = xp->v_full[2] - half_dt * p->a[2]; - /* if(p->id == 1000 || p->id == 515050 || p->id == 504849) */ - /* message("%lld: current_t=%f t_beg=%f t_end=%f half_dt=%f v=[%.3e %.3e %.3e]\n", */ - /* p->id, */ - /* t_current, */ - /* p->t_begin, */ - /* p->t_end, */ - /* half_dt, */ - /* p->v[0], */ - /* p->v[1], */ - /* p->v[2]); */ - - - /* Extra kick work */ - hydro_kick_extra(p, dt); + /* if(p->id == 1000 || p->id == 515050 || p->id == 504849) */ + /* message("%lld: current_t=%f t_beg=%f t_end=%f half_dt=%f v=[%.3e + * %.3e %.3e]\n", */ + /* p->id, */ + /* t_current, */ + /* p->t_begin, */ + /* p->t_end, */ + /* half_dt, */ + /* p->v[0], */ + /* p->v[1], */ + /* p->v[2]); */ + + /* Extra kick work */ + hydro_kick_extra(p, dt); } /* Now collect quantities for statistics */ @@ -965,7 +961,7 @@ void runner_dokick(struct runner *r, struct cell *c, int timer) { struct cell *cp = c->progeny[k]; runner_dokick(r, cp, 0); - updated += cp->updated; + updated += cp->updated; ekin += cp->ekin; epot += cp->epot; mom[0] += cp->mom[0]; @@ -1026,7 +1022,7 @@ void *runner_main(void *data) { engine_barrier(e, r->id); /* Re-set the pointer to the previous task, as there is none. */ - struct task* prev = NULL; + struct task *prev = NULL; /* Loop while there are tasks... */ while (1) { @@ -1054,7 +1050,7 @@ void *runner_main(void *data) { if (t->subtype == task_subtype_density) runner_doself1_density(r, ci); else if (t->subtype == task_subtype_force) - runner_doself2_force(r, ci); + runner_doself2_force(r, ci); else error("Unknown task subtype."); break; @@ -1062,7 +1058,7 @@ void *runner_main(void *data) { if (t->subtype == task_subtype_density) runner_dopair1_density(r, ci, cj); else if (t->subtype == task_subtype_force) - runner_dopair2_force(r, ci, cj); + runner_dopair2_force(r, ci, cj); else error("Unknown task subtype."); break; @@ -1121,7 +1117,8 @@ void *runner_main(void *data) { space_split(e->s, t->ci); break; case task_type_rewait: - scheduler_do_rewait((struct task *)t->ci, (struct task *)t->cj, t->flags, t->rank); + scheduler_do_rewait((struct task *)t->ci, (struct task *)t->cj, + t->flags, t->rank); break; default: error("Unknown task type."); diff --git a/src/runner_doiact.h b/src/runner_doiact.h index 416a45bea52439d3ab04db204de079263c233cce..cddd249acd77f305a456d7b78023d4e4ca613cc7 100644 --- a/src/runner_doiact.h +++ b/src/runner_doiact.h @@ -782,8 +782,7 @@ void DOPAIR1(struct runner *r, struct cell *ci, struct cell *cj) { TIMER_TIC /* Anything to do here? */ - if (ci->t_end_min > t_current && cj->t_end_min > t_current) - return; + if (ci->t_end_min > t_current && cj->t_end_min > t_current) return; /* Get the sort ID. */ sid = space_getsid(e->s, &ci, &cj, shift); @@ -1380,7 +1379,6 @@ void DOSELF1(struct runner *r, struct cell *restrict c) { #endif TIMER_TIC - /* Set up indt if needed. */ if (c->t_end_min > t_current) return; @@ -1402,7 +1400,7 @@ void DOSELF1(struct runner *r, struct cell *restrict c) { /* if(pi->id == 1000) message("oO 1000"); */ /* if(pi->id == 515050) message("oO 515050"); */ - + /* Get the particle position and radius. */ for (k = 0; k < 3; k++) pix[k] = pi->x[k]; hi = pi->h; @@ -1607,7 +1605,6 @@ void DOSELF2(struct runner *r, struct cell *restrict c) { #endif TIMER_TIC - /* Set up indt if needed. */ if (c->t_end_min > t_current) return; @@ -1630,7 +1627,6 @@ void DOSELF2(struct runner *r, struct cell *restrict c) { /* if(pi->id == 1000) message("oO 1000"); */ /* if(pi->id == 515050) message("oO 515050"); */ - /* Get the particle position and radius. */ for (k = 0; k < 3; k++) pix[k] = pi->x[k]; hi = pi->h; diff --git a/src/scheduler.c b/src/scheduler.c index f0aa8a0c81ab701add6a2d455a2e4d12b554a217..35f1504e25dec140d8746ec10bc644fb44f5374d 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -957,7 +957,8 @@ void scheduler_reweight(struct scheduler *s) { * @param submask The sub-task types to enqueue. */ -void scheduler_start(struct scheduler *s, unsigned int mask, unsigned int submask) { +void scheduler_start(struct scheduler *s, unsigned int mask, + unsigned int submask) { int nr_tasks = s->nr_tasks, *tid = s->tasks_ind; struct task *t, *tasks = s->tasks; @@ -983,9 +984,10 @@ void scheduler_start(struct scheduler *s, unsigned int mask, unsigned int submas : s->nr_queues; /* Remember that engine_launch may fiddle with this value. */ - const int waiting_old = s->waiting; + const int waiting_old = s->waiting; - /* We are going to use the task structure in a modified way to pass information + /* We are going to use the task structure in a modified way to pass + information to the task. Don't do this at home ! - ci and cj will give the range of tasks to which the waits will be applied - the flags will be used to transfer the mask @@ -1020,15 +1022,13 @@ void scheduler_start(struct scheduler *s, unsigned int mask, unsigned int submas s->mask = mask; s->submask = submask | (1 << task_subtype_none); - + /* Loop over the tasks and enqueue whoever is ready. */ // tic = getticks(); for (int k = 0; k < s->nr_tasks; k++) { t = &tasks[tid[k]]; - if (atomic_dec(&t->wait) == 1 && - ((1 << t->type) & s->mask) && - ((1 << t->subtype) & s->submask) && - !t->skip) { + if (atomic_dec(&t->wait) == 1 && ((1 << t->type) & s->mask) && + ((1 << t->subtype) & s->submask) && !t->skip) { scheduler_enqueue(s, t); pthread_cond_broadcast(&s->sleep_cond); } @@ -1056,7 +1056,8 @@ void scheduler_enqueue(struct scheduler *s, struct task *t) { if (t->rid >= 0) error("Task has already been enqueued."); /* Ignore skipped tasks and tasks not in the masks. */ - if (t->skip || (1 << t->type) & ~(s->mask) || (1 << t->subtype) & ~(s->submask)) { + if (t->skip || (1 << t->type) & ~(s->mask) || + (1 << t->subtype) & ~(s->submask)) { return; } @@ -1111,9 +1112,9 @@ void scheduler_enqueue(struct scheduler *s, struct task *t) { break; case task_type_send: #ifdef WITH_MPI - if ((err = MPI_Isend(t->ci->parts, t->ci->count, s->part_mpi_type, - t->cj->nodeID, t->flags, MPI_COMM_WORLD, - &t->req)) != MPI_SUCCESS) { + if ((err = MPI_Isend(t->ci->parts, t->ci->count, s->part_mpi_type, + t->cj->nodeID, t->flags, MPI_COMM_WORLD, + &t->req)) != MPI_SUCCESS) { char buff[MPI_MAX_ERROR_STRING]; int len; MPI_Error_string(err, buff, &len); @@ -1394,17 +1395,17 @@ void scheduler_print_tasks(struct scheduler *s, char *fileName) { * @param submask The scheduler subtask mask */ void scheduler_do_rewait(struct task *t_begin, struct task *t_end, - unsigned int mask, unsigned int submask) { + unsigned int mask, unsigned int submask) { for (struct task *t2 = t_begin; t2 != t_end; t2++) { - + if (t2->skip) continue; - + /* Skip tasks not in the mask */ if (!((1 << t2->type) & mask) || !((1 << t2->subtype) & submask)) continue; - + /* Skip sort tasks that have already been performed */ if (t2->type == task_type_sort && t2->flags == 0) continue; - + /* Sets the waits of the dependances */ for (int k = 0; k < t2->nr_unlock_tasks; k++) { struct task *t3 = t2->unlock_tasks[k]; @@ -1412,4 +1413,3 @@ void scheduler_do_rewait(struct task *t_begin, struct task *t_end, } } } - diff --git a/src/scheduler.h b/src/scheduler.h index 5c27fd83503396c10011e0f0322178b6f47122ce..3f2d8c289d0d691d0d155b20ae0522c5830524aa 100644 --- a/src/scheduler.h +++ b/src/scheduler.h @@ -64,7 +64,7 @@ struct scheduler { /* Scheduler sub-task mask */ unsigned int submask; - + /* Number of queues in this scheduler. */ int nr_queues; @@ -112,9 +112,10 @@ struct scheduler { void scheduler_init(struct scheduler *s, struct space *space, int nr_tasks, int nr_queues, unsigned int flags, int nodeID); struct task *scheduler_gettask(struct scheduler *s, int qid, - const struct task* prev); + const struct task *prev); void scheduler_enqueue(struct scheduler *s, struct task *t); -void scheduler_start(struct scheduler *s, unsigned int mask, unsigned int submask); +void scheduler_start(struct scheduler *s, unsigned int mask, + unsigned int submask); void scheduler_reset(struct scheduler *s, int nr_tasks); void scheduler_ranktasks(struct scheduler *s); void scheduler_reweight(struct scheduler *s); @@ -129,6 +130,6 @@ void scheduler_set_unlocks(struct scheduler *s); void scheduler_dump_queue(struct scheduler *s); void scheduler_print_tasks(struct scheduler *s, char *fileName); void scheduler_do_rewait(struct task *t_begin, struct task *t_end, - unsigned int mask, unsigned int submask); + unsigned int mask, unsigned int submask); #endif /* SWIFT_SCHEDULER_H */ diff --git a/src/serial_io.c b/src/serial_io.c index a8b9ecfdde135f0933b6942e0efb125867510908..806833213c56c6720d048da4aa7009a74f3b41ee 100644 --- a/src/serial_io.c +++ b/src/serial_io.c @@ -673,7 +673,7 @@ void write_output_serial(struct engine* e, struct UnitSystem* us, int mpi_rank, entropy); writeArray(h_grp, "ParticleIDs", ULONGLONG, N, 1, N_total, offset, parts, id); - //writeArray(h_grp, "TimeStep", FLOAT, N, 1, N_total, offset, parts, dt); + // writeArray(h_grp, "TimeStep", FLOAT, N, 1, N_total, offset, parts, dt); writeArray(h_grp, "Acceleration", FLOAT, N, 3, N_total, offset, parts, a); writeArray(h_grp, "Density", FLOAT, N, 1, N_total, offset, parts, rho); diff --git a/src/single_io.c b/src/single_io.c index 09a33ed96a77630fa72cf44668ff9c8a7a25fbc3..2e2a03ff0a8fc004f813ceda00e92e37a48a5f06 100644 --- a/src/single_io.c +++ b/src/single_io.c @@ -227,7 +227,8 @@ void read_ic_single(char* fileName, double dim[3], struct part** parts, int* N, readArray(h_grp, "Velocities", FLOAT, *N, 3, *parts, v, COMPULSORY); readArray(h_grp, "Masses", FLOAT, *N, 1, *parts, mass, COMPULSORY); readArray(h_grp, "SmoothingLength", FLOAT, *N, 1, *parts, h, COMPULSORY); - readArray(h_grp, "InternalEnergy", FLOAT, *N, 1, *parts, entropy, COMPULSORY); //MATTHIEU + readArray(h_grp, "InternalEnergy", FLOAT, *N, 1, *parts, entropy, + COMPULSORY); // MATTHIEU readArray(h_grp, "ParticleIDs", ULONGLONG, *N, 1, *parts, id, COMPULSORY); // readArray(h_grp, "TimeStep", FLOAT, *N, 1, *parts, dt, OPTIONAL); readArray(h_grp, "Acceleration", FLOAT, *N, 3, *parts, a, OPTIONAL); @@ -469,8 +470,8 @@ void write_output_single(struct engine* e, struct UnitSystem* us) { UNIT_CONV_MASS); writeArray(h_grp, fileName, xmfFile, "SmoothingLength", FLOAT, N, 1, parts, h, us, UNIT_CONV_LENGTH); - writeArray(h_grp, fileName, xmfFile, "InternalEnergy", FLOAT, N, 1, parts, entropy, - us, UNIT_CONV_ENERGY_PER_UNIT_MASS); //MATTHIEU + writeArray(h_grp, fileName, xmfFile, "InternalEnergy", FLOAT, N, 1, parts, + entropy, us, UNIT_CONV_ENERGY_PER_UNIT_MASS); // MATTHIEU writeArray(h_grp, fileName, xmfFile, "ParticleIDs", ULONGLONG, N, 1, parts, id, us, UNIT_CONV_NO_UNITS); /* writeArray(h_grp, fileName, xmfFile, "TimeStep", FLOAT, N, 1, parts, dt, diff --git a/src/space.c b/src/space.c index e021b9ff2e6bcd1f07a9571daa9bb5d41633e669..60f86bcde85fed7db603a44de6fd2a3555f16a43 100644 --- a/src/space.c +++ b/src/space.c @@ -1,21 +1,21 @@ - /******************************************************************************* - * This file is part of SWIFT. - * Copyright (c) 2012 Pedro Gonnet (pedro.gonnet@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/>. - * - ******************************************************************************/ +/******************************************************************************* +* This file is part of SWIFT. +* Copyright (c) 2012 Pedro Gonnet (pedro.gonnet@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/>. +* +******************************************************************************/ /* Config parameters. */ #include "../config.h" @@ -470,8 +470,8 @@ void space_rebuild(struct space *s, double cell_max, int verbose) { // tic = getticks(); // for (k = 0; k < s->nr_cells; k++) space_split(s, &cells[k]); for (k = 0; k < s->nr_cells; k++) - scheduler_addtask(&s->e->sched, task_type_split_cell, task_subtype_none, - k, 0, &cells[k], NULL, 0); + scheduler_addtask(&s->e->sched, task_type_split_cell, task_subtype_none, k, + 0, &cells[k], NULL, 0); engine_launch(s->e, s->e->nr_threads, 1 << task_type_split_cell, 0); // message( "space_split took %.3f ms." , (double)(getticks() - tic) / CPU_TPS @@ -517,7 +517,8 @@ void space_parts_sort(struct space *s, int *ind, int N, int min, int max) { /* Verify space_sort_struct. */ /* for (int i = 1; i < N; i++) if (ind[i - 1] > ind[i]) - error("Sorting failed (ind[%i]=%i,ind[%i]=%i), min=%i, max=%i.", i - 1, ind[i - 1], i, + error("Sorting failed (ind[%i]=%i,ind[%i]=%i), min=%i, max=%i.", i - 1, + ind[i - 1], i, ind[i], min, max); message("Sorting succeeded."); */ @@ -542,7 +543,7 @@ void space_do_parts_sort() { /* Wait for the entry to be ready, or for the sorting do be done. */ while (!space_sort_struct.stack[qid].ready) if (!space_sort_struct.waiting) return; - + /* Get the stack entry. */ int i = space_sort_struct.stack[qid].i; int j = space_sort_struct.stack[qid].j; @@ -598,7 +599,8 @@ void space_do_parts_sort() { if (jj > i && pivot > min) { qid = atomic_inc(&space_sort_struct.last) % space_sort_struct.stack_size; - while (space_sort_struct.stack[qid].ready); + while (space_sort_struct.stack[qid].ready) + ; space_sort_struct.stack[qid].i = i; space_sort_struct.stack[qid].j = jj; space_sort_struct.stack[qid].min = min; @@ -622,7 +624,8 @@ void space_do_parts_sort() { if (pivot + 1 < max) { qid = atomic_inc(&space_sort_struct.last) % space_sort_struct.stack_size; - while (space_sort_struct.stack[qid].ready); + while (space_sort_struct.stack[qid].ready) + ; space_sort_struct.stack[qid].i = jj + 1; space_sort_struct.stack[qid].j = j; space_sort_struct.stack[qid].min = pivot + 1; @@ -1229,5 +1232,4 @@ void space_link_cleanup(struct space *s) { /* Recursively apply the cell link cleaning routine */ space_map_cells_pre(s, 1, cell_clean_links, NULL); - } diff --git a/src/swift.h b/src/swift.h index 95b0abba00cda61fd0ac278f307e3737771c710a..9cd7ac65da305a995fb48ba9c931cb8a9be782e6 100644 --- a/src/swift.h +++ b/src/swift.h @@ -50,5 +50,4 @@ #include "tools.h" #include "version.h" - #endif /* SWIFT_SWIFT_H */ diff --git a/src/task.c b/src/task.c index 452ffd0e721fa2e8467e906f6b19f1d02db29fd5..f611ab8115b7ce24ddc1bd605df4cfd65de6348f 100644 --- a/src/task.c +++ b/src/task.c @@ -43,15 +43,13 @@ /* Task type names. */ const char *taskID_names[task_type_count] = { - "none", "sort", "self", "pair", "sub", "init", - "ghost", "drift", "kick", "send", "recv", - "grav_pp", "grav_mm", "grav_up", "grav_down", - "psort", "split_cell", "rewait"}; + "none", "sort", "self", "pair", "sub", "init", + "ghost", "drift", "kick", "send", "recv", "grav_pp", + "grav_mm", "grav_up", "grav_down", "psort", "split_cell", "rewait"}; const char *subtaskID_names[task_type_count] = {"none", "density", "force", "grav"}; - /** * @brief Computes the overlap between the parts array of two given cells. */ diff --git a/src/tools.c b/src/tools.c index 315bd0e7ef4a708341627b95596275f0e6188087..34cd4c436a128a3e177a7d4405b313130b143889 100644 --- a/src/tools.c +++ b/src/tools.c @@ -311,7 +311,7 @@ void density_dump(int N) { Pj[k].mass = 1.0f; Pj[k].rho = 0.0f; Pj[k].density.wcount = 0.0f; - Pj[k].id = k+4; + Pj[k].id = k + 4; hi[k] = 1.0; hj[k] = 1.0; } @@ -350,7 +350,7 @@ void engine_single_density(double *dim, long long int pid, /* Clear accumulators. */ ih = 1.0f / p.h; hydro_init_part(&p); - + /* Loop over all particle pairs (force). */ for (k = 0; k < N; k++) { if (parts[k].id == p.id) continue; @@ -396,7 +396,7 @@ void engine_single_force(double *dim, long long int pid, /* Clear accumulators. */ hydro_reset_acceleration(&p); - + /* Loop over all particle pairs (force). */ for (k = 0; k < N; k++) { // for ( k = N-1 ; k >= 0 ; k-- ) { @@ -420,7 +420,7 @@ void engine_single_force(double *dim, long long int pid, } /* Dump the result. */ - message("part %lli (h=%e) has a=[%.3e,%.3e,%.3e]", p.id, p.h, p.a[0], - p.a[1], p.a[2]); + message("part %lli (h=%e) has a=[%.3e,%.3e,%.3e]", p.id, p.h, p.a[0], p.a[1], + p.a[2]); fflush(stdout); } diff --git a/src/version.c b/src/version.c index 4624f036a0178f5b31b1aa24b1607507914444a7..6aeee2d8bcbc4652f679bbb786e9e512ebc4caa6 100644 --- a/src/version.c +++ b/src/version.c @@ -155,7 +155,6 @@ const char *compiler_version(void) { return version; } - /** * @brief return the MPI version, runtime if possible otherwise that used when * built. @@ -168,7 +167,7 @@ const char *mpi_version(void) { #ifdef WITH_MPI int std_version, std_subversion; - /* Check that the library implements the version string routine */ +/* Check that the library implements the version string routine */ #ifdef MPI_MAX_LIBRARY_VERSION_STRING static char lib_version[MPI_MAX_LIBRARY_VERSION_STRING] = {0}; int len; @@ -181,7 +180,7 @@ const char *mpi_version(void) { /* Also arbitrarily truncate to keep down to one line, Open MPI, * check for last comma and keep to ~60 chars max. */ - strcpy(lib_version+60, "..."); + strcpy(lib_version + 60, "..."); ptr = strrchr(lib_version, ','); if (ptr != NULL) *ptr = '\0'; @@ -193,8 +192,8 @@ const char *mpi_version(void) { /* Numeric version. */ MPI_Get_version(&std_version, &std_subversion); - snprintf(version, 80, "%s (MPI std v%i.%i)", lib_version, - std_version, std_subversion); + snprintf(version, 80, "%s (MPI std v%i.%i)", lib_version, std_version, + std_subversion); #else sprintf(version, "Code was not compiled with MPI support"); #endif