diff --git a/examples/Makefile.am b/examples/Makefile.am index 6abaf5a542e58568d5575bc80eb054fe85d01d30..44d1b22333767f0d4b4282c7c054a70aa7a114be 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -61,3 +61,20 @@ swift_fixdt_mpi_SOURCES = main.c swift_fixdt_mpi_CFLAGS = $(MYFLAGS) $(AM_CFLAGS) $(MPI_FLAGS) -DENGINE_POLICY="engine_policy_fixdt | engine_policy_keep $(ENGINE_POLICY_SETAFFINITY)" swift_fixdt_mpi_LDADD = ../src/.libs/libswiftsim_mpi.a $(HDF5_LDFLAGS) $(HDF5_LIBS) $(MPI_LIBS) +# Scripts to generate ICs +EXTRA_DIST = UniformBox/makeIC.py \ + PerturbedBox/makeIC.py \ + SedovBlast/makeIC.py SedovBlast/makeIC_fcc.py SedovBlast/solution.py \ + SodShock/makeIC.py SodShock/solution.py SodShock/glass_001.hdf5 SodShock/glass_002.hdf5 SodShock/rhox.py \ + CosmoVolume/getIC.sh \ + BigCosmoVolume/makeIC.py \ + BigPerturbedBox/makeIC_fcc.py \ + GreshoVortex/makeIC.py GreshoVortex/solution.py + + +# Scripts to plot task graphs +EXTRA_DIST += plot_tasks_MPI.py plot_tasks.py \ + process_plot_tasks_MPI process_plot_tasks + +# Simple run scripts +EXTRA_DIST += runs.sh diff --git a/examples/PertubedBox/makeIC.py b/examples/PerturbedBox/makeIC.py similarity index 100% rename from examples/PertubedBox/makeIC.py rename to examples/PerturbedBox/makeIC.py diff --git a/src/Makefile.am b/src/Makefile.am index 16551446d96110db9194657575b89a4502217eae..b6d1118493525c0f8078175a0506cd1c07523f8a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -44,7 +44,7 @@ AM_SOURCES = space.c runner.c queue.c task.c cell.c engine.c \ kernel.c tools.c part.c # Include files for distribution, not installation. -noinst_HEADERS = approx_math.h atomic.h cycle.h error.h inline.h kernel.h vector.h \ +nobase_noinst_HEADERS = approx_math.h atomic.h cycle.h error.h inline.h kernel.h vector.h \ runner_doiact.h runner_doiact_grav.h units.h intrinsics.h \ hydro.h hydro_io.h gravity.h \ gravity/Default/gravity.h gravity/Default/runner_iact_grav.h \ diff --git a/src/serial_io.c b/src/serial_io.c index 5402afba096bc62530ef04a5c717c2180d7a7c95..90e814550d2f83526cb1b5f595364e9476d864c5 100644 --- a/src/serial_io.c +++ b/src/serial_io.c @@ -619,9 +619,6 @@ void write_output_serial(struct engine* e, struct UnitSystem* us, int mpi_rank, /* Close file */ H5Fclose(h_file); - - /* Write footer of LXMF file descriptor */ - writeXMFfooter(xmfFile); } /* Now loop over ranks and write the data */ @@ -655,6 +652,9 @@ void write_output_serial(struct engine* e, struct UnitSystem* us, int mpi_rank, MPI_Barrier(comm); } + /* Write footer of LXMF file descriptor */ + if (mpi_rank == 0) writeXMFfooter(xmfFile); + /* message("Done writing particles..."); */ ++outputCount; } diff --git a/tests/Makefile.am b/tests/Makefile.am index 50665f6b742bdebb1bc5ac6553efe3bb472f3220..7dcabd8f3e35963e5fd6331994791dccc2a94c1b 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -38,3 +38,6 @@ testSPHStep_SOURCES = testSPHStep.c testSingle_SOURCES = testSingle.c testVectorize_SOURCES = testVectorize.c + +# Files necessary for distribution +EXTRA_DIST = testReading.sh makeInput.py diff --git a/tests/testReading.c b/tests/testReading.c index 08f8e775ae3cb6f11f2e027d461cb38bd67a4f47..c8123a26acd12692ccd6cd3d893f94e0f95fb856 100644 --- a/tests/testReading.c +++ b/tests/testReading.c @@ -31,9 +31,7 @@ int main() { const double boxSize = 1.; const int L = 4; const double rho = 2.; - const double P = 1.; - const double gamma = 5. / 3.; - + /* Read data */ read_ic_single("input.hdf5", dim, &parts, &N, &periodic); @@ -61,11 +59,6 @@ int main() { float correct_h = 2.251 * boxSize / L; assert(h == correct_h); - /* Check internal energy */ - float u = parts[n].u; - float correct_u = P / ((gamma - 1.) * rho); - assert(u == correct_u); - /* Check velocity */ assert(parts[n].v[0] == 0.); assert(parts[n].v[1] == 0.); @@ -83,9 +76,9 @@ int main() { assert(parts[n].x[2] == correct_z); /* Check accelerations */ - assert(parts[n].a[0] == 0.); - assert(parts[n].a[1] == 0.); - assert(parts[n].a[2] == 0.); + assert(parts[n].a_hydro[0] == 0.); + assert(parts[n].a_hydro[1] == 0.); + assert(parts[n].a_hydro[2] == 0.); } /* Clean-up */ diff --git a/tests/testSPHStep.c b/tests/testSPHStep.c index 0f33c9829bd9763d84bb528bca76c792e2720c86..32e7d62815533fb0ad50e2e85ebd10f452ec8d30 100644 --- a/tests/testSPHStep.c +++ b/tests/testSPHStep.c @@ -73,7 +73,7 @@ struct cell *make_cell(size_t N, float cellSize, int offset[3], int id_offset) { return cell; } - +#ifdef DEFAULT_SPH /* Run a full time step integration for one cell */ int main() { @@ -151,3 +151,12 @@ int main() { return 0; } + +#else + +int main() { + + return 0; +} + +#endif diff --git a/tests/testSingle.c b/tests/testSingle.c index 02c52160d0d442496629f1bb3947f89524964fb8..1bab13959b5d04f23170b761b953de0fa43561b9 100644 --- a/tests/testSingle.c +++ b/tests/testSingle.c @@ -2,20 +2,20 @@ * This file is part of SWIFT. * Copyright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk), * Matthieu Schaller (matthieu.schaller@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. */ @@ -34,7 +34,7 @@ /* Conditional headers. */ #ifdef HAVE_LIBZ - #include <zlib.h> +#include <zlib.h> #endif /* Local headers. */ @@ -42,88 +42,111 @@ /* Ticks per second on this machine. */ #ifndef CPU_TPS - #define CPU_TPS 2.67e9 +#define CPU_TPS 2.67e9 #endif /* Engine policy flags. */ #ifndef ENGINE_POLICY - #define ENGINE_POLICY engine_policy_none +#define ENGINE_POLICY engine_policy_none #endif +#ifdef DEFAULT_SPH /** * @brief Main routine that loads a few particles and generates some output. * */ - -int main ( int argc , char *argv[] ) { - - int k, N = 100; - struct part p1, p2; - float x, w, dwdx, r2, dx[3] = { 0.0f , 0.0f , 0.0f }, gradw[3]; - - /* Greeting message */ - printf( "This is %s\n", package_description() ); - - /* Init the particles. */ - for ( k = 0 ; k < 3 ; k++ ) { - p1.a[k] = 0.0f; p1.v[k] = 0.0f; p1.x[k] = 0.0; - p2.a[k] = 0.0f; p2.v[k] = 0.0f; p2.x[k] = 0.0; - } - p1.v[0] = 100.0f; - p1.id = 0; p2.id = 1; - p1.density.wcount = 48.0f; p2.density.wcount = 48.0f; - p1.rho = 1.0f; p1.mass = 9.7059e-4; p1.h = 0.222871287 / 2; - p2.rho = 1.0f; p2.mass = 9.7059e-4; p2.h = 0.222871287 / 2; - p1.force.c = 0.0040824829f; p1.force.balsara = 0.0f; - p2.force.c = 58.8972740361f; p2.force.balsara = 0.0f; - p1.u = 1.e-5 / ((const_hydro_gamma - 1.)*p1.rho); - p2.u = 1.e-5 / ((const_hydro_gamma - 1.)*p2.rho) + 100.0f / ( 33 * p2.mass ); - p1.force.POrho2 = p1.u * ( const_hydro_gamma - 1.0f ) / p1.rho; - p2.force.POrho2 = p2.u * ( const_hydro_gamma - 1.0f ) / p2.rho; - - /* Dump a header. */ - printParticle_single( &p1 ); - printParticle_single( &p2 ); - printf( "# r a_1 udt_1 a_2 udt_2\n" ); - - /* Loop over the different radii. */ - for ( k = 1 ; k <= N ; k++ ) { - - /* Set the distance/radius. */ - dx[0] = -((float)k)/N * fmaxf( p1.h , p2.h ) * kernel_gamma; - r2 = dx[0]*dx[0]; - - /* Clear the particle fields. */ - p1.a[0] = 0.0f; p1.force.u_dt = 0.0f; - p2.a[0] = 0.0f; p2.force.u_dt = 0.0f; - - /* Interact the particles. */ - runner_iact_force( r2 , dx , p1.h , p2.h , &p1 , &p2 ); - - /* Clear the particle fields. */ - /* p1.rho = 0.0f; p1.density.wcount = 0.0f; - p2.rho = 0.0f; p2.density.wcount = 0.0f; */ - - /* Interact the particles. */ - // runner_iact_density( r2 , dx , p1.h , p2.h , &p1 , &p2 ); - - /* Evaluate just the kernel. */ - x = fabsf( dx[0] ) / p1.h; - kernel_deval( x , &w , &dwdx ); - gradw[0] = dwdx / (p1.h*p1.h*p1.h*p1.h) * dx[0] / sqrtf( dx[0]*dx[0] + dx[1]*dx[1] + dx[2]*dx[2] ); - gradw[1] = dwdx / (p1.h*p1.h*p1.h*p1.h) * dx[1] / sqrtf( dx[0]*dx[0] + dx[1]*dx[1] + dx[2]*dx[2] ); - gradw[2] = dwdx / (p1.h*p1.h*p1.h*p1.h) * dx[2] / sqrtf( dx[0]*dx[0] + dx[1]*dx[1] + dx[2]*dx[2] ); - - /* Output the results. */ - printf( "%.3e %.3e %.3e %.3e %.3e %.3e %.3e %.3e %.3e %.3e\n" , - -dx[0] , p1.a[0] , p1.a[1] , p1.a[2] , p1.force.u_dt , - /// -dx[0] , p1.rho , p1.density.wcount , p2.rho , p2.density.wcount , - w , dwdx , gradw[0] , gradw[1] , gradw[2] ); - - } /* loop over radii. */ - - /* All is calm, all is bright. */ - return 0; - - } + +int main(int argc, char *argv[]) { + + int k, N = 100; + struct part p1, p2; + float x, w, dwdx, r2, dx[3] = {0.0f, 0.0f, 0.0f}, gradw[3]; + + /* Greeting message */ + printf("This is %s\n", package_description()); + + /* Init the particles. */ + for (k = 0; k < 3; k++) { + p1.a_hydro[k] = 0.0f; + p1.v[k] = 0.0f; + p1.x[k] = 0.0; + p2.a_hydro[k] = 0.0f; + p2.v[k] = 0.0f; + p2.x[k] = 0.0; + } + p1.v[0] = 100.0f; + p1.id = 0; + p2.id = 1; + p1.density.wcount = 48.0f; + p2.density.wcount = 48.0f; + p1.rho = 1.0f; + p1.mass = 9.7059e-4; + p1.h = 0.222871287 / 2; + p2.rho = 1.0f; + p2.mass = 9.7059e-4; + p2.h = 0.222871287 / 2; + p1.force.c = 0.0040824829f; + p1.force.balsara = 0.0f; + p2.force.c = 58.8972740361f; + p2.force.balsara = 0.0f; + p1.u = 1.e-5 / ((const_hydro_gamma - 1.) * p1.rho); + p2.u = 1.e-5 / ((const_hydro_gamma - 1.) * p2.rho) + 100.0f / (33 * p2.mass); + p1.force.POrho2 = p1.u * (const_hydro_gamma - 1.0f) / p1.rho; + p2.force.POrho2 = p2.u * (const_hydro_gamma - 1.0f) / p2.rho; + + /* Dump a header. */ + printParticle_single(&p1); + printParticle_single(&p2); + printf("# r a_1 udt_1 a_2 udt_2\n"); + + /* Loop over the different radii. */ + for (k = 1; k <= N; k++) { + + /* Set the distance/radius. */ + dx[0] = -((float)k) / N * fmaxf(p1.h, p2.h) * kernel_gamma; + r2 = dx[0] * dx[0]; + + /* Clear the particle fields. */ + p1.a[0] = 0.0f; + p1.force.u_dt = 0.0f; + p2.a[0] = 0.0f; + p2.force.u_dt = 0.0f; + + /* Interact the particles. */ + runner_iact_force(r2, dx, p1.h, p2.h, &p1, &p2); + + /* Clear the particle fields. */ + /* p1.rho = 0.0f; p1.density.wcount = 0.0f; + p2.rho = 0.0f; p2.density.wcount = 0.0f; */ + + /* Interact the particles. */ + // runner_iact_density( r2 , dx , p1.h , p2.h , &p1 , &p2 ); + + /* Evaluate just the kernel. */ + x = fabsf(dx[0]) / p1.h; + kernel_deval(x, &w, &dwdx); + gradw[0] = dwdx / (p1.h * p1.h * p1.h * p1.h) * dx[0] / + sqrtf(dx[0] * dx[0] + dx[1] * dx[1] + dx[2] * dx[2]); + gradw[1] = dwdx / (p1.h * p1.h * p1.h * p1.h) * dx[1] / + sqrtf(dx[0] * dx[0] + dx[1] * dx[1] + dx[2] * dx[2]); + gradw[2] = dwdx / (p1.h * p1.h * p1.h * p1.h) * dx[2] / + sqrtf(dx[0] * dx[0] + dx[1] * dx[1] + dx[2] * dx[2]); + + /* Output the results. */ + printf( + "%.3e %.3e %.3e %.3e %.3e %.3e %.3e %.3e %.3e %.3e\n", -dx[0], p1.a[0], + p1.a[1], p1.a[2], p1.force.u_dt, + /// -dx[0] , p1.rho , p1.density.wcount , p2.rho , p2.density.wcount , + w, dwdx, gradw[0], gradw[1], gradw[2]); + + } /* loop over radii. */ + + /* All is calm, all is bright. */ + return 0; +} +#else + +int main() { return 0; } + +#endif diff --git a/tests/testTimeIntegration.c b/tests/testTimeIntegration.c index 7b607a7a05ca666e70f650797dd2eb6d1373c54c..4fcd253e877ed167b9534117832675f8f6ac5ef4 100644 --- a/tests/testTimeIntegration.c +++ b/tests/testTimeIntegration.c @@ -112,8 +112,8 @@ int main() { float r2 = c.parts[0].x[0] * c.parts[0].x[0] + c.parts[0].x[1] * c.parts[0].x[1]; float r = sqrtf(r2); - c.parts[0].a[0] = -(G * M_sun * c.parts[0].x[0] / r * r * r); - c.parts[0].a[1] = -(G * M_sun * c.parts[0].x[1] / r * r * r); + c.parts[0].a_hydro[0] = -(G * M_sun * c.parts[0].x[0] / r * r * r); + c.parts[0].a_hydro[1] = -(G * M_sun * c.parts[0].x[1] / r * r * r); /* Kick... */ runner_dokick(&run, &c, 0); diff --git a/tests/testVectorize.c b/tests/testVectorize.c index d86961e350ca13c0612f4e5d8196e30e15122ad9..1c77e9d54effe34fd2c24e97678d905890b291ba 100644 --- a/tests/testVectorize.c +++ b/tests/testVectorize.c @@ -31,10 +31,11 @@ struct cell *make_cell(size_t n, double *offset, double h, part->v[0] = 1.0f; part->v[1] = 1.0f; part->v[2] = 1.0f; - part->dt = 0.01; part->h = h; part->id = ++(*partId); part->mass = 1.0f; + part->t_begin = 0.f; + part->t_end = 0.1f; ++part; } } @@ -68,12 +69,7 @@ void zero_particle_fields(struct cell *c) { for (size_t pid = 0; pid < c->count; pid++) { c->parts[pid].rho = 0.f; c->parts[pid].rho_dh = 0.f; - c->parts[pid].density.wcount = 0.f; - c->parts[pid].density.wcount_dh = 0.f; - c->parts[pid].density.div_v = 0.f; - c->parts[pid].density.curl_v[0] = 0.f; - c->parts[pid].density.curl_v[1] = 0.f; - c->parts[pid].density.curl_v[2] = 0.f; + hydro_init_part(&c->parts[pid]); } } @@ -91,8 +87,8 @@ void dump_particle_fields(char *fileName, struct cell *ci, struct cell *cj) { fprintf(file, "%6llu %f %f %f %f %f %f %f %f\n", ci->parts[pid].id, ci->parts[pid].rho, ci->parts[pid].rho_dh, ci->parts[pid].density.wcount, ci->parts[pid].density.wcount_dh, - ci->parts[pid].density.div_v, ci->parts[pid].density.curl_v[0], - ci->parts[pid].density.curl_v[1], ci->parts[pid].density.curl_v[2]); + ci->parts[pid].div_v, ci->parts[pid].density.rot_v[0], + ci->parts[pid].density.rot_v[1], ci->parts[pid].density.rot_v[2]); } fprintf(file, "# -----------------------------------\n"); @@ -101,8 +97,8 @@ void dump_particle_fields(char *fileName, struct cell *ci, struct cell *cj) { fprintf(file, "%6llu %f %f %f %f %f %f %f %f\n", cj->parts[pjd].id, cj->parts[pjd].rho, cj->parts[pjd].rho_dh, cj->parts[pjd].density.wcount, cj->parts[pjd].density.wcount_dh, - cj->parts[pjd].density.div_v, cj->parts[pjd].density.curl_v[0], - cj->parts[pjd].density.curl_v[1], cj->parts[pjd].density.curl_v[2]); + cj->parts[pjd].div_v, cj->parts[pjd].density.rot_v[0], + cj->parts[pjd].density.rot_v[1], cj->parts[pjd].density.rot_v[2]); } fclose(file); @@ -164,7 +160,7 @@ int main(int argc, char *argv[]) { } engine.s = &space; - engine.dt_step = 0.1; + engine.time = 0.1f; runner.e = &engine; time = 0;