18#ifndef PECLET_VORO_PHYSICS_VISCOUS_HPP
19#define PECLET_VORO_PHYSICS_VISCOUS_HPP
21#include <Kokkos_Core.hpp>
23#include "peclet/core/common/view.hpp"
33 const Kokkos::View<int*, peclet::core::MemSpace>& recip,
34 const Kokkos::View<int*, peclet::core::MemSpace>& cellOfFacet,
35 const Kokkos::View<Real*, peclet::core::MemSpace>& vel,
36 const Kokkos::View<Real*, peclet::core::MemSpace>& grad) {
37 using Exec = peclet::core::ExecSpace;
40 "visc.grad", Kokkos::RangePolicy<Exec>(0, N), KOKKOS_LAMBDA(
const int i) {
42 for (
int t = 0; t < 9; ++t)
44 const Real vi[3] = {vel(3 * i + 0), vel(3 * i + 1), vel(3 * i + 2)};
46 const int r = recip(f);
49 const int nb = cellOfFacet(r);
50 for (
int p = 0; p < 3; ++p) {
51 const Real vn = vel(3 * nb + p);
52 for (
int k = 0; k < 3; ++k)
53 g[3 * p + k] += vi[p] * view.
connect(f, k) - vn * view.
connect(r, k);
56 const Real invV = Real(1) / view.
volume(i);
57 for (
int t = 0; t < 9; ++t)
58 grad(9 * i + t) = g[t] * invV;
64void viscousStress(
const Kokkos::View<Real*, peclet::core::MemSpace>& grad,
65 const Kokkos::View<Real*, peclet::core::MemSpace>& visc,
66 const Kokkos::View<Real*, peclet::core::MemSpace>& bulkVisc,
67 const Kokkos::View<Real*, peclet::core::MemSpace>& stress) {
68 using Exec = peclet::core::ExecSpace;
69 const int N =
static_cast<int>(visc.extent(0));
71 "visc.stress", Kokkos::RangePolicy<Exec>(0, N), KOKKOS_LAMBDA(
const int i) {
72 const Real mu = visc(i), mub = bulkVisc(i);
74 for (
int t = 0; t < 9; ++t)
75 gk[t] = grad(9 * i + t);
76 Real divv = gk[0] + gk[4] + gk[8];
78 for (
int k = 0; k < 3; ++k)
79 for (
int m = 0; m < 3; ++m)
80 s[3 * k + m] = mu * (gk[3 * k + m] + gk[3 * m + k]);
81 const Real lam = (mub - Real(2) / Real(3) * mu) * divv;
85 for (
int t = 0; t < 9; ++t)
86 stress(9 * i + t) = s[t];
94 const Kokkos::View<Real*, peclet::core::MemSpace>& stress,
95 const Kokkos::View<Real*, peclet::core::MemSpace>& force) {
96 using Exec = peclet::core::ExecSpace;
99 "visc.force", Kokkos::RangePolicy<Exec>(0, N), KOKKOS_LAMBDA(
const int i) {
100 Real f[3] = {0, 0, 0};
105 for (
int k = 0; k < 3; ++k)
106 for (
int m = 0; m < 3; ++m)
108 (stress(9 * nb + 3 * k + m) - stress(9 * i + 3 * k + m)) * view.
connect(ff, m);
110 for (
int k = 0; k < 3; ++k)
111 force(3 * i + k) += f[k];
120 const Kokkos::View<int*, peclet::core::MemSpace>& recip,
121 const Kokkos::View<int*, peclet::core::MemSpace>& cellOfFacet,
122 const Kokkos::View<Real*, peclet::core::MemSpace>& vel,
123 const Kokkos::View<Real*, peclet::core::MemSpace>& visc,
124 const Kokkos::View<Real*, peclet::core::MemSpace>& bulkVisc,
125 const Kokkos::View<Real*, peclet::core::MemSpace>& force,
126 const Kokkos::View<Real*, peclet::core::MemSpace>& grad,
127 const Kokkos::View<Real*, peclet::core::MemSpace>& stress) {
136 const Kokkos::View<int*, peclet::core::MemSpace>& recip,
137 const Kokkos::View<int*, peclet::core::MemSpace>& cellOfFacet,
138 const Kokkos::View<Real*, peclet::core::MemSpace>& vel,
139 const Kokkos::View<Real*, peclet::core::MemSpace>& visc,
140 const Kokkos::View<Real*, peclet::core::MemSpace>& bulkVisc,
141 const Kokkos::View<Real*, peclet::core::MemSpace>& force) {
143 Kokkos::View<Real*, peclet::core::MemSpace> grad(
"visc.grad", (
size_t)9 * N);
144 Kokkos::View<Real*, peclet::core::MemSpace> stress(
"visc.stress", (
size_t)9 * N);
145 viscousForce(view, recip, cellOfFacet, vel, visc, bulkVisc, force, grad, stress);
void viscousForce(const TessellationView< Real > &view, const Kokkos::View< int *, peclet::core::MemSpace > &recip, const Kokkos::View< int *, peclet::core::MemSpace > &cellOfFacet, const Kokkos::View< Real *, peclet::core::MemSpace > &vel, const Kokkos::View< Real *, peclet::core::MemSpace > &visc, const Kokkos::View< Real *, peclet::core::MemSpace > &bulkVisc, const Kokkos::View< Real *, peclet::core::MemSpace > &force, const Kokkos::View< Real *, peclet::core::MemSpace > &grad, const Kokkos::View< Real *, peclet::core::MemSpace > &stress)
Definition viscous.hpp:119
void velocityGradient(const TessellationView< Real > &view, const Kokkos::View< int *, peclet::core::MemSpace > &recip, const Kokkos::View< int *, peclet::core::MemSpace > &cellOfFacet, const Kokkos::View< Real *, peclet::core::MemSpace > &vel, const Kokkos::View< Real *, peclet::core::MemSpace > &grad)
Definition viscous.hpp:32
void viscousStress(const Kokkos::View< Real *, peclet::core::MemSpace > &grad, const Kokkos::View< Real *, peclet::core::MemSpace > &visc, const Kokkos::View< Real *, peclet::core::MemSpace > &bulkVisc, const Kokkos::View< Real *, peclet::core::MemSpace > &stress)
Newtonian stress per cell from the gradient (τ stored 9-per-cell, symmetric).
Definition viscous.hpp:64
void addViscousForce(const TessellationView< Real > &view, const Kokkos::View< Real *, peclet::core::MemSpace > &stress, const Kokkos::View< Real *, peclet::core::MemSpace > &force)
Definition viscous.hpp:93
Definition convex_cell.hpp:40
Definition tessellation_view.hpp:111
KOKKOS_INLINE_FUNCTION int facetEnd(int i) const
Definition tessellation_view.hpp:140
KOKKOS_INLINE_FUNCTION gid_t facetNbr(int f) const
Definition tessellation_view.hpp:143
KOKKOS_INLINE_FUNCTION int facetBegin(int i) const
Definition tessellation_view.hpp:139
KOKKOS_INLINE_FUNCTION Real volume(int i) const
Definition tessellation_view.hpp:138
KOKKOS_INLINE_FUNCTION int numCells() const
Definition tessellation_view.hpp:131
KOKKOS_INLINE_FUNCTION Real connect(int f, int c) const
Definition tessellation_view.hpp:145
Published, read-only device data layer for the tessellation (migration §2.1, §3).