34 return 10.0f / (7.0f * 3.14159265f * h * h);
40 return 1.0f / (3.14159265f * h * h * h);
50 const float H = 2.0f * h;
53 const float h5 = h * h * h * h * h;
54 const float d = H - r;
55 return (-15.0f / (16.0f * 3.14159265f * h5)) * d * d;
62 const float H = 2.0f * h;
63 if (r >= H || r < 1e-10f)
65 const float H6 = H * H * H * H * H * H;
66 const float d = H - r;
67 return -45.0f / (3.14159265f * H6) * d * d;
76 static_assert(Dim == 2 || Dim == 3,
"SPHKernel: Dim must be 2 or 3");
79 static float W(
float r,
float h) {
81 const float q = r / h;
83 return sigma * (1.0f - 1.5f * q * q + 0.75f * q * q * q);
85 const float t = 2.0f - q;
86 return sigma * 0.25f * t * t * t;
93 static float dW_dr(
float r,
float h) {
95 const float q = r / h;
97 return (sigma / h) * (-3.0f * q + 2.25f * q * q);
99 const float t = 2.0f - q;
100 return (sigma / h) * (-0.75f * t * t);
112 static std::array<float, Dim>
Spiky_gradW(std::array<float, Dim> r_vec,
115 std::array<float, Dim> g{};
116 if (r < 1e-10f || r >= 2.0f * h)
119 for (
int d = 0; d < Dim; ++d)
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)