Skip to content

Commit

Permalink
RePrimAnd Version 1.3
Browse files Browse the repository at this point in the history
-Added experimental Einstein Toolkit thorn for building ReprimAnd library
-Fixed minor bug affecting some EOS sanity checks
  • Loading branch information
Wolfgang Kastaun committed Jul 25, 2021
1 parent dac853e commit 2e168cf
Show file tree
Hide file tree
Showing 15 changed files with 243 additions and 10 deletions.
22 changes: 22 additions & 0 deletions ET_interface/thorns/RePrimAnd/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Cactus Code Thorn RePrimAnd
Author(s) : Wolfgang Kastaun
Maintainer(s): Wolfgang Kastaun
Licence : GPL
--------------------------------------------------------------------------

1. Purpose

Distribute the RePrimAnd Library; see
<https://github.com/wokast/RePrimAnd>.


The RePrimAnd library is a support library for general relativistic
magnetohydrodynamics, providing:
An extensible, modular EOS framework (thermal + barotropic)
An algorithm for primitive variable recovery in ideal GRMHD

A link to the library documentation can be found at
https://github.com/wokast/RePrimAnd

The article describing the algorithm is
https://doi.org/10.1103/PhysRevD.103.023018
11 changes: 11 additions & 0 deletions ET_interface/thorns/RePrimAnd/configuration.ccl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Configuration definitions for thorn RePrimAnd

PROVIDES RePrimAnd
{
SCRIPT src/detect.sh
LANG bash
OPTIONS REPRIMAND_DIR REPRIMAND_INSTALL_DIR REPRIMAND_LIBS
}

# Pass configuration options to build script
REQUIRES GSL BOOST HDF5 RePrimAnd
Binary file not shown.
3 changes: 3 additions & 0 deletions ET_interface/thorns/RePrimAnd/interface.ccl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Interface definition for thorn RePrimAnd

IMPLEMENTS: RePrimAnd
1 change: 1 addition & 0 deletions ET_interface/thorns/RePrimAnd/param.ccl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Parameter definitions for thorn RePrimAnd
1 change: 1 addition & 0 deletions ET_interface/thorns/RePrimAnd/schedule.ccl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Schedule definitions for thorn RePrimAnd
62 changes: 62 additions & 0 deletions ET_interface/thorns/RePrimAnd/src/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#! /bin/bash

################################################################################
# Build
################################################################################

# Set up shell
if [ "$(echo ${VERBOSE} | tr '[:upper:]' '[:lower:]')" = 'yes' ]; then
set -x # Output commands
fi
set -e # Abort on errors



# Set locations
THORN=RePrimAnd
NAME=RePrimAnd-1.3
SRCDIR="$(dirname $0)"
BUILD_DIR=${SCRATCH_BUILD}/build/${THORN}
if [ -z "${REPRIMAND_INSTALL_DIR}" ]; then
INSTALL_DIR=${SCRATCH_BUILD}/external/${THORN}
else
echo "BEGIN MESSAGE"
echo "Installing REPRIMAND into ${REPRIMAND_INSTALL_DIR} "
echo "END MESSAGE"
INSTALL_DIR=${REPRIMAND_INSTALL_DIR}
fi
DONE_FILE=${SCRATCH_BUILD}/done/${THORN}
REPRIMAND_DIR=${INSTALL_DIR}

# Set up environment
#unset LIBS
#if echo '' ${ARFLAGS} | grep 64 > /dev/null 2>&1; then
# export OBJECT_MODE=64
#fi

echo "REPRIMAND: Preparing directory structure..."
cd ${SCRATCH_BUILD}
mkdir build external done 2> /dev/null || true
rm -rf ${BUILD_DIR} ${INSTALL_DIR}
mkdir ${BUILD_DIR} ${INSTALL_DIR}

echo "REPRIMAND: Unpacking archive..."
pushd ${BUILD_DIR}
${TAR?} xJf ${SRCDIR}/../dist/${NAME}.tar.xz

echo "REPRIMAND: Configuring..."
cd ${NAME}
meson setup mesonbuild --prefix=${REPRIMAND_DIR} --default-library=static --buildtype=debugoptimized -Dbuild_documentation=false -Dbuild_benchmarks=false -Dbuild_tests=false

echo "REPRIMAND: Building..."
ninja -C mesonbuild

echo "REPRIMAND: Installing..."
meson install -C mesonbuild
popd

echo "REPRIMAND: Cleaning up..."
rm -rf ${BUILD_DIR}

date > ${DONE_FILE}
echo "REPRIMAND: Done."
85 changes: 85 additions & 0 deletions ET_interface/thorns/RePrimAnd/src/detect.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#! /bin/bash

################################################################################
# Prepare
################################################################################

# Set up shell
if [ "$(echo ${VERBOSE} | tr '[:upper:]' '[:lower:]')" = 'yes' ]; then
set -x # Output commands
fi
set -e # Abort on errors

. $CCTK_HOME/lib/make/bash_utils.sh

# Take care of requests to build the library in any case
REPRIMAND_DIR_INPUT=$REPRIMAND_DIR
if [ "$(echo "${REPRIMAND_DIR}" | tr '[a-z]' '[A-Z]')" = 'BUILD' ]; then
REPRIMAND_BUILD=yes
REPRIMAND_DIR=
else
REPRIMAND_BUILD=
fi


THORN=RePrimAnd

################################################################################
# Build
################################################################################

if [ -n "$REPRIMAND_BUILD" -o -z "${REPRIMAND_DIR}" ]; then
echo "BEGIN MESSAGE"
echo "Using bundled REPRIMAND..."
echo "END MESSAGE"

check_tools "tar"

# Set locations
BUILD_DIR=${SCRATCH_BUILD}/build/${THORN}
if [ -z "${REPRIMAND_INSTALL_DIR}" ]; then
INSTALL_DIR=${SCRATCH_BUILD}/external/${THORN}
else
echo "BEGIN MESSAGE"
echo "Installing REPRIMAND into ${REPRIMAND_INSTALL_DIR} "
echo "END MESSAGE"
INSTALL_DIR=${REPRIMAND_INSTALL_DIR}
fi
REPRIMAND_BUILD=1
REPRIMAND_DIR=${INSTALL_DIR}
REPRIMAND_INC_DIRS="$REPRIMAND_DIR/include"
REPRIMAND_LIB_DIRS="$REPRIMAND_DIR/lib"
REPRIMAND_LIBS="RePrimAnd"
else
REPRIMAND_BUILD=
DONE_FILE=${SCRATCH_BUILD}/done/${THORN}
if [ ! -e ${DONE_FILE} ]; then
mkdir ${SCRATCH_BUILD}/done 2> /dev/null || true
date > ${DONE_FILE}
fi
fi

################################################################################
# Configure Cactus
################################################################################

# Pass configuration options to build script
echo "BEGIN MAKE_DEFINITION"
echo "REPRIMAND_BUILD = ${REPRIMAND_BUILD}"
echo "REPRIMAND_INSTALL_DIR = ${REPRIMAND_INSTALL_DIR}"
echo "END MAKE_DEFINITION"


set_make_vars "REPRIMAND" "$REPRIMAND_LIBS" "$REPRIMAND_LIB_DIRS" "$REPRIMAND_INC_DIRS"

# Pass options to Cactus
echo "BEGIN MAKE_DEFINITION"
echo "REPRIMAND_DIR = ${REPRIMAND_DIR}"
echo "REPRIMAND_INC_DIRS = ${REPRIMAND_INC_DIRS}"
echo "REPRIMAND_LIB_DIRS = ${REPRIMAND_LIB_DIRS}"
echo "REPRIMAND_LIBS = ${REPRIMAND_LIBS}"
echo "END MAKE_DEFINITION"

echo 'INCLUDE_DIRECTORY $(REPRIMAND_INC_DIRS)'
echo 'LIBRARY_DIRECTORY $(REPRIMAND_LIB_DIRS)'
echo 'LIBRARY $(REPRIMAND_LIBS)'
7 changes: 7 additions & 0 deletions ET_interface/thorns/RePrimAnd/src/make.code.defn
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Main make.code.defn file for thorn REPRIMAND

# Source files in this directory
SRCS =

# Subdirectories containing source files
SUBDIRS =
10 changes: 10 additions & 0 deletions ET_interface/thorns/RePrimAnd/src/make.code.deps
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Main make.code.deps file for thorn RePrimAnd

export REPRIMAND_INSTALL_DIR

$(CCTK_TARGET) $(OBJS) $(SRCS:%=%.d): $(SCRATCH_BUILD)/done/$(THORN)

ifneq ($(REPRIMAND_BUILD),)
$(SCRATCH_BUILD)/done/$(THORN): $(SRCDIR)/build.sh
+$(SRCDIR)/build.sh
endif
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,19 @@ together with the library. The Python extension module is called
`pyreprimand`.


## Einstein Toolkit Support

RePrimAnd does provide an (experimental) thorn that builds the library within
an EinsteinToolkit (ET) environment, using the ExternalLibraries mechanism. The
thorn can be found in the folder `ET_interface/thorns/RePrimAnd/`. The thorn
depends on the HDF5, GSL, and BOOST ExternalLibraries thorns. In addition,
the meson build system needs to be installed on the build host.

Currently there is are no thorns that provide an ET-style interface for using
this library, although this might change in future versions. ET Thorns can of
course use the library like any other C++ library.


## Creating Documentation

To just build the documentation, use the target `documentation`.
Expand Down
18 changes: 12 additions & 6 deletions docsrc/sphinx/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,20 @@ and velocity from the variables evolved in quasi-conservative
formulations. Further, it provides a general framework for handling
matter equations of state.

This version of the library was made public together with the article
describing the recovery scheme:
A description of the algorithm and tests of the library is given in
the accompanying article:

Wolfgang Kastaun, Jay Vijay Kalinani, Riccardo Ciolfi,
"Robust Recovery of Primitive Variables in Relativistic Ideal
Magnetohydrodynamics",
`arXiv:2005.01821 [gr-qc] <https://arxiv.org/abs/2005.01821>`_
(2020).
`Phys. Rev. D 103, 023018 (2021) <https://doi.org/10.1103/PhysRevD.103.023018>`_
`(arXiv:2005.01821) <https://arxiv.org/abs/2005.01821>`_.

Prospective users should be sure to check for updated versions
that will likely be made available in a public repository.
The latest public versions can be found on the
`github page <https://github.com/wokast/RePrimAnd>`_.

Releases are also archived on Zenodo and can be cited via the
`DOI <https://doi.org/10.5281/zenodo.3785074>`_.

Developers
^^^^^^^^^^
Expand All @@ -41,6 +43,10 @@ License

<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png" /></a><br />This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>.

Please cite the
`PRD article <https://doi.org/10.1103/PhysRevD.103.023018>`_
and the `DOI on Zenodo <https://doi.org/10.5281/zenodo.3785074>`_
when publishing results obtained using the library.

Contents
--------
Expand Down
16 changes: 14 additions & 2 deletions docsrc/sphinx/installing.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Installation
============

The main target and devolpment platform is Linux, although the
The main target and development platform is Linux, although the
library code is not platform-specific and should also work on Macs.
Windows and AIX are not supported.

Expand Down Expand Up @@ -38,7 +38,7 @@ To build the library,
ninja
This will compile with optimization and without debug symbols. Other
possibilities are `--buildtype=debug` and `--buildtype=debugoptimized`
possibilities are `--buildtype=debug` and `--buildtype=debugoptimized`.
To use a different compiler, e.g. clang, prefix the meson command
with `CC=clang CXX=clang++`.
See `here <https://mesonbuild.com/Running-Meson.html>`_ for general
Expand Down Expand Up @@ -97,6 +97,18 @@ If the Python bindings have been build, they are automatically installed
together with the library. The Python extension module is called
`pyreprimand`.

Einstein Toolkit Support
------------------------
RePrimAnd does provide an (experimental) thorn that builds the library within
an EinsteinToolkit (ET) environment, using the ExternalLibraries mechanism. The
thorn can be found in the folder `ET_interface/thorns/RePrimAnd/`. The thorn
depends on the HDF5, GSL, and BOOST ExternalLibraries thorns. In addition,
the meson build system needs to be installed on the build host.

Currently there are no thorns that provide an ET-style interface for using
this library, although this might change in future versions. ET Thorns can of
course use the library like any other C++ library.


Creating Documentation
----------------------
Expand Down
2 changes: 1 addition & 1 deletion library/BasicStuff/interpol.cc
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ detail::cspline_mono_impl::cspline_mono_impl(
std::vector<double> x_, std::vector<double> y_)
: x{std::move(x_)}, y{std::move(y_)}, interp{x,y}
{
auto ext = std::minmax_element(x.begin(), x.end());
auto ext = std::minmax_element(y.begin(), y.end());
rgy = {*ext.first, *ext.second};
rgx = {x.front(), x.back()};
}
Expand Down
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

project('RePrimAnd', ['cpp','c'], default_options : ['cpp_std=c++11'],
version : '1.2', license : 'CC BY-NC-SA 4.0')
version : '1.3', license : 'CC BY-NC-SA 4.0')

project_headers_dest = 'reprimand'

Expand Down

0 comments on commit 2e168cf

Please sign in to comment.