Commit 5ec192f9 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Move the multipole acceptance criterion function to a separate file.

parent c5f50536
......@@ -52,7 +52,7 @@ include_HEADERS = space.h runner.h queue.h task.h lock.h cell.h part.h const.h \
chemistry.h chemistry_io.h chemistry_struct.h cosmology.h restart.h space_getsid.h utilities.h \
mesh_gravity.h cbrt.h exp10.h velociraptor_interface.h swift_velociraptor_part.h outputlist.h \
logger_io.h tracers_io.h tracers.h tracers_struct.h star_formation_io.h fof.h fof_struct.h fof_io.h \
multipole.h multipole_struct.h binomial.h \
multipole.h multipole_accept.h multipole_struct.h binomial.h \
star_formation_struct.h star_formation.h star_formation_iact.h \
star_formation_logger.h star_formation_logger_struct.h \
pressure_floor.h pressure_floor_struct.h pressure_floor_iact.h \
......
......@@ -61,6 +61,7 @@
#include "hydro_properties.h"
#include "memswap.h"
#include "minmax.h"
#include "multipole.h"
#include "pressure_floor.h"
#include "scheduler.h"
#include "space.h"
......
......@@ -75,6 +75,7 @@
#include "memuse.h"
#include "minmax.h"
#include "mpiuse.h"
#include "multipole_struct.h"
#include "outputlist.h"
#include "parallel_io.h"
#include "part.h"
......
......@@ -27,7 +27,7 @@
#include "align.h"
#include "error.h"
#include "gravity.h"
#include "multipole.h"
#include "multipole_accept.h"
#include "vector.h"
/**
......
......@@ -44,14 +44,6 @@
#include "periodic.h"
#include "vector_power.h"
#ifdef WITH_MPI
/* MPI datatypes for transfers */
extern MPI_Datatype multipole_mpi_type;
extern MPI_Op multipole_mpi_reduce_op;
void multipole_create_mpi_types(void);
void multipole_free_mpi_types(void);
#endif
/**
* @brief Reset the data of a #multipole.
*
......@@ -2808,65 +2800,4 @@ __attribute__((nonnull)) INLINE static void gravity_L2P(
#endif
}
/**
* @brief Checks whether a cell-cell interaction can be appromixated by a M-M
* interaction using the distance and cell radius.
*
* We use the multipole acceptance criterion of Dehnen, 2002, JCoPh, Volume 179,
* Issue 1, pp.27-42, equation 10.
*
* We also additionally check that the distance between the multipoles
* is larger than the softening lengths (here the distance at which
* the gravity becomes Newtonian again, not the Plummer-equivalent quantity).
*
* @param r_crit_a The size of the multipole A.
* @param r_crit_b The size of the multipole B.
* @param theta_crit2 The square of the critical opening angle.
* @param r2 Square of the distance (periodically wrapped) between the
* multipoles.
* @param epsilon_a The maximal softening length of any particle in A.
* @param epsilon_b The maximal softening length of any particle in B.
*/
__attribute__((always_inline, const)) INLINE static int gravity_M2L_accept(
const double r_crit_a, const double r_crit_b, const double theta_crit2,
const double r2, const double epsilon_a, const double epsilon_b) {
const double size = r_crit_a + r_crit_b;
const double size2 = size * size;
const double epsilon_a2 = epsilon_a * epsilon_a;
const double epsilon_b2 = epsilon_b * epsilon_b;
// MATTHIEU: Make this mass-dependent ?
/* Multipole acceptance criterion (Dehnen 2002, eq.10) */
return (r2 * theta_crit2 > size2) && (r2 > epsilon_a2) && (r2 > epsilon_b2);
}
/**
* @brief Checks whether a particle-cell interaction can be appromixated by a
* M2P interaction using the distance and cell radius.
*
* We use the multipole acceptance criterion of Dehnen, 2002, JCoPh, Volume 179,
* Issue 1, pp.27-42, equation 10.
*
* We also additionally check that the distance between the particle and the
* multipole is larger than the softening length (here the distance at which
* the gravity becomes Newtonian again, not the Plummer-equivalent quantity).
*
* @param r_max2 The square of the size of the multipole.
* @param theta_crit2 The square of the critical opening angle.
* @param r2 Square of the distance (periodically wrapped) between the
* particle and the multipole.
* @param epsilon The softening length of the particle.
*/
__attribute__((always_inline, const)) INLINE static int gravity_M2P_accept(
const float r_max2, const float theta_crit2, const float r2,
const float epsilon) {
// MATTHIEU: Make this mass-dependent ?
/* Multipole acceptance criterion (Dehnen 2002, eq.10) */
return (r2 * theta_crit2 > r_max2) && (r2 > epsilon * epsilon);
}
#endif /* SWIFT_MULTIPOLE_H */
/*******************************************************************************
* This file is part of SWIFT.
* Copyright (c) 2016 Matthieu Schaller (schaller@strw.leidenuniv.nl)
*
* 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/>.
*
******************************************************************************/
#ifndef SWIFT_MULTIPOLE_ACCEPT_H
#define SWIFT_MULTIPOLE_ACCEPT_H
/* Config parameters. */
#include "../config.h"
/* Local includes */
#include "multipole_struct.h"
/**
* @brief Checks whether a cell-cell interaction can be appromixated by a M-M
* interaction using the distance and cell radius.
*
* We use the multipole acceptance criterion of Dehnen, 2002, JCoPh, Volume 179,
* Issue 1, pp.27-42, equation 10.
*
* We also additionally check that the distance between the multipoles
* is larger than the softening lengths (here the distance at which
* the gravity becomes Newtonian again, not the Plummer-equivalent quantity).
*
* @param r_crit_a The size of the multipole A.
* @param r_crit_b The size of the multipole B.
* @param theta_crit2 The square of the critical opening angle.
* @param r2 Square of the distance (periodically wrapped) between the
* multipoles.
* @param epsilon_a The maximal softening length of any particle in A.
* @param epsilon_b The maximal softening length of any particle in B.
*/
__attribute__((always_inline, const)) INLINE static int gravity_M2L_accept(
const double r_crit_a, const double r_crit_b, const double theta_crit2,
const double r2, const double epsilon_a, const double epsilon_b) {
const double size = r_crit_a + r_crit_b;
const double size2 = size * size;
const double epsilon_a2 = epsilon_a * epsilon_a;
const double epsilon_b2 = epsilon_b * epsilon_b;
// MATTHIEU: Make this mass-dependent ?
/* Multipole acceptance criterion (Dehnen 2002, eq.10) */
return (r2 * theta_crit2 > size2) && (r2 > epsilon_a2) && (r2 > epsilon_b2);
}
/**
* @brief Checks whether a particle-cell interaction can be appromixated by a
* M2P interaction using the distance and cell radius.
*
* We use the multipole acceptance criterion of Dehnen, 2002, JCoPh, Volume 179,
* Issue 1, pp.27-42, equation 10.
*
* We also additionally check that the distance between the particle and the
* multipole is larger than the softening length (here the distance at which
* the gravity becomes Newtonian again, not the Plummer-equivalent quantity).
*
* @param r_max2 The square of the size of the multipole.
* @param theta_crit2 The square of the critical opening angle.
* @param r2 Square of the distance (periodically wrapped) between the
* particle and the multipole.
* @param epsilon The softening length of the particle.
*/
__attribute__((always_inline, const)) INLINE static int gravity_M2P_accept(
const float r_max2, const float theta_crit2, const float r2,
const float epsilon) {
// MATTHIEU: Make this mass-dependent ?
/* Multipole acceptance criterion (Dehnen 2002, eq.10) */
return (r2 * theta_crit2 > r_max2) && (r2 > epsilon * epsilon);
}
#endif /* SWIFT_MULTIPOLE_ACCEPT_H */
......@@ -230,4 +230,13 @@ struct reduced_grav_tensor {
float F_001;
};
#ifdef WITH_MPI
/* MPI datatypes for transfers */
extern MPI_Datatype multipole_mpi_type;
extern MPI_Op multipole_mpi_reduce_op;
void multipole_create_mpi_types(void);
void multipole_free_mpi_types(void);
#endif
#endif /* SWIFT_MULTIPOLE_STRUCT_H */
......@@ -32,6 +32,7 @@
#include "engine.h"
#include "feedback.h"
#include "kick.h"
#include "multipole.h"
#include "timers.h"
#include "timestep.h"
#include "timestep_limiter.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