22#ifndef PECLET_VORO_ENERGY_WALL_HPP
23#define PECLET_VORO_ENERGY_WALL_HPP
25#include <Kokkos_Core.hpp>
39template <
class Real,
class Policy = Voronoi,
class Sdf = NoSdf>
41 const Kokkos::View<int*, peclet::core::MemSpace>& types,
42 const Kokkos::View<Real*, peclet::core::MemSpace>& sigmaS,
const Sdf& sdf,
43 const Kokkos::View<Real*, peclet::core::MemSpace>& pos,
44 const Kokkos::View<Real*, peclet::core::MemSpace>& weight, Real L,
45 const Kokkos::View<Real*, peclet::core::MemSpace>& force,
46 const Kokkos::View<Real*, peclet::core::MemSpace>& forceW = {}) {
47 using Exec = peclet::core::ExecSpace;
50 Kokkos::parallel_reduce(
51 "energy.wall", Kokkos::RangePolicy<Exec>(0, N),
52 KOKKOS_LAMBDA(
const int i, Real& acc) {
53 const Real sig = sigmaS(types(i));
60 for (
int k = 0; k < 3 * nf; ++k)
64 for (
int f = b; f < b + nf; ++f) {
68 const Real ax = view.
area(f, 0), ay = view.
area(f, 1), az = view.
area(f, 2);
69 acc += sig * Kokkos::sqrt(ax * ax + ay * ay + az * az);
74 for (
int c = 0; c < 3; ++c)
75 gl[3 * p + c] += sig * view.
areaGrad(e, c);
79 detail::routeCellGradient<Real, Policy>(view, i, gl, nf, pos, weight, L, sdf, force,
82 for (
int c = 0; c < 3; ++c)
83 Kokkos::atomic_add(&force(3 * i + c), sig * view.
wallDA(i, c));
KOKKOS_INLINE_FUNCTION Dual< Real, K > dnum(Real c)
Definition convex_cell.hpp:53
constexpr int kMaxLocalFacets
Facets one cell may publish (CellBuilder::MAXF_TMP); bounds the per-thread gradient array.
Definition route.hpp:29
Definition interface.hpp:23
Real wallEnergyForce(const TessellationView< Real > &view, const Kokkos::View< int *, peclet::core::MemSpace > &types, const Kokkos::View< Real *, peclet::core::MemSpace > &sigmaS, const Sdf &sdf, const Kokkos::View< Real *, peclet::core::MemSpace > &pos, const Kokkos::View< Real *, peclet::core::MemSpace > &weight, Real L, const Kokkos::View< Real *, peclet::core::MemSpace > &force, const Kokkos::View< Real *, peclet::core::MemSpace > &forceW={})
Definition wall.hpp:40
constexpr int kBoundaryFacet
Definition sdf.hpp:36
Rung A3: route a cell's per-facet geometry gradient to the seed DOFs on the PUBLISHED view — the one ...
Definition tessellation_view.hpp:111
KOKKOS_INLINE_FUNCTION Real wallDA(int i, int c) const
Definition tessellation_view.hpp:155
KOKKOS_INLINE_FUNCTION Real area(int f, int c) const
Definition tessellation_view.hpp:186
KOKKOS_INLINE_FUNCTION int facetEnd(int i) const
Definition tessellation_view.hpp:182
KOKKOS_INLINE_FUNCTION gid_t facetNbr(int f) const
Definition tessellation_view.hpp:185
KOKKOS_INLINE_FUNCTION int edgePartner(int e) const
Definition tessellation_view.hpp:168
KOKKOS_INLINE_FUNCTION int facetBegin(int i) const
Definition tessellation_view.hpp:181
KOKKOS_INLINE_FUNCTION bool hasWallFD() const
Definition tessellation_view.hpp:153
KOKKOS_INLINE_FUNCTION int edgeBegin(int f) const
Definition tessellation_view.hpp:166
KOKKOS_INLINE_FUNCTION int numCells() const
Definition tessellation_view.hpp:173
KOKKOS_INLINE_FUNCTION int edgeEnd(int f) const
Definition tessellation_view.hpp:167
KOKKOS_INLINE_FUNCTION Real areaGrad(int e, int c) const
Definition tessellation_view.hpp:169