Skip to content

Commit

Permalink
Initial high level changes from moving_mesh
Browse files Browse the repository at this point in the history
  • Loading branch information
Yolan Uyttenhove authored and MatthieuSchaller committed Oct 8, 2024
1 parent 6bd852e commit 29c23b8
Show file tree
Hide file tree
Showing 60 changed files with 2,266 additions and 7,418 deletions.
75 changes: 70 additions & 5 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -818,6 +818,42 @@ AC_SUBST([GSL_LIBS])
AC_SUBST([GSL_INCS])
AM_CONDITIONAL([HAVEGSL],[test -n "$GSL_LIBS"])

# Check for GMP. We test for this in the standard directories by default,
# and only disable if using --with-gmp=no or --without-gmp. When a value
# is given GMP must be found.
have_gmp="no"
AC_ARG_WITH([gmp],
[AS_HELP_STRING([--with-gmp=PATH],
[root directory where GMP is installed @<:@yes/no@:>@]
)],
[with_gmp="$withval"],
[with_gmp="test"]
)
if test "x$with_gmp" != "xno"; then
if test "x$with_gmp" != "xyes" -a "x$with_gmp" != "xtest" -a "x$with_gmp" != "x"; then
GMP_LIBS="-L$with_gmp/lib -lgmp"
else
GMP_LIBS="-lgmp"
fi
# GMP is not specified, so just check if we have it.
if test "x$with_gmp" = "xtest"; then
AC_CHECK_LIB([gmp],[__gmpz_inits],[have_gmp="yes"],[have_gmp="no"],$GMP_LIBS)
if test "x$have_gmp" != "xno"; then
AC_DEFINE([HAVE_LIBGMP],1,[The GMP library appears to be present.])
fi
else
AC_CHECK_LIB([gmp],[__gmpz_inits],
AC_DEFINE([HAVE_LIBGMP],1,[The GMP library appears to be present.]),
AC_MSG_ERROR(something is wrong with the GMP library!), $GMP_LIBS)
have_gmp="yes"
fi
if test "$have_gmp" = "no"; then
GMP_LIBS=""
fi
fi
AC_SUBST([GMP_LIBS])
AM_CONDITIONAL([HAVEGMP],[test -n "$GMP_LIBS"])

# Check for pthreads.
AX_PTHREAD([LIBS="$PTHREAD_LIBS $LIBS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
CC="$PTHREAD_CC" LDFLAGS="$LDFLAGS $PTHREAD_LIBS $LIBS"],
Expand Down Expand Up @@ -2109,7 +2145,7 @@ fi
# Hydro scheme.
AC_ARG_WITH([hydro],
[AS_HELP_STRING([--with-hydro=<scheme>],
[Hydro dynamics to use @<:@gadget2, minimal, pressure-entropy, pressure-energy, pressure-energy-monaghan, phantom, gizmo-mfv, gizmo-mfm, shadowfax, planetary, sphenix, gasoline, anarchy-pu default: sphenix@:>@]
[Hydro dynamics to use @<:@gadget2, minimal, pressure-entropy, pressure-energy, pressure-energy-monaghan, phantom, gizmo-mfv, gizmo-mfm, shadowswift, planetary, sphenix, gasoline, anarchy-pu default: sphenix@:>@]
)],
[with_hydro="$withval"],
[with_hydro="sphenix"]
Expand Down Expand Up @@ -2146,9 +2182,12 @@ case "$with_hydro" in
AC_DEFINE([GIZMO_MFM_SPH], [1], [GIZMO MFM SPH])
need_riemann_solver=yes
;;
shadowfax)
AC_DEFINE([SHADOWFAX_SPH], [1], [Shadowfax SPH])
shadowswift)
AC_DEFINE([SHADOWSWIFT], [1], [ShadowSWIFT hydrodynamics])
AC_DEFINE([MOVING_MESH_HYDRO], [1], [Moving mesh hydrodynamics])
need_moving_mesh=yes
need_riemann_solver=yes
hydro_does_mass_flux=yes
;;
planetary)
AC_DEFINE([PLANETARY_SPH], [1], [Planetary SPH])
Expand Down Expand Up @@ -2195,8 +2234,8 @@ fi
if test "$with_hydro" = "gizmo-mfv" -a "$with_spmhd" != "none"; then
AC_MSG_ERROR([Cannot use an SPMHD scheme alongside a gizmo hydro solver!"])
fi
if test "$with_hydro" = "shadowfax" -a "$with_spmhd" != "none"; then
AC_MSG_ERROR([Cannot use an SPMHD scheme alongside a gizmo hydro solver!"])
if test "$with_hydro" = "shadowswift" -a "$with_spmhd" != "none"; then
AC_MSG_ERROR([Cannot use an SPMHD scheme alongside a moving mesh hydro solver!"])
fi

# Check if debugging interactions stars is switched on.
Expand Down Expand Up @@ -2425,6 +2464,27 @@ if test "x$need_riemann_solver" = "xyes" -a "$with_riemann" = "none"; then
AC_MSG_ERROR([Hydro scheme $with_hydro requires selection of a Riemann solver!])
fi

# Moving mesh
AC_ARG_ENABLE([moving-mesh],
[AS_HELP_STRING([--enable-moving-mesh],
[enable the moving mesh computation]
)],
[enable_moving_mesh="${enableval}"],
[enable_moving_mesh="no"]
)
if test "x$need_moving_mesh" = "xyes"; then
enable_moving_mesh="yes"
fi
if test "$enable_moving_mesh" = "yes"; then
if test "$have_gmp" = "no"; then
AC_MSG_ERROR([GMP is required when using moving mesh!])
fi
if test "$have_gsl" = "no"; then
AC_MSG_ERROR([GSL is required when using moving mesh!])
fi
AC_DEFINE([MOVING_MESH], [1], [Unstructured Voronoi mesh])
fi

# Hydro does mass flux?
if test "x$hydro_does_mass_flux" = "xyes"; then
AC_DEFINE([HYDRO_DOES_MASS_FLUX], [1], [Hydro scheme with mass fluxes])
Expand Down Expand Up @@ -3155,6 +3215,9 @@ AM_CONDITIONAL([HAVESPHM1RTRT], [test "${with_rt:0:7}" = "SPHM1RT"])
# Check if using GEAR-RT radiative transfer
AM_CONDITIONAL([HAVEGEARRT], [test "${with_rt:0:4}" = "GEAR"])

# Check if using Moving mesh
AM_CONDITIONAL([HAVE_MOVING_MESH], [test "$enable_moving_mesh" = "yes"])




Expand Down Expand Up @@ -3212,6 +3275,7 @@ AC_MSG_RESULT([
- MPI : $have_mpi_fftw
- ARM : $have_arm_fftw
GSL enabled : $have_gsl
GMP enabled : $have_gmp
HEALPix C enabled : $have_chealpix
libNUMA enabled : $have_numa
GRACKLE enabled : $have_grackle
Expand All @@ -3222,6 +3286,7 @@ AC_MSG_RESULT([
VELOCIraptor enabled : $have_velociraptor
FoF activated: : $enable_fof
Lightcones enabled : $enable_lightcone
Moving-mesh enabled : $enable_moving_mesh
Hydro scheme : $with_hydro
Dimensionality : $with_dimension
Expand Down
1 change: 1 addition & 0 deletions doc/RTD/source/HydroSchemes/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,6 @@ In case the case of a 2 loop scheme, SWIFT removes the gradient loop and the ext
phantom_sph
adaptive_softening
gizmo
shadowswift
adding_your_own

48 changes: 48 additions & 0 deletions doc/RTD/source/HydroSchemes/shadowswift.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
.. ShadowSWIFT (Moving mesh hydrodynamics)
Yolan Uyttenhove September 2023
ShadowSWIFT (moving mesh hydrodynamics)
=======================================

.. warning::
The moving mesh hydrodynamics solver is currently in the process of being merged into master and will **NOT**
work on the master branch. To use it, compile the code using the ``moving_mesh`` branch.

This is an implementation of the moving-mesh finite-volume method for hydrodynamics in SWIFT.
To use this scheme, a Riemann solver is also needed. Configure SWIFT as follows:

.. code-block:: bash
./configure --with-hydro="shadowswift" --with-riemann-solver="hllc"
Current status
~~~~~~~~~~~~~~

Due to the completely different task structure compared to SPH hydrodynamics, currently only a subset of the features of
SWIFT is supported in this scheme.

- Hydrodynamics is fully supported in 1D, 2D and 3D and over MPI.

- Both self-gravity and external potentials are supported.

- Cosmological time-integration is supported.

- Cooling and chemistry are supported, with the exception of the ``GEAR_diffusion`` chemistry scheme. Metals are
properly according to mass fluxes.

- Choice between periodic, reflective, open, inflow and vacuum boundary conditions (for non-periodic boundary
conditions, the desired variant must be selected in ``const.h``). Additionally, reflective boundary conditions
are applied to SWIFT's boundary particles. Configure with ``--with-boundary-particles=<N>`` to use this (e.g. to
simulate walls).


Caveats
~~~~~~~
These are currently the main limitations of the ShadowSWIFT hydro scheme:

- Unlike SPH the cells of the moving mesh must form a partition of the entire simulation volume. This means that there
cannot be empty SWIFT cells and vacuum must be explicitly represented by zero (or negligible) mass particles.
- Most other subgrid physics, most notably, star formation and stellar feedback are not supported yet.
- No MHD schemes are supported.
- No radiative-transfer schemes are supported.
1 change: 1 addition & 0 deletions examples/parameter_example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ Scheduler:
cell_sub_size_pair_grav: 256000000 # (Optional) Maximal number of interactions per sub-pair gravity task (this is the default value).
cell_sub_size_self_grav: 32000 # (Optional) Maximal number of interactions per sub-self gravity task (this is the default value).
cell_split_size: 400 # (Optional) Maximal number of particles per cell (this is the default value).
grid_split_threshold: 400 # (Optional) Maximal number of particles per cell at construction level of Voronoi grid (this is the default value).
cell_subdepth_diff_grav: 4 # (Optional) Maximal depth difference between leaves and a cell that gravity tasks can be pushed down to (this is the default value).
cell_extra_parts: 0 # (Optional) Number of spare parts per top-level allocated at rebuild time for on-the-fly creation.
cell_extra_gparts: 0 # (Optional) Number of spare gparts per top-level allocated at rebuild time for on-the-fly creation.
Expand Down
Loading

0 comments on commit 29c23b8

Please sign in to comment.