Skip to content
Snippets Groups Projects
Commit aa103b56 authored by Josh Borrow's avatar Josh Borrow
Browse files

Minor refactoring changes to GIZMO-MFM to allow use with the new hydro function configuration.

parent 99efec73
No related branches found
No related tags found
1 merge request!561Change gradient loops
......@@ -421,8 +421,7 @@ __attribute__((always_inline)) INLINE static void hydro_part_has_no_neighbours(
/**
* @brief Prepare a particle for the gradient calculation.
*
* The name of this method is confusing, as this method is really called after
* the density loop and before the gradient loop.
* This function is called after the density loop and before the gradient loop.
*
* We use it to set the physical timestep for the particle and to copy the
* actual velocities, which we need to boost our interfaces during the flux
......@@ -433,7 +432,7 @@ __attribute__((always_inline)) INLINE static void hydro_part_has_no_neighbours(
* @param xp The extended particle data to act upon.
* @param cosmo The cosmological model.
*/
__attribute__((always_inline)) INLINE static void hydro_prepare_force(
__attribute__((always_inline)) INLINE static void hydro_prepare_gradient(
struct part* restrict p, struct xpart* restrict xp,
const struct cosmology* cosmo) {
......@@ -446,6 +445,18 @@ __attribute__((always_inline)) INLINE static void hydro_prepare_force(
hydro_velocities_prepare_force(p, xp);
}
/**
* @brief Resets the variables that are required for a gradient calculation.
*
* This function is called after hydro_prepare_gradient.
*
* @param p The particle to act upon.
* @param xp The extended particle data to act upon.
* @param cosmo The cosmological model.
*/
__attribute__((always_inline)) INLINE static void hydro_reset_gradient(
struct part *restrict p) {}
/**
* @brief Finishes the gradient calculation.
*
......@@ -461,6 +472,28 @@ __attribute__((always_inline)) INLINE static void hydro_end_gradient(
hydro_gradients_finalize(p);
#ifdef GIZMO_LLOYD_ITERATION
/* reset the gradients to zero, as we don't want them */
hydro_gradients_init(p);
#endif
}
/**
* @brief Prepare a particle for the force calculation.
*
* This function is called in the extra_ghost task to convert some quantities coming
* from the gradient loop over neighbours into quantities ready to be used in the
* force loop over neighbours.
*
* @param p The particle to act upon
* @param xp The extended particle data to act upon
* @param cosmo The current cosmological model.
*/
__attribute__((always_inline)) INLINE static void hydro_prepare_force(
struct part* restrict p, struct xpart* restrict xp,
const struct cosmology* cosmo) {
/* Initialise values that are used in the force loop */
p->gravity.mflux[0] = 0.0f;
p->gravity.mflux[1] = 0.0f;
p->gravity.mflux[2] = 0.0f;
......@@ -470,11 +503,6 @@ __attribute__((always_inline)) INLINE static void hydro_end_gradient(
p->conserved.flux.momentum[1] = 0.0f;
p->conserved.flux.momentum[2] = 0.0f;
p->conserved.flux.energy = 0.0f;
#ifdef GIZMO_LLOYD_ITERATION
/* reset the gradients to zero, as we don't want them */
hydro_gradients_init(p);
#endif
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment