18 template <
typename TKernel>
23 template <
typename T,
typename =
void>
43 template <
typename TKernel>
45 : close(
std::forward<TKernel>(source)) {
46 using T = std::decay_t<TKernel>;
48 "Use GravityKernel to get gravity smoothing kernel associated to SPH kernel");
57 const Float hInv = 1._f / h;
71 const Float hInv = 1._f / h;
94 return 2._f / 3._f * qSqr - 3._f / 10._f *
pow<4>(q) + 1._f / 10._f *
pow<5>(q) - 7._f / 5._f;
96 return 4._f / 3._f * qSqr -
pow<3>(q) + 3._f / 10._f *
pow<2>(qSqr) - 1._f / 30._f *
pow<5>(q) -
97 8._f / 5._f + 1._f / (15._f * q);
106 }
else if (q < 1._f) {
107 return 1._f / q * (4._f / 3._f * q - 6._f / 5._f *
pow<3>(q) + 1._f / 2._f *
pow<2>(qSqr));
110 (8._f / 3._f * q - 3._f * qSqr + 6._f / 5._f *
pow<3>(q) - 1._f / 6._f *
pow<2>(qSqr) -
111 1._f / (15._f * qSqr));
140 template <
typename TKernel,
145 Float integral = 0._f;
148 for (
Size i = 1; i < resolution; ++i) {
151 psi[i] = 4._f *
PI /
sqr(q2) * integral;
164 : gradients(range, std::move(psi))
167 values = gradients.
integral(r, -1._f / r);
171 return values(
sqrt(qSqr));
178 return gradients(q) / q;
186 const Float grad0 = 4._f / 3._f *
PI * W.valueImpl(0._f);
190 template <
typename T,
typename>
192 static constexpr
bool value =
false;
195 template <
typename T>
200 template <
typename T>
201 struct IsGravityKernel<T,
std::enable_if_t<std::is_base_of<GravityKernelTag, std::decay_t<T>>::value>> {
INLINE bool isReal(const AntisymmetricTensor &t)
#define SPH_ASSERT(x,...)
NAMESPACE_SPH_BEGIN INLINE Float integrate(const Interval range, const TFunctor &functor)
Integrates a one-dimensional function using Simpson's rule.
uint32_t Size
Integral type used to index arrays (by default).
double Float
Precision used withing the code. Use Float instead of float or double where precision is important.
auto getAssociatedGravityKernel(const TKernel &W, const Size resolution=40000)
Computes the gravitational softening kernel from the associated SPH kernel by integrating the Poisson...
Approximation of generic function by look-up table.
constexpr INLINE Float pow< 5 >(const Float v)
constexpr INLINE T sqr(const T &f) noexcept
Return a squared value.
INLINE T sqrt(const T f)
Return a squared root of a value.
constexpr INLINE Float pow< 3 >(const Float v)
constexpr INLINE Float pow< 4 >(const Float v)
constexpr INLINE Float pow< 2 >(const Float v)
constexpr Float PI
Mathematical constants.
#define INLINE
Macros for conditional compilation based on selected compiler.
#define NAMESPACE_SPH_END
Few non-standard type traits.
INLINE Float getLength(const Vector &v)
Returns the length of the vector. Enabled only for vectors of floating-point precision.
INLINE Float getSqrLength(const Vector &v)
Cubic spline (M4) kernel.
INLINE Float gradImpl(const Float qSqr) const
INLINE Float radius() const
INLINE Float valueImpl(const Float qSqr) const
Gravity smoothing kernels associated with standard SPH kernels.
Gravitational kernel approximated by LUT for close particles.
GravityLutKernel(TKernel &&source)
INLINE Vector grad(const Vector &r, const Float h) const
GravityLutKernel()=default
INLINE Float value(const Vector &r, const Float h) const
INLINE Float radius() const
Object representing a 1D interval of real numbers.
INLINE Float upper() const
Returns upper bound of the interval.
Base class for all SPH kernels.
INLINE Float valueImpl(const Float qSqr) const noexcept
INLINE Float radius() const noexcept
INLINE Float gradImpl(const Float qSqr) const noexcept
Interval getRange() const
Returns the definition interval of the function.
Lut integral(const Float x0, const Float y0) const
Computes the indefinite integral of the function.
Gravity kernel of a solid sphere.
SolidSphereKernel()=default
INLINE Float gradImpl(const Float UNUSED(qSqr)) const
INLINE Float valueImpl(const Float UNUSED(qSqr)) const
INLINE Float radius() const
Kernel introduced by Thomas & Couchman (1992).
Overload of std::swap for Sph::Array.
static constexpr bool value