Skip to content
Snippets Groups Projects
Commit 68f11cb4 authored by Peter W. Draper's avatar Peter W. Draper
Browse files

Merge branch 'missing_files' into 'master'

Missing files and other small bugs

A bit of a mix:

- Added files to the Makefile.am such that 'make dist' works (issue #100)
- Unit tests now compile (issue #99)
- Fixed XMF i/o crash (issue #101)



See merge request !93
parents a0ad2365 cb68944b
Branches
Tags
1 merge request!136Master
......@@ -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
File moved
......@@ -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 \
......
......@@ -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;
}
......
......@@ -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
......@@ -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 */
......
......@@ -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
......@@ -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
......@@ -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);
......
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment