Commit eaa5ae5a authored by Peter W. Draper's avatar Peter W. Draper
Browse files

Merge branch 'master' into autotools-update

parents 5410de20 3c4fd37b
......@@ -3,3 +3,8 @@ Matthieu Schaller matthieu.schaller@durham.ac.uk
Aidan Chalk aidan.chalk@durham.ac.uk
Peter W. Draper p.w.draper@durham.ac.uk
Bert Vandenbrouck bert.vandenbroucke@gmail.com
James S. Willis james.s.willis@durham.ac.uk
John A. Regan john.a.regan@durham.ac.uk
Angus Lepper angus.lepper@ed.ac.uk
Tom Theuns tom.theuns@durham.ac.uk
Richard G. Bower r.g.bower@durham.ac.uk
......@@ -75,26 +75,33 @@ SWIFT depends on a number of third party libraries that should be available
before you can build it.
HDF5: a HDF5 library is required to read and write particle data. One of the
commands "h5cc" or "h5pcc" should be available. If "h5pcc" is located them a
parallel HDF5 built for the version of MPI located should be provided. If
the command is not available then it can be located using the "--with-hfd5"
configure option. The value should be the full path to the "h5cc" or "h5pcc"
commands.
HDF5: a HDF5 library (v. 1.8.x or higher) is required to read and write
particle data. One of the commands "h5cc" or "h5pcc" should be
available. If "h5pcc" is located them a parallel HDF5 built for the version
of MPI located should be provided. If the command is not available then it
can be located using the "--with-hfd5" configure option. The value should
be the full path to the "h5cc" or "h5pcc" commands.
MPI: an optional MPI library that fully supports MPI_THREAD_MULTIPLE.
MPI: an optional MPI library that fully supports MPI_THREAD_MULTIPLE.
Before running configure the "mpirun" command should be available in the
shell. If your command isn't called "mpirun" then define the "MPIRUN"
environment variable, either in the shell or when running configure.
METIS: a build of the METIS library can be optionally used to optimize the
load between MPI nodes (requires an MPI library). This should be found in the
standard installation directories, or pointed at using the "--with-metis"
configuration option. In this case the top-level installation directory of
the METIS build should be given. Note to use METIS you should at least supply
"--with-metis".
load between MPI nodes (requires an MPI library). This should be found in
the standard installation directories, or pointed at using the
"--with-metis" configuration option. In this case the top-level
installation directory of the METIS build should be given. Note to use
METIS you should at least supply "--with-metis".
DOXYGEN: the doxygen library is required to create the SWIFT API documentation.
libNUMA: a build of the NUMA library can be used to pin the threads to
the physical core of the machine SWIFT is running on. This is not always
necessary as the OS scheduler may do a good job at distributing the threads
among the different cores on each computing node.
DOXYGEN: the doxygen library is required to create the SWIFT API
documentation.
......@@ -15,7 +15,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Init the project.
AC_INIT([SWIFT],[0.1.0])
AC_INIT([SWIFT],[0.2.0])
AC_CONFIG_SRCDIR([src/space.c])
AC_CONFIG_AUX_DIR([.])
AM_INIT_AUTOMAKE
......@@ -270,11 +270,13 @@ AC_CHECK_FUNC(pthread_setaffinity_np, AC_DEFINE([HAVE_SETAFFINITY],[true],
AM_CONDITIONAL(HAVESETAFFINITY,
[test "$ac_cv_func_pthread_setaffinity_np" = "yes"])
have_numa="no"
if test "$ac_cv_func_pthread_setaffinity_np" = "yes"; then
# Check for libnuma.
AC_CHECK_HEADER([numa.h])
if test "$ac_cv_header_numa_h" = "yes"; then
AC_CHECK_LIB([numa], [numa_available])
have_numa="yes"
fi
fi
......@@ -335,14 +337,15 @@ AC_CONFIG_FILES([Makefile src/Makefile examples/Makefile doc/Makefile doc/Doxyfi
# Report general configuration.
AC_MSG_RESULT([
Compiler: $CC
vendor: $ax_cv_c_compiler_vendor
version: $ax_cv_c_compiler_version
flags: $CFLAGS
MPI enabled: $enable_mpi
HDF5 enabled: $with_hdf5
parallel: $have_parallel_hdf5
Metis enabled: $with_metis
Compiler : $CC
- vendor : $ax_cv_c_compiler_vendor
- version : $ax_cv_c_compiler_version
- flags : $CFLAGS
MPI enabled : $enable_mpi
HDF5 enabled : $with_hdf5
- parallel : $have_parallel_hdf5
Metis enabled : $with_metis
libNUMA enabled : $have_numa
])
# Generate output.
......
###############################################################################
# This file is part of SWIFT.
# Copyright (c) 2016 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/>.
#
##############################################################################
import h5py
import sys
from numpy import *
# Generates a swift IC file containing a cartesian distribution of particles
# at a constant density and pressure in a cubic box
# Parameters
periodic= 1 # 1 For periodic box
boxSize = 1.
L = int(sys.argv[1]) # Number of particles along one axis
N = int(sys.argv[2]) # Write N particles at a time to avoid requiring a lot of RAM
rho = 2. # Density
P = 1. # Pressure
gamma = 5./3. # Gas adiabatic index
fileName = "uniformBox_%d.hdf5"%L
#---------------------------------------------------
numPart = L**3
mass = boxSize**3 * rho / numPart
internalEnergy = P / ((gamma - 1.)*rho)
#---------------------------------------------------
n_iterations = numPart / N
remainder = numPart % N
print "Writing", numPart, "in", n_iterations, "iterations of size", N, "and a remainder of", remainder
#---------------------------------------------------
#File
file = h5py.File(fileName, 'w')
# Header
grp = file.create_group("/Header")
grp.attrs["BoxSize"] = boxSize
grp.attrs["NumPart_Total"] = [numPart % (long(1)<<32), 0, 0, 0, 0, 0]
grp.attrs["NumPart_Total_HighWord"] = [numPart / (long(1)<<32), 0, 0, 0, 0, 0]
grp.attrs["NumPart_ThisFile"] = [numPart, 0, 0, 0, 0, 0]
grp.attrs["Time"] = 0.0
grp.attrs["NumFilesPerSnapshot"] = 1
grp.attrs["MassTable"] = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
grp.attrs["Flag_Entropy_ICs"] = 0
#Runtime parameters
grp = file.create_group("/RuntimePars")
grp.attrs["PeriodicBoundariesOn"] = periodic
#Particle group
grp = file.create_group("/PartType0")
# First create the arrays in the file
ds_v = grp.create_dataset('Velocities', (numPart, 3), 'f', chunks=True, compression="gzip")
ds_m = grp.create_dataset('Masses', (numPart,1), 'f', chunks=True, compression="gzip")
ds_h = grp.create_dataset('SmoothingLength', (numPart,1), 'f', chunks=True, compression="gzip")
ds_u = grp.create_dataset('InternalEnergy', (numPart,1), 'f', chunks=True, compression="gzip")
ds_id = grp.create_dataset('ParticleIDs', (numPart, 1), 'L', chunks=True, compression="gzip")
ds_x = grp.create_dataset('Coordinates', (numPart, 3), 'd', chunks=True, compression="gzip")
# Now loop and create parts of the dataset
offset = 0
for n in range(n_iterations):
v = zeros((N, 3))
ds_v[offset:offset+N,:] = v
v = zeros(1)
m = full((N, 1), mass)
ds_m[offset:offset+N] = m
m = zeros(1)
h = full((N, 1), 1.1255 * boxSize / L)
ds_h[offset:offset+N] = h
h = zeros(1)
u = full((N, 1), internalEnergy)
ds_u[offset:offset+N] = u
u = zeros(1)
ids = linspace(offset, offset+N, N, endpoint=False).reshape((N,1))
ds_id[offset:offset+N] = ids
x = ids % L;
y = ((ids - x) / L) % L;
z = (ids - x - L * y) / L**2;
ids = zeros(1)
coords = zeros((N, 3))
coords[:,0] = z[:,0] * boxSize / L + boxSize / (2*L)
coords[:,1] = y[:,0] * boxSize / L + boxSize / (2*L)
coords[:,2] = x[:,0] * boxSize / L + boxSize / (2*L)
ds_x[offset:offset+N,:] = coords
coords = zeros((1,3))
offset += N
print "Done", offset,"/", numPart, "(%.1f %%)"%(100*(float)(offset)/numPart)
# And now, the remainder
v = zeros((remainder, 3))
ds_v[offset:offset+remainder,:] = v
v = zeros(1)
m = full((remainder, 1), mass)
ds_m[offset:offset+remainder] = m
m = zeros(1)
h = full((remainder, 1), 1.1255 * boxSize / L)
ds_h[offset:offset+remainder] = h
h = zeros(1)
u = full((remainder, 1), internalEnergy)
ds_u[offset:offset+remainder] = u
u = zeros(1)
print "Done", offset+remainder,"/", numPart
ids = linspace(offset, offset+remainder, remainder, endpoint=False).reshape((remainder,1))
ds_id[offset:offset+remainder] = ids
x = ids % L;
y = ((ids - x) / L) % L;
z = (ids - x - L * y) / L**2;
coords = zeros((remainder, 3))
coords[:,0] = z[:,0] * boxSize / L + boxSize / (2*L)
coords[:,1] = y[:,0] * boxSize / L + boxSize / (2*L)
coords[:,2] = x[:,0] * boxSize / L + boxSize / (2*L)
ds_x[offset:offset+remainder,:] = coords
file.close()
......@@ -46,15 +46,20 @@ AM_SOURCES = space.c runner.c queue.c task.c cell.c engine.c \
# Include files for distribution, not installation.
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 minmax.h \
hydro.h hydro_io.h gravity.h \
gravity.h \
gravity/Default/gravity.h gravity/Default/runner_iact_grav.h \
gravity/Default/gravity_part.h \
hydro.h hydro_io.h \
hydro/Minimal/hydro.h hydro/Minimal/hydro_iact.h hydro/Minimal/hydro_io.h \
hydro/Minimal/hydro_debug.h hydro/Minimal/hydro_part.h \
hydro/Default/hydro.h hydro/Default/hydro_iact.h hydro/Default/hydro_io.h \
hydro/Default/hydro_debug.h hydro/Default/hydro_part.h \
hydro/Gadget2/hydro.h hydro/Gadget2/hydro_iact.h hydro/Gadget2/hydro_io.h \
hydro/Gadget2/hydro_debug.h hydro/Gadget2/hydro_part.h
hydro/Gadget2/hydro_debug.h hydro/Gadget2/hydro_part.h \
hydro/Gizmo/hydro.h hydro/Gizmo/hydro_iact.h hydro/Gizmo/hydro_io.h \
hydro/Gizmo/hydro_debug.h hydro/Gizmo/hydro_part.h \
riemann.h \
riemann/riemann_hllc.h riemann/riemann_trrs.h riemann/riemann_exact.h
# Sources and flags for regular library
libswiftsim_la_SOURCES = $(AM_SOURCES)
......
This diff is collapsed.
/*******************************************************************************
* This file is part of SWIFT.
* Coypright (c) 2016 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/>.
*
******************************************************************************/
__attribute__((always_inline))
INLINE static void hydro_debug_particle(struct part* p, struct xpart* xp) {
printf(
"x=[%.16e,%.16e,%.16e], "
"v=[%.3e,%.3e,%.3e], a=[%.3e,%.3e,%.3e], volume=%.3e\n",
p->x[0], p->x[1], p->x[2], p->v[0], p->v[1], p->v[2], p->a_hydro[0],
p->a_hydro[1], p->a_hydro[2], p->geometry.volume);
}
This diff is collapsed.
/*******************************************************************************
* This file is part of SWIFT.
* Coypright (c) 2016 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/>.
*
******************************************************************************/
/**
* @brief Reads the different particles to the HDF5 file
*
* @param h_grp The HDF5 group in which to read the arrays.
* @param N The number of particles on that MPI rank.
* @param N_total The total number of particles (only used in MPI mode)
* @param offset The offset of the particles for this MPI rank (only used in MPI
*mode)
* @param parts The particle array
*
*/
__attribute__((always_inline)) INLINE static void hydro_read_particles(
hid_t h_grp, int N, long long N_total, long long offset,
struct part* parts) {
/* Read arrays */
readArray(h_grp, "Coordinates", DOUBLE, N, 3, parts, N_total, offset, x,
COMPULSORY);
readArray(h_grp, "Velocities", FLOAT, N, 3, parts, N_total, offset, v,
COMPULSORY);
readArray(h_grp, "Masses", FLOAT, N, 1, parts, N_total, offset,
conserved.mass, 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,
primitives.P, COMPULSORY);
readArray(h_grp, "ParticleIDs", ULONGLONG, N, 1, parts, N_total, offset, id,
COMPULSORY);
readArray(h_grp, "Acceleration", FLOAT, N, 3, parts, N_total, offset, a_hydro,
OPTIONAL);
readArray(h_grp, "Density", FLOAT, N, 1, parts, N_total, offset,
primitives.rho, OPTIONAL);
}
/**
* @brief Writes the different particles to the HDF5 file
*
* @param h_grp The HDF5 group in which to write the arrays.
* @param fileName The name of the file (unsued in MPI mode).
* @param xmfFile The XMF file to write to (unused in MPI mode).
* @param N The number of particles on that MPI rank.
* @param N_total The total number of particles (only used in MPI mode)
* @param mpi_rank The MPI rank of this node (only used in MPI mode)
* @param offset The offset of the particles for this MPI rank (only used in MPI
*mode)
* @param parts The particle array
* @param us The unit system to use
*
*/
__attribute__((always_inline)) INLINE static void hydro_write_particles(
hid_t h_grp, char* fileName, FILE* xmfFile, int N, long long N_total,
int mpi_rank, long long offset, struct part* parts, struct UnitSystem* us) {
/* Write arrays */
writeArray(h_grp, fileName, xmfFile, "Coordinates", DOUBLE, N, 3, parts,
N_total, mpi_rank, offset, x, us, UNIT_CONV_LENGTH);
writeArray(h_grp, fileName, xmfFile, "Velocities", FLOAT, N, 3, parts,
N_total, mpi_rank, offset, v, us, UNIT_CONV_SPEED);
writeArray(h_grp, fileName, xmfFile, "Masses", FLOAT, N, 1, parts, N_total,
mpi_rank, offset, conserved.mass, us, UNIT_CONV_MASS);
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, primitives.P, us,
UNIT_CONV_ENTROPY_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, "Acceleration", FLOAT, N, 3, parts,
N_total, mpi_rank, offset, a_hydro, us, UNIT_CONV_ACCELERATION);
writeArray(h_grp, fileName, xmfFile, "Density", FLOAT, N, 1, parts, N_total,
mpi_rank, offset, primitives.rho, us, UNIT_CONV_DENSITY);
}
/**
* @brief Writes the current model of SPH to the file
* @param h_grpsph The HDF5 group in which to write
*/
void writeSPHflavour(hid_t h_grpsph) {
/* Kernel function description */
writeAttribute_s(h_grpsph, "Kernel", kernel_name);
writeAttribute_f(h_grpsph, "Kernel eta", const_eta_kernel);
writeAttribute_f(h_grpsph, "Weighted N_ngb", kernel_nwneigh);
writeAttribute_f(h_grpsph, "Delta N_ngb", const_delta_nwneigh);
writeAttribute_f(h_grpsph, "Hydro gamma", const_hydro_gamma);
/* Viscosity and thermal conduction */
writeAttribute_s(h_grpsph, "Thermal Conductivity Model",
"(No treatment) Legacy Gadget-2 as in Springel (2005)");
writeAttribute_s(h_grpsph, "Viscosity Model",
"Legacy Gadget-2 as in Springel (2005)");
writeAttribute_f(h_grpsph, "Viscosity alpha", const_viscosity_alpha);
writeAttribute_f(h_grpsph, "Viscosity beta", 3.f);
/* Time integration properties */
writeAttribute_f(h_grpsph, "CFL parameter", const_cfl);
writeAttribute_f(h_grpsph, "Maximal ln(Delta h) change over dt",
const_ln_max_h_change);
writeAttribute_f(h_grpsph, "Maximal Delta h change over dt",
exp(const_ln_max_h_change));
}
/*******************************************************************************
* This file is part of SWIFT.
* Coypright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
* Matthieu Schaller (matthieu.schaller@durham.ac.uk)
* Bert Vandenbroucke (bert.vandenbroucke@ugent.be)
*
* 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/>.
*
******************************************************************************/
/* Some standard headers. */
#include <stdlib.h>
#define GFLOAT float
/* Extra particle data not needed during the computation. */
struct xpart {
/* Old position, at last tree rebuild. */
double x_old[3];
/* Velocity at the last full step. */
float v_full[3];
/* Entropy at the half-step. */
float u_hdt;
/* Old density. */
float omega;
} __attribute__((aligned(xpart_align)));
/* Data of a single particle. */
struct part {
/* Particle position. */
double x[3];
/* Particle velocity. */
float v[3];
/* Particle acceleration. */
float a_hydro[3];
float mass; // MATTHIEU
float h_dt;
float rho;
float rho_dh;
/* Particle cutoff radius. */
float h;
/* Particle time of beginning of time-step. */
int ti_begin;
/* Particle time of end of time-step. */
int ti_end;
/* The primitive hydrodynamical variables */
struct {
/* fluid velocity */
GFLOAT v[3];
/* density */
GFLOAT rho;
/* pressure */
GFLOAT P;
struct {
GFLOAT rho[3];
GFLOAT v[3][3];
GFLOAT P[3];
} gradients;
struct {
/* extreme values among the neighbours */
GFLOAT rho[2];
GFLOAT v[3][2];
GFLOAT P[2];
/* maximal distance to all neighbouring faces */
float maxr;
} limiter;
} primitives;
/* The conserved hydrodynamical variables */
struct {
/* fluid momentum */
GFLOAT momentum[3];
/* fluid mass */
GFLOAT mass;
/* fluid energy */
GFLOAT energy;
} conserved;
/* Geometrical quantities used for hydro */
struct {
/* volume of the particle */
float volume;
/* gradient matrix */
float matrix_E[3][3];
} geometry;
struct {
float vmax;
} timestepvars;
/* Quantities used during the density loop */
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;
/* Particle ID. */
unsigned long long id;
/* Associated gravitas. */
struct gpart *gpart;
} __attribute__((aligned(part_align)));
/*******************************************************************************
* This file is part of SWIFT.
* Coypright (c) 2015 Bert Vandenbroucke (bert.vandenbroucke@ugent.be)
*
* 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