15#ifndef PECLET_VORO_ENERGY_INTERFACE_HPP
16#define PECLET_VORO_ENERGY_INTERFACE_HPP
18#include <Kokkos_Core.hpp>
28template <
class Real,
class Policy = Voronoi,
class Sdf = NoSdf>
30 const Kokkos::View<int*, peclet::core::MemSpace>& types,
31 const Kokkos::View<Real*, peclet::core::MemSpace>& tension,
int nTypes,
32 const Kokkos::View<Real*, peclet::core::MemSpace>& pos,
33 const Kokkos::View<Real*, peclet::core::MemSpace>& weight, Real L,
34 const Kokkos::View<Real*, peclet::core::MemSpace>& force,
35 const Kokkos::View<Real*, peclet::core::MemSpace>& forceW = {},
36 const Sdf& sdf = Sdf{}) {
37 using Exec = peclet::core::ExecSpace;
40 Kokkos::parallel_reduce(
41 "energy.interface", Kokkos::RangePolicy<Exec>(0, N),
42 KOKKOS_LAMBDA(
const int i, Real& acc) {
47 for (
int k = 0; k < 3 * nf; ++k)
49 const int ti = types(i);
51 for (
int f = b; f < b + nf; ++f) {
55 const int tj = types(j);
58 const Real sig = Real(0.5) * tension(ti * nTypes + tj);
62 const Real ax = view.
area(f, 0), ay = view.
area(f, 1), az = view.
area(f, 2);
63 acc += sig * Kokkos::sqrt(ax * ax + ay * ay + az * az);
66 for (
int c = 0; c < 3; ++c)
67 gl[3 * p + c] += sig * view.
areaGrad(e, c);
71 detail::routeCellGradient<Real, Policy>(view, i, gl, nf, pos, weight, L, sdf, force,
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 interfaceEnergyForce(const TessellationView< Real > &view, const Kokkos::View< int *, peclet::core::MemSpace > &types, const Kokkos::View< Real *, peclet::core::MemSpace > &tension, int nTypes, 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={}, const Sdf &sdf=Sdf{})
Definition interface.hpp:29
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 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 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
Published, read-only device data layer for the tessellation (migration §2.1, §3).