Commit cb998cc5 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Use the new getter definitions also in the grackle cooling model. Put the...

Use the new getter definitions also in the grackle cooling model. Put the grackle library variables in all the relevant makefiles.
parent 1123dd4e
......@@ -19,7 +19,7 @@
MYFLAGS =
# Add the source directory and the non-standard paths to the included library headers to CFLAGS
AM_CFLAGS = -I$(top_srcdir)/src $(HDF5_CPPFLAGS) $(GSL_INCS) $(FFTW_INCS)
AM_CFLAGS = -I$(top_srcdir)/src $(HDF5_CPPFLAGS) $(GSL_INCS) $(FFTW_INCS) $(GRACKLE_INCS)
AM_LDFLAGS = $(HDF5_LDFLAGS)
......
......@@ -16,7 +16,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Add the non-standard paths to the included library headers
AM_CFLAGS = $(HDF5_CPPFLAGS) $(GSL_INCS) $(FFTW_INCS)
AM_CFLAGS = $(HDF5_CPPFLAGS) $(GSL_INCS) $(FFTW_INCS) $(GRACKLE_INCS)
# Assign a "safe" version number
AM_LDFLAGS = $(HDF5_LDFLAGS) $(FFTW_LIBS) -version-info 0:0:0
......@@ -25,7 +25,7 @@ AM_LDFLAGS = $(HDF5_LDFLAGS) $(FFTW_LIBS) -version-info 0:0:0
GIT_CMD = @GIT_CMD@
# Additional dependencies for shared libraries.
EXTRA_LIBS = $(HDF5_LIBS) $(FFTW_LIBS) $(PROFILER_LIBS) $(TCMALLOC_LIBS) $(JEMALLOC_LIBS) $(TBBMALLOC_LIBS) $(GRACKLE_LIB) $(GSL_LIBS)
EXTRA_LIBS = $(HDF5_LIBS) $(FFTW_LIBS) $(PROFILER_LIBS) $(TCMALLOC_LIBS) $(JEMALLOC_LIBS) $(TBBMALLOC_LIBS) $(GRACKLE_LIBS) $(GSL_LIBS)
# MPI libraries.
MPI_LIBS = $(PARMETIS_LIBS) $(METIS_LIBS) $(MPI_THREAD_LIBS)
......
......@@ -31,7 +31,7 @@
#ifdef HAVE_HDF5
/**
* @brief Writes the current model of SPH to the file
* @brief Writes the current model of cooling to the file
* @param h_grp The HDF5 group in which to write
* @param cooling the parameters of the cooling function.
*/
......
......@@ -36,6 +36,7 @@
/* Local includes. */
#include "chemistry.h"
#include "cooling_io.h"
#include "error.h"
#include "hydro.h"
#include "parser.h"
......@@ -491,6 +492,10 @@ __attribute__((always_inline)) INLINE static gr_float cooling_rate(
const struct cooling_function_data* restrict cooling,
const struct part* restrict p, struct xpart* restrict xp, double dt) {
error(
"Check cosmology factors (physical vs. co-moving and drifted vs. "
"un-drifted)!");
/* set current time */
code_units units = cooling->units;
if (cooling->redshift == -1)
......@@ -515,7 +520,8 @@ __attribute__((always_inline)) INLINE static gr_float cooling_rate(
/* general particle data */
gr_float density = hydro_get_physical_density(p, cosmo);
const double energy_before = hydro_get_physical_internal_energy(p, cosmo);
const double energy_before =
hydro_get_drifted_physical_internal_energy(p, cosmo);
gr_float energy = energy_before;
/* initialize density */
......@@ -596,7 +602,8 @@ __attribute__((always_inline)) INLINE static gr_float cooling_time(
data.grid_end = grid_end;
/* general particle data */
const gr_float energy_before = hydro_get_physical_internal_energy(p, cosmo);
const gr_float energy_before =
hydro_get_drifted_physical_internal_energy(p, cosmo);
gr_float density = hydro_get_physical_density(p, cosmo);
gr_float energy = energy_before;
......@@ -641,13 +648,19 @@ __attribute__((always_inline)) INLINE static void cooling_cool_part(
const struct phys_const* restrict phys_const,
const struct unit_system* restrict us,
const struct cosmology* restrict cosmo,
const struct hydro_props* hydro_props,
const struct cooling_function_data* restrict cooling,
struct part* restrict p, struct xpart* restrict xp, double dt) {
struct part* restrict p, struct xpart* restrict xp, double dt,
double dt_therm) {
error(
"Check cosmology factors (physical vs. co-moving and drifted vs. "
"un-drifted)!");
if (dt == 0.) return;
/* Current du_dt */
const float hydro_du_dt = hydro_get_internal_energy_dt(p);
const float hydro_du_dt = hydro_get_physical_internal_energy_dt(p, cosmo);
/* compute cooling rate */
const float du_dt = cooling_rate(phys_const, us, cosmo, cooling, p, xp, dt);
......@@ -656,7 +669,7 @@ __attribute__((always_inline)) INLINE static void cooling_cool_part(
xp->cooling_data.radiated_energy += -du_dt * dt * hydro_get_mass(p);
/* Update the internal energy */
hydro_set_internal_energy_dt(p, hydro_du_dt + du_dt);
hydro_set_physical_internal_energy_dt(p, cosmo, hydro_du_dt + du_dt);
}
/**
......@@ -674,7 +687,9 @@ __attribute__((always_inline)) INLINE static float cooling_timestep(
const struct cooling_function_data* restrict cooling,
const struct phys_const* restrict phys_const,
const struct cosmology* restrict cosmo,
const struct unit_system* restrict us, const struct part* restrict p) {
const struct unit_system* restrict us,
const struct hydro_props* hydro_props, const struct part* restrict p,
const struct xpart* restrict xp) {
return FLT_MAX;
}
......
......@@ -29,20 +29,20 @@
#ifdef HAVE_HDF5
/**
* @brief Writes the current model of SPH to the file
* @param h_grpsph The HDF5 group in which to write
* @brief Writes the current model of cooling to the file
* @param h_grp The HDF5 group in which to write
*/
__attribute__((always_inline)) INLINE static void cooling_write_flavour(
hid_t h_grpsph) {
hid_t h_grp, const struct cooling_function_data* cooling) {
#if COOLING_GRACKLE_MODE == 0
io_write_attribute_s(h_grpsph, "Cooling Model", "Grackle");
io_write_attribute_s(h_grp, "Cooling Model", "Grackle");
#elif COOLING_GRACKLE_MODE == 1
io_write_attribute_s(h_grpsph, "Cooling Model", "Grackle1");
io_write_attribute_s(h_grp, "Cooling Model", "Grackle1");
#elif COOLING_GRACKLE_MODE == 2
io_write_attribute_s(h_grpsph, "Cooling Model", "Grackle2");
io_write_attribute_s(h_grp, "Cooling Model", "Grackle2");
#elif COOLING_GRACKLE_MODE == 3
io_write_attribute_s(h_grpsph, "Cooling Model", "Grackle3");
io_write_attribute_s(h_grp, "Cooling Model", "Grackle3");
#else
error("This function should be called only with one of the Grackle cooling.");
#endif
......
......@@ -16,14 +16,14 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
******************************************************************************/
#ifndef SWIFT_COOLING_STRUCT_NONE_H
#define SWIFT_COOLING_STRUCT_NONE_H
#ifndef SWIFT_COOLING_STRUCT_GRACKLE_H
#define SWIFT_COOLING_STRUCT_GRACKLE_H
#include "../config.h"
/* include grackle */
#include <grackle.h>
#include "../config.h"
/**
* @file src/cooling/none/cooling_struct.h
* @brief Empty infrastructure for the cases without cooling function
......@@ -113,4 +113,4 @@ struct cooling_xpart_data {
float metal_frac;
};
#endif /* SWIFT_COOLING_STRUCT_NONE_H */
#endif /* SWIFT_COOLING_STRUCT_GRACKLE_H */
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment