11#ifndef CUBBYFLOW_CUDA_SPH_KERNELS2_IMPL_HPP
12#define CUBBYFLOW_CUDA_SPH_KERNELS2_IMPL_HPP
14#ifdef CUBBYFLOW_USE_CUDA
21inline CUDASPHStdKernel2::CUDASPHStdKernel2() : h(0), h2(0), h3(0), h4(0)
26inline CUDASPHStdKernel2::CUDASPHStdKernel2(
float kernelRadius)
27 : h(kernelRadius), h2(h * h), h3(h2 * h), h4(h2 * h2)
32inline float CUDASPHStdKernel2::operator()(
float distance)
const
34 const float distanceSquared = distance * distance;
36 if (distanceSquared >= h2)
41 const float x = 1.0f - distanceSquared / h2;
42 return 4.0f / (
PI_FLOAT * h2) * x * x * x;
45inline float CUDASPHStdKernel2::FirstDerivative(
float distance)
const
52 const float x = 1.0f - distance * distance / h2;
53 return -24.0f * distance / (
PI_FLOAT * h4) * x * x;
56inline float CUDASPHStdKernel2::SecondDerivative(
float distance)
const
58 float distanceSquared = distance * distance;
60 if (distanceSquared >= h2)
65 const float x = distanceSquared / h2;
66 return 24.0f / (
PI_FLOAT * h4) * (1 - x) * (5 * x - 1);
69inline float2 CUDASPHStdKernel2::Gradient(
const float2& point)
const
71 float dist = Length(point);
75 return Gradient(dist, point / dist);
78 return make_float2(0, 0);
81inline float2 CUDASPHStdKernel2::Gradient(
float distance,
82 const float2& directionToCenter)
const
84 return -FirstDerivative(distance) * directionToCenter;
87inline CUDASPHSpikyKernel2::CUDASPHSpikyKernel2()
88 : h(0), h2(0), h3(0), h4(0), h5(0)
93inline CUDASPHSpikyKernel2::CUDASPHSpikyKernel2(
float kernelRadius)
94 : h(kernelRadius), h2(h * h), h3(h2 * h), h4(h2 * h2), h5(h3 * h2)
99inline float CUDASPHSpikyKernel2::operator()(
float distance)
const
106 const float x = 1.0f - distance / h;
107 return 10.0f / (
PI_FLOAT * h2) * x * x * x;
110inline float CUDASPHSpikyKernel2::FirstDerivative(
float distance)
const
117 const float x = 1.0f - distance / h;
118 return -30.0f / (
PI_FLOAT * h3) * x * x;
121inline float CUDASPHSpikyKernel2::SecondDerivative(
float distance)
const
128 const float x = 1.0f - distance / h;
132inline float2 CUDASPHSpikyKernel2::Gradient(
const float2& point)
const
134 float dist = Length(point);
138 return Gradient(dist, point / dist);
141 return make_float2(0, 0);
144inline float2 CUDASPHSpikyKernel2::Gradient(
145 float distance,
const float2& directionToCenter)
const
147 return -FirstDerivative(distance) * directionToCenter;
Definition pybind11Utils.hpp:21
constexpr float PI_FLOAT
Float-type PI.
Definition Constants.hpp:75