11#ifndef CUBBYFLOW_CUDA_SPH_KERNELS3_IMPL_HPP
12#define CUBBYFLOW_CUDA_SPH_KERNELS3_IMPL_HPP
14#ifdef CUBBYFLOW_USE_CUDA
21inline CUDASPHStdKernel3::CUDASPHStdKernel3() : h(0), h2(0), h3(0), h5(0)
26inline CUDASPHStdKernel3::CUDASPHStdKernel3(
float kernelRadius)
27 : h(kernelRadius), h2(h * h), h3(h2 * h), h5(h2 * h3)
32inline float CUDASPHStdKernel3::operator()(
float distance)
const
34 if (distance * distance >= h2)
39 const float x = 1.0f - distance * distance / h2;
40 return 315.0f / (64.0f *
PI_FLOAT * h3) * x * x * x;
43inline float CUDASPHStdKernel3::FirstDerivative(
float distance)
const
50 const float x = 1.0f - distance * distance / h2;
51 return -945.0f / (32.0f *
PI_FLOAT * h5) * distance * x * x;
54inline float CUDASPHStdKernel3::SecondDerivative(
float distance)
const
56 if (distance * distance >= h2)
61 const float x = distance * distance / h2;
62 return 945.0f / (32.0f *
PI_FLOAT * h5) * (1 - x) * (3 * x - 1);
65inline float4 CUDASPHStdKernel3::Gradient(
const float4& point)
const
67 float dist = Length(point);
71 return Gradient(dist, point / dist);
74 return make_float4(0, 0, 0, 0);
77inline float4 CUDASPHStdKernel3::Gradient(
float distance,
78 const float4& directionToCenter)
const
80 return -FirstDerivative(distance) * directionToCenter;
83inline CUDASPHSpikyKernel3::CUDASPHSpikyKernel3()
84 : h(0), h2(0), h3(0), h4(0), h5(0)
89inline CUDASPHSpikyKernel3::CUDASPHSpikyKernel3(
float kernelRadius)
90 : h(kernelRadius), h2(h * h), h3(h2 * h), h4(h2 * h2), h5(h3 * h2)
95inline float CUDASPHSpikyKernel3::operator()(
float distance)
const
102 const float x = 1.0f - distance / h;
103 return 15.0f / (
PI_FLOAT * h3) * x * x * x;
106inline float CUDASPHSpikyKernel3::FirstDerivative(
float distance)
const
113 const float x = 1.0f - distance / h;
114 return -45.0f / (
PI_FLOAT * h4) * x * x;
117inline float CUDASPHSpikyKernel3::SecondDerivative(
float distance)
const
124 const float x = 1.0f - distance / h;
128inline float4 CUDASPHSpikyKernel3::Gradient(
const float4& point)
const
130 float dist = Length(point);
134 return Gradient(dist, point / dist);
137 return make_float4(0, 0, 0, 0);
140inline float4 CUDASPHSpikyKernel3::Gradient(
141 float distance,
const float4& directionToCenter)
const
143 return -FirstDerivative(distance) * directionToCenter;
Definition pybind11Utils.hpp:21
constexpr float PI_FLOAT
Float-type PI.
Definition Constants.hpp:75