17 const std::vector<RigidBody3D>& bodies,
20#ifdef NUMERICS_HAS_OMP
21 const float h = params.
h;
22 const float alpha = params.
alpha_T;
23 const float m = params.
mass;
24 const float h_conv = params.
h_conv;
25 const float supp_sq = 4.0f * h * h;
26 const float eps2 = 0.01f * h * h;
27 const int n =
static_cast<int>(particles.size());
29# pragma omp parallel for schedule(static)
30 for (
int i = 0; i < n; ++i) {
34 grid.
query(pi.x, pi.y, pi.z, [&](
int j) {
37 const float rx = pi.x - pj.
x, ry = pi.y - pj.
y, rz = pi.z - pj.
z;
38 const float r2 = rx*rx + ry*ry + rz*rz;
39 if (r2 >= supp_sq || r2 < 1e-10f)
return;
40 const float r = std::sqrt(r2);
42 dT += 2.0f * alpha * (m / pj.
density)
44 * rij_dot_gradW / (r2 + eps2);
48 const float dx = pi.x - body.x, dy = pi.y - body.y, dz = pi.z - body.z;
49 const float d = std::sqrt(dx*dx + dy*dy + dz*dz);
50 if (d < body.radius + 2.0f * h) {
51 const float excess = std::max(0.0f, d - body.radius);
52 const float phi = 1.0f - excess / (2.0f * h);
53 dT += h_conv * (body.temperature - pi.temperature) * phi;
3D SPH particle – AoS layout
3D rigid spherical body that interacts with SPH particles