diff --git a/examples/main.c b/examples/main.c index 07bf70e2e6701486b43b83260b4f80c7cbf05a77..828448b8dd4237ac70fc77e622fb54e0ef5943ed 100644 --- a/examples/main.c +++ b/examples/main.c @@ -56,6 +56,12 @@ #define ENGINE_POLICY engine_policy_none #endif +#if defined(MINIMAL_SPH) || defined(GADGET2_SPH) || defined(DEFAULT_SPH) +#define ENGINE_HYDRO engine_policy_hydro +#else +#define ENGINE_HYDRO 0 +#endif + /** * @brief Main routine that loads a few particles and generates some output. * @@ -63,7 +69,7 @@ int main(int argc, char *argv[]) { - int c, icount, j, k, Ngas, Ndm, periodic = 1; + int c, icount, j, k, Ngas = 0, Ndm = 0, periodic = 1; long long N_total = -1; int nr_threads = 1, nr_queues = -1; int dump_tasks = 0; @@ -265,10 +271,10 @@ int main(int argc, char *argv[]) { tic = getticks(); #if defined(WITH_MPI) #if defined(HAVE_PARALLEL_HDF5) - read_ic_parallel(ICfileName, dim, &parts, &gparts, &Ngas, &Ndm, &periodic, myrank, nr_nodes, + read_ic_parallel(ICfileName, dim, &gparts, &Ndm, &periodic, myrank, nr_nodes, MPI_COMM_WORLD, MPI_INFO_NULL); #else - read_ic_serial(ICfileName, dim, &parts, &gparts, &Ngas, &Ndm, &periodic, myrank, nr_nodes, + read_ic_serial(ICfileName, dim, &gparts, &Ndm, &periodic, myrank, nr_nodes, MPI_COMM_WORLD, MPI_INFO_NULL); #endif #else @@ -282,7 +288,7 @@ int main(int argc, char *argv[]) { #if defined(WITH_MPI) long long tmp; - long long N_long = Ngas; + long long N_long = Ngas + Ndm; MPI_Reduce(&N_long, &tmp, 1, MPI_LONG_LONG, MPI_SUM, 0, MPI_COMM_WORLD); long long N_long = Ndm; MPI_Reduce(&N_long, &N_total, 1, MPI_LONG_LONG, MPI_SUM, 0, MPI_COMM_WORLD); @@ -292,9 +298,12 @@ int main(int argc, char *argv[]) { #endif if (myrank == 0) message("Read %lld particles from the ICs", N_total); + j = 0; /* Apply h scaling */ - if (scaling != 1.0) - for (k = 0; k < Ngas; k++) parts[k].h *= scaling; + if (scaling != 1.0) { + for (k = 0; k < Ngas; k++) + parts[k].h *= scaling; + } /* Apply shift */ if (shift[0] != 0 || shift[1] != 0 || shift[2] != 0) { @@ -331,6 +340,7 @@ int main(int argc, char *argv[]) { message("%i gas parts in %i cells.", s.nr_parts, s.tot_cells); message("%i dm parts in %i cells.", s.nr_gparts, s.tot_cells); message("maximum depth is %d.", s.maxdepth); + message("gparts[10].id = %ld.", gparts[10].id); // message( "cutoffs in [ %g %g ]." , s.h_min , s.h_max ); fflush(stdout); } @@ -352,7 +362,7 @@ int main(int argc, char *argv[]) { tic = getticks(); if (myrank == 0) message("nr_nodes is %i.", nr_nodes); engine_init(&e, &s, dt_max, nr_threads, nr_queues, nr_nodes, myrank, - ENGINE_POLICY | engine_policy_steal | engine_policy_hydro, 0, + ENGINE_POLICY | engine_policy_steal | ENGINE_HYDRO, 0, time_end, dt_min, dt_max); if (myrank == 0) message("engine_init took %.3f ms.", @@ -398,10 +408,10 @@ int main(int argc, char *argv[]) { 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); - exit(-99); + //exit(-99); /* Legend */ if (myrank == 0) printf( diff --git a/src/cell.c b/src/cell.c index 06312f448a2ebf2572ea32d58e8913b4faa40df4..2a631ab57bc39e00f26b080543364983545af90e 100644 --- a/src/cell.c +++ b/src/cell.c @@ -447,11 +447,11 @@ void cell_split(struct cell *c) { c->progeny[k]->parts = &c->parts[left[k]]; c->progeny[k]->xparts = &c->xparts[left[k]]; } - +#ifdef LINK /* Re-link the gparts. THIS IS BROKEN BUT NEEDS MENDING J & T */ - /* for (k = 0; k < count; k++) */ - /* if (parts[k].gpart != NULL) parts[k].gpart->part = &parts[k]; */ - + for (k = 0; k < count; k++) + if (parts[k].gpart != NULL) parts[k].gpart->part = &parts[k]; +#endif /* Verify that _all_ the parts have been assigned to a cell. */ /* for ( k = 1 ; k < 8 ; k++ ) if ( &c->progeny[k-1]->parts[ c->progeny[k-1]->count ] != @@ -541,10 +541,11 @@ void cell_split(struct cell *c) { c->progeny[k]->gcount = right[k] - left[k] + 1; c->progeny[k]->gparts = &c->gparts[left[k]]; } - +#ifdef LINK /* Re-link the parts. */ for (k = 0; k < gcount; k++) if (gparts[k].id > 0) gparts[k].part->gpart = &gparts[k]; +#endif } /** diff --git a/src/const.h b/src/const.h index 239ec18a5b3302436ce9e6cf7898a4a408546f97..fbd46ac488a6e63d8dcc49640c25344ebd360f10 100644 --- a/src/const.h +++ b/src/const.h @@ -67,14 +67,16 @@ /* SPH variant to use */ //#define MINIMAL_SPH -#define GADGET2_SPH +//#define GADGET2_SPH //#define DEFAULT_SPH - +#define NO_SPH /* Gravity properties */ #define GRAVITY /* valid choices DEFAULT_GRAVITY || EXTERNAL_POTENTIAL */ #define EXTERNAL_POTENTIAL +//#define DEFAULT_GRAVITY + /* System of units */ #define const_unit_length_in_cgs 1 /* 3.08567810e16 /\* 1Mpc *\/ */ diff --git a/src/debug.c b/src/debug.c index 2be981175eabe41a8a7e57aec4261a9b38def6ac..5ebb08fe4908de5a4bb06f29847b4198eef438be 100644 --- a/src/debug.c +++ b/src/debug.c @@ -34,6 +34,8 @@ #include "./hydro/Gadget2/hydro_debug.h" #elif defined(DEFAULT_SPH) #include "./hydro/Default/hydro_debug.h" +#elif defined(NO_SPH) +#include "./hydro/Gadget2/hydro_debug.h" #else #error "Invalid choice of SPH variant" #endif diff --git a/src/engine.c b/src/engine.c index 413cfb4a2e3416b435fb59ade50b9f308ecfa250..ac36b3b13ab22eaec338491af268b30f19c236df 100644 --- a/src/engine.c +++ b/src/engine.c @@ -1100,6 +1100,7 @@ void engine_maketasks(struct engine *e) { } } +#ifdef DEFAULT_GRAVITY /* Add the gravity mm tasks. */ for (i = 0; i < nr_cells; i++) if (cells[i].gcount > 0) { @@ -1110,7 +1111,9 @@ void engine_maketasks(struct engine *e) { scheduler_addtask(sched, task_type_grav_mm, task_subtype_none, -1, 0, &cells[i], &cells[j], 0); } - +#endif + scheduler_print_tasks(sched, "sched.txt"); + return; /* Split the tasks. */ scheduler_splittasks(sched); @@ -1122,7 +1125,7 @@ void engine_maketasks(struct engine *e) { if ((e->links = malloc(sizeof(struct link) * e->size_links)) == NULL) error("Failed to allocate cell-task links."); e->nr_links = 0; - +#ifdef GRAVITY /* Add the gravity up/down tasks at the top-level cells and push them down. */ for (k = 0; k < nr_cells; k++) if (cells[k].nodeID == nodeID && cells[k].gcount > 0) { @@ -1138,7 +1141,7 @@ void engine_maketasks(struct engine *e) { /* Push tasks down the cell hierarchy. */ engine_addtasks_grav(e, &cells[k], up, down); } - +#endif /* Count the number of tasks associated with each cell and store the density tasks in each cell, and make each sort depend on the sorts of its progeny. */ @@ -1184,7 +1187,7 @@ void engine_maketasks(struct engine *e) { } } } - +#ifdef DEFAULT_GRAVITY /* Link gravity multipole tasks to the up/down tasks. */ if (t->type == task_type_grav_mm || (t->type == task_type_sub && t->subtype == task_subtype_grav)) { @@ -1196,8 +1199,8 @@ void engine_maketasks(struct engine *e) { scheduler_addunlock(sched, t, t->cj->grav_down); } } +#endif } - /* Append a ghost task to each cell, and add kick tasks to the super cells. */ for (k = 0; k < nr_cells; k++) engine_mkghosts(e, &cells[k], NULL); @@ -1505,6 +1508,7 @@ void engine_rebuild(struct engine *e) { /* Re-build the tasks. */ // tic = getticks(); engine_maketasks(e); + // message( "engine_maketasks took %.3f ms." , (double)(getticks() - // tic)/CPU_TPS*1000 ); @@ -1724,7 +1728,7 @@ void engine_init_particles(struct engine *e) { /* Make sure all particles are ready to go */ /* i.e. clean-up any stupid state in the ICs */ space_map_cells_pre(s, 1, cell_init_parts, NULL); - + engine_marktasks(e); // printParticle(e->s->parts, 1000, e->s->nr_parts); @@ -1775,7 +1779,7 @@ void engine_init_particles(struct engine *e) { TIMER_TIC; engine_launch(e, e->nr_threads, mask, submask); TIMER_TOC(timer_runners); - + // message("\n0th ENTROPY CONVERSION\n") /* Apply some conversions (e.g. internal energy -> entropy) */ diff --git a/src/gravity/ExternalPotential/gravity_part.h b/src/gravity/ExternalPotential/gravity_part.h index 0bdbc0b09f0f1d1e47b807c538dc092ad080ed38..5d966cade22bb7fd866c91e999fbf99797b909b2 100644 --- a/src/gravity/ExternalPotential/gravity_part.h +++ b/src/gravity/ExternalPotential/gravity_part.h @@ -22,14 +22,14 @@ /* Some standard headers. */ #include <stdlib.h> - +#ifdef DONOTUSEYET /* properties of external potential */ static struct ExternalPointMass { const float Mass; const float Position[3]; } PointMass = {.Mass = 1, .Position={0.,0.,0.}}; - +#endif /* Gravity particle. */ struct gpart { diff --git a/src/hydro.h b/src/hydro.h index 4b131ea7bb65302aaa69503130f7429710dc221f..9986f61e93be5f1c180e0ccaef7b5eb0d1ff99d8 100644 --- a/src/hydro.h +++ b/src/hydro.h @@ -31,6 +31,9 @@ #elif defined(DEFAULT_SPH) #include "./hydro/Default/hydro_iact.h" #include "./hydro/Default/hydro.h" +#elif defined(NO_SPH) +#include "./hydro/Gadget2/hydro_iact.h" +#include "./hydro/Gadget2/hydro.h" #else #error "Invalid choice of SPH variant" #endif diff --git a/src/hydro_io.h b/src/hydro_io.h index 30d663f647c9b763e9b19177e9ba8ef374855768..3ca7b0b06ccaff18e0103e8b96935b35e0ca6fac 100644 --- a/src/hydro_io.h +++ b/src/hydro_io.h @@ -28,6 +28,8 @@ #include "./hydro/Gadget2/hydro_io.h" #elif defined(DEFAULT_SPH) #include "./hydro/Default/hydro_io.h" +#elif defined(NO_SPH) +#include "./hydro/Gadget2/hydro_io.h" #else #error "Invalid choice of SPH variant" #endif diff --git a/src/part.h b/src/part.h index 33ee05fcb87b23a49c3942493fd844ef7dc986c8..16fe48825ae669af147a4bcf6e1f43f697e5c67e 100644 --- a/src/part.h +++ b/src/part.h @@ -44,6 +44,8 @@ #include "./hydro/Gadget2/hydro_part.h" #elif defined(DEFAULT_SPH) #include "./hydro/Default/hydro_part.h" +#elif defined(NO_SPH) +#include "./hydro/Gadget2/hydro_part.h" #else #error "Invalid choice of SPH variant" #endif @@ -53,7 +55,7 @@ #include "./gravity/Default/gravity_part.h" #elif defined(EXTERNAL_POTENTIAL) #include "./gravity/ExternalPotential/gravity_part.h" -#elif +#else #error "Invalid choice of gravity variant" #endif #endif diff --git a/src/single_io.c b/src/single_io.c index 2a03554a4e977118e8fa38a406ea95ebea87b65b..b2a14819773ebdf245af367fb7bece2279753d26 100644 --- a/src/single_io.c +++ b/src/single_io.c @@ -298,7 +298,7 @@ void writeArrayBackEnd(hid_t grp, char* fileName, FILE* xmfFile, char* name, * Calls #error() if an error occurs. * */ -void read_ic_single(char* fileName, double dim[3], struct part** parts, struct gpart** gparts, +void read_ic_single(char* fileName, double dim[3], struct part** parts, struct gpart **gparts, int *Ngas, int *Ndm, int* periodic) { hid_t h_file = 0, h_grp = 0; double boxSize[3] = {0.0, -1.0, -1.0}; diff --git a/src/space.c b/src/space.c index 74d480790f7ebc2e46047a2675cb6977c741b39b..6814b8d9f24aad8b36e44fe4fc8392700960e3a0 100644 --- a/src/space.c +++ b/src/space.c @@ -427,6 +427,8 @@ void space_rebuild(struct space *s, double cell_max, int verbose) { cell_getid(cdim, gp->x[0] * ih[0], gp->x[1] * ih[1], gp->x[2] * ih[2]); cells[ind[k]].gcount++; } + + // message( "getting particle indices took %.3f ms." , (double)(getticks() - // tic) / CPU_TPS * 1000 );