11 #ifndef CUBBYFLOW_CUDA_SPH_KERNELS3_IMPL_HPP 12 #define CUBBYFLOW_CUDA_SPH_KERNELS3_IMPL_HPP 14 #ifdef CUBBYFLOW_USE_CUDA 21 inline CUDASPHStdKernel3::CUDASPHStdKernel3() : h(0), h2(0), h3(0), h5(0)
26 inline CUDASPHStdKernel3::CUDASPHStdKernel3(
float kernelRadius)
27 : h(kernelRadius), h2(h * h), h3(h2 * h), h5(h2 * h3)
32 inline 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;
43 inline 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;
54 inline 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);
65 inline 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);
77 inline float4 CUDASPHStdKernel3::Gradient(
float distance,
78 const float4& directionToCenter)
const 80 return -FirstDerivative(distance) * directionToCenter;
83 inline CUDASPHSpikyKernel3::CUDASPHSpikyKernel3()
84 : h(0), h2(0), h3(0), h4(0), h5(0)
89 inline CUDASPHSpikyKernel3::CUDASPHSpikyKernel3(
float kernelRadius)
90 : h(kernelRadius), h2(h * h), h3(h2 * h), h4(h2 * h2), h5(h3 * h2)
95 inline float CUDASPHSpikyKernel3::operator()(
float distance)
const 102 const float x = 1.0f - distance / h;
103 return 15.0f / (
PI_FLOAT * h3) * x * x * x;
106 inline float CUDASPHSpikyKernel3::FirstDerivative(
float distance)
const 113 const float x = 1.0f - distance / h;
114 return -45.0f / (
PI_FLOAT * h4) * x * x;
117 inline float CUDASPHSpikyKernel3::SecondDerivative(
float distance)
const 124 const float x = 1.0f - distance / h;
128 inline 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);
140 inline float4 CUDASPHSpikyKernel3::Gradient(
141 float distance,
const float4& directionToCenter)
const 143 return -FirstDerivative(distance) * directionToCenter;
Definition: pybind11Utils.hpp:20
constexpr float PI_FLOAT
Float-type PI.
Definition: Constants.hpp:75
size_t Length() const
Definition: ArrayBase-Impl.hpp:84