Skip to content
Snippets Groups Projects
Select Git revision
  • fd3d64a8c86c95d2eec393834f62bc5ed59bf149
  • master default protected
  • reyz/gear_preSN_feedback
  • zoom-mesh-considerations
  • stars_sidm_iact
  • karapiperis/plasma_beta_rms_in_tensile_instability_correction_taper_function
  • darwin/gear_preSN_fbk_merge
  • darwin/gear_mechanical_feedback
  • karapiperis/consistent_treatment_of_vsig_in_MHD
  • FS_VP_m2_allGrad
  • examples-GravityTests-HydroStatic-halo-issue
  • fof_props
  • FS_VP_m2
  • FS_m2
  • darwin/gear_chemistry_fluxes
  • zoom_mpi_redux
  • mladen/rt_limit_star_timesteps
  • zoom-missing-rebuild-time
  • moving_mesh
  • zoom_truncate_bkg
  • sidm_merge protected
  • v2025.10 protected
  • v2025.04 protected
  • v2025.01 protected
  • v1.0.0 protected
  • v0.9.0 protected
  • v0.8.5 protected
  • v0.8.4 protected
  • v0.8.3 protected
  • v0.8.2 protected
  • v0.8.1 protected
  • v0.8.0 protected
  • v0.7.0 protected
  • v0.6.0 protected
  • v0.5.0 protected
  • v0.4.0 protected
  • v0.3.0 protected
  • v0.2.0 protected
  • v0.1.0-pre protected
  • v0.1 protected
  • v0.0 protected
41 results

gravity_derivatives.h

Blame
  • user avatar
    Matthieu Schaller authored
    68ce4a36
    History
    gravity_derivatives.h 2.63 KiB
    /*******************************************************************************
     * This file is part of SWIFT.
     * Copyright (c) 2016 Matthieu Schaller (matthieu.schaller@durham.ac.uk)
     *
     * 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_GRAVITY_DERIVATIVE_H
    #define SWIFT_GRAVITY_DERIVATIVE_H
    
    /* Some standard headers. */
    #include <math.h>
    
    /* Local headers. */
    #include "inline.h"
    
    /**
     * @brief \f$ \phi(r_x, r_y, r_z) \f$.
     */
    __attribute__((always_inline)) INLINE static double D_000(double r_x,
                                                              double r_y,
                                                              double r_z,
                                                              double r_inv) {
    
      return r_inv;
    }
    
    /**
     * @brief \f$ \frac{\partial\phi(r_x, r_y, r_z)}{\partial r_x} \f$.
     */
    __attribute__((always_inline)) INLINE static double D_100(double r_x,
                                                              double r_y,
                                                              double r_z,
                                                              double r_inv) {
    
      return -r_x * r_inv * r_inv * r_inv;
    }
    
    /**
     * @brief \f$ \frac{\partial\phi(r_x, r_y, r_z)}{\partial r_x} \f$.
     */
    __attribute__((always_inline)) INLINE static double D_010(double r_x,
                                                              double r_y,
                                                              double r_z,
                                                              double r_inv) {
    
      return -r_y * r_inv * r_inv * r_inv;
    }
    
    /**
     * @brief \f$ \frac{\partial\phi(r_x, r_y, r_z)}{\partial r_x} \f$.
     */
    __attribute__((always_inline)) INLINE static double D_001(double r_x,
                                                              double r_y,
                                                              double r_z,
                                                              double r_inv) {
    
      return -r_z * r_inv * r_inv * r_inv;
    }
    
    #endif /* SWIFT_GRAVITY_DERIVATIVE_H */