31 return 10.0f / (7.0f * 3.14159265f * h * h);
36 return 1.0f / (3.14159265f * h * h * h);
44 const float H = 2.0f * h;
45 if (
r >= H)
return 0.0f;
46 const float h5 = h * h * h * h * h;
47 const float d = H -
r;
48 return (-15.0f / (16.0f * 3.14159265f *
h5)) *
d *
d;
54 const float H = 2.0f * h;
55 if (
r >= H ||
r < 1e-10f)
return 0.0f;
56 const float H6 = H * H * H * H * H * H;
57 const float d = H -
r;
58 return -45.0f / (3.14159265f *
H6) *
d *
d;
67 static_assert(
Dim == 2 ||
Dim == 3,
"SPHKernel: Dim must be 2 or 3");
70 static float W(
float r,
float h) {
72 const float q =
r / h;
74 return sigma * (1.0f - 1.5f * q * q + 0.75f * q * q * q);
76 const float t = 2.0f - q;
77 return sigma * 0.25f * t * t * t;
84 static float dW_dr(
float r,
float h) {
86 const float q =
r / h;
87 if (q <= 1.0f)
return (
sigma / h) * (-3.0f * q + 2.25f * q * q);
89 const float t = 2.0f - q;
90 return (
sigma / h) * (-0.75f * t * t);
104 std::array<float, Dim>
g{};
constexpr T ipow(T x) noexcept
Compute x^N at compile time via repeated squaring.
Dimension-generic SPH smoothing kernels. Dim = 2 or 3.
static std::array< float, Dim > Spiky_gradW(std::array< float, Dim > r_vec, float r, float h)
static float dW_dr(float r, float h)
static float Spiky_dW_dr(float r, float h)
Radial derivative dW/dr of spiky kernel (<= 0, non-zero at r=0).
static float W(float r, float h)
2D/3D cubic spline density kernel. Support = 2h.
static float compute(float h)
static float compute(float h)
static float compute(float r, float h)
static float compute(float r, float h)