36 const Kokkos::View<Real*, peclet::core::MemSpace>& pos,
37 const Kokkos::View<Real*, peclet::core::MemSpace>& weight, Real L,
const Sdf& sdf,
38 const Kokkos::View<Real*, peclet::core::MemSpace>& force,
39 const Kokkos::View<Real*, peclet::core::MemSpace>& forceW) {
42 const Real Lh = Real(0.5) * L;
43 Real fSelf[3] = {Real(0), Real(0), Real(0)};
44 Real fwSelf = Real(0);
45 double gw[3] = {0.0, 0.0, 0.0};
46 Real sx = Real(0), sy = Real(0), sz = Real(0);
47 if constexpr (Policy::kHasWeightDof) {
52 for (
int k = 0; k < nf; ++k) {
53 const Real g[3] = {gl[3 * k], gl[3 * k + 1], gl[3 * k + 2]};
54 if (g[0] == Real(0) && g[1] == Real(0) && g[2] == Real(0))
65 Real r[3] = {Real(0), Real(0), Real(0)}, rho = Real(0), cc = Real(0);
66 if constexpr (Policy::kHasWeightDof) {
67 const Real s[3] = {sx, sy, sz};
68 for (
int d = 0; d < 3; ++d) {
69 Real rr = pos(3 * j + d) - s[d];
70 rr = rr > Lh ? rr - L : (rr < -Lh ? rr + L : rr);
73 rho = r[0] * r[0] + r[1] * r[1] + r[2] * r[2];
74 cc = weight(i) - weight(j);
76 Real fs[3], fn[3], fws = Real(0), fwn = Real(0);
77 Policy::template chain<Real>(g, r, rho, cc, fs, fn, fws, fwn);
82 Kokkos::atomic_add(&force(3 * j), fn[0]);
83 Kokkos::atomic_add(&force(3 * j + 1), fn[1]);
84 Kokkos::atomic_add(&force(3 * j + 2), fn[2]);
85 if constexpr (Policy::kHasWeightDof)
86 if (forceW.extent(0) > 0)
87 Kokkos::atomic_add(&forceW(j), fwn);
89 if constexpr (!std::is_same_v<Sdf, NoSdf>) {
90 double fw[3] = {0.0, 0.0, 0.0};
91 Real px = pos.extent(0) > 0 ? pos(3 * i) : Real(0);
92 Real py = pos.extent(0) > 0 ? pos(3 * i + 1) : Real(0);
93 Real pz = pos.extent(0) > 0 ? pos(3 * i + 2) : Real(0);
94 sdfWallChain<Real>(sdf, px, py, pz, gw, fw);
95 fSelf[0] += (Real)fw[0];
96 fSelf[1] += (Real)fw[1];
97 fSelf[2] += (Real)fw[2];
101 Kokkos::atomic_add(&force(3 * i), fSelf[0]);
102 Kokkos::atomic_add(&force(3 * i + 1), fSelf[1]);
103 Kokkos::atomic_add(&force(3 * i + 2), fSelf[2]);
104 if constexpr (Policy::kHasWeightDof)
105 if (forceW.extent(0) > 0)
106 Kokkos::atomic_add(&forceW(i), fwSelf);