12#ifndef PECLET_VORO_ENERGY_VOLUME_HPP
13#define PECLET_VORO_ENERGY_VOLUME_HPP
15#include <Kokkos_Core.hpp>
25 return Real(2) * (V / Vref - Real(1)) / Vref;
30 return V > Real(0) ? -mu / V : Real(0);
35 return V > Real(0) ? -Vref / V : Real(0);
40template <
class Real,
class Policy = Voronoi,
class Sdf = NoSdf>
42 const Kokkos::View<Real*, peclet::core::MemSpace>& dEdV,
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 const Sdf& sdf = Sdf{}) {
48 using Exec = peclet::core::ExecSpace;
51 "energy.volume", Kokkos::RangePolicy<Exec>(0, N), KOKKOS_LAMBDA(
const int i) {
52 const Real de = dEdV(i);
60 for (
int k = 0; k < nf; ++k) {
63 for (
int c = 0; c < 3; ++c)
64 gl[3 * k + c] = fd ? Real(0) : de * view.
area(f, c);
66 for (
int c = 0; c < 3; ++c)
67 gl[3 * k + c] = Real(2) * de * view.
connect(f, c);
70 detail::routeCellGradient<Real, Policy>(view, i, gl, nf, pos, weight, L, sdf, force,
73 for (
int c = 0; c < 3; ++c)
74 Kokkos::atomic_add(&force(3 * i + c), de * view.
wallDV(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
KOKKOS_INLINE_FUNCTION Real dLogBarrier(Real V, Real mu)
e(V) = −μ log(V/Vref) (log-barrier against collapse): e' = −μ/V.
Definition volume.hpp:29
void volumeGradientForce(const TessellationView< Real > &view, const Kokkos::View< Real *, peclet::core::MemSpace > &dEdV, 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 volume.hpp:41
KOKKOS_INLINE_FUNCTION Real dTargetVolume(Real V, Real Vref)
e(V) = (V/Vref − 1)²: e' = 2 (V/Vref − 1)/Vref.
Definition volume.hpp:24
KOKKOS_INLINE_FUNCTION Real dFreeEnergy(Real V, Real Vref)
e(V) = −Vref log V (ideal-gas free energy; equilibrium at equal pressure Vref/V): e' = −Vref/V.
Definition volume.hpp:34
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 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 facetBegin(int i) const
Definition tessellation_view.hpp:181
KOKKOS_INLINE_FUNCTION bool hasWallFD() const
Definition tessellation_view.hpp:153
KOKKOS_INLINE_FUNCTION int numCells() const
Definition tessellation_view.hpp:173
KOKKOS_INLINE_FUNCTION Real wallDV(int i, int c) const
Definition tessellation_view.hpp:154
KOKKOS_INLINE_FUNCTION Real connect(int f, int c) const
Definition tessellation_view.hpp:187
Published, read-only device data layer for the tessellation (migration §2.1, §3).