flow 1.4.0
Kokkos cut-cell IBM incompressible Navier-Stokes solver + pnm pore extraction
Loading...
Searching...
No Matches
full_stress.hpp
Go to the documentation of this file.
1
24#ifndef PECLET_FLOW_FULL_STRESS_HPP
25#define PECLET_FLOW_FULL_STRESS_HPP
26
27#include <cstdint>
28#include <Kokkos_Core.hpp>
29
30#include "mac_cutcell.hpp"
31
32namespace peclet::flow {
33
36using RegMask = Kokkos::View<std::uint8_t*, CCMem>;
37using RegConst = Kokkos::View<const std::uint8_t*, CCMem>;
38
48template <class FaceProps, bool kSolid>
49inline void addFullStressRhs(int c, CCField bb, CCConst rs, const CCConst (&v)[3], FaceProps fp,
50 C3 e, int g, double wc, bool skipLoC,
51 const RegConst (&reg)[3] = {RegConst(), RegConst(), RegConst()}) {
52 const long st[3] = {1L, (long)e.x, (long)e.x * e.y};
53 const int a1 = (c == 0) ? 1 : 0, a2 = (c == 2) ? 1 : 2;
54 const long sc = st[c], s1 = st[a1], s2 = st[a2];
55 const CCConst vc = v[c], va1 = v[a1], va2 = v[a2];
56 const RegConst rc = reg[c], ra1 = reg[a1], ra2 = reg[a2];
57 const int lo[3] = {g + ((skipLoC && c == 0) ? 1 : 0), g + ((skipLoC && c == 1) ? 1 : 0),
58 g + ((skipLoC && c == 2) ? 1 : 0)};
59 ccFor3(
60 "peclet::flow::full_stress_rhs", C3{lo[0], lo[1], lo[2]}, C3{e.x - g, e.y - g, e.z - g},
61 KOKKOS_LAMBDA(int x, int y, int z) {
62 const long i = (long)x + (long)y * st[1] + (long)z * st[2];
63 if (kSolid) { // not constexpr-if: nvcc cannot first-capture inside one
64 if (!rc(i))
65 return; // every element of this row touches u_c(i): nothing is included
66 }
67 // Normal elements at the cell centres i and i - s_c.
68 double nP = fp.beta(i, i + sc) * (vc(i + sc) - vc(i));
69 double nM = fp.beta(i - sc, i) * (vc(i) - vc(i - sc));
70 // Shear elements on the four (a, c) edges of the node.
71 double p1 = fp.beta(i, i + s1) * (va1(i + s1) - va1(i + s1 - sc));
72 double m1 = fp.beta(i, i - s1) * (va1(i) - va1(i - sc));
73 double p2 = fp.beta(i, i + s2) * (va2(i + s2) - va2(i + s2 - sc));
74 double m2 = fp.beta(i, i - s2) * (va2(i) - va2(i - sc));
75 if (kSolid) { // not constexpr-if: nvcc cannot first-capture inside one
76 if (!rc(i + sc))
77 nP = 0.0;
78 if (!rc(i - sc))
79 nM = 0.0;
80 if (!(rc(i + s1) && ra1(i + s1) && ra1(i + s1 - sc)))
81 p1 = 0.0;
82 if (!(rc(i - s1) && ra1(i) && ra1(i - sc)))
83 m1 = 0.0;
84 if (!(rc(i + s2) && ra2(i + s2) && ra2(i + s2 - sc)))
85 p2 = 0.0;
86 if (!(rc(i - s2) && ra2(i) && ra2(i - sc)))
87 m2 = 0.0;
88 }
89 const double t = wc * (((nP - nM) + (p1 - m1)) + (p2 - m2));
90 bb(i) += rs(i) * t;
91 });
92}
93
97inline void muRangeInner(CCConst mu, C3 e, int g, double& lo, double& hi) {
98 CCExec space;
99 Kokkos::MinMaxScalar<double> r;
100 Kokkos::parallel_reduce(
101 "peclet::flow::full_stress_mu_range",
102 MDRange3<CCExec>(space, {g - 1, g - 1, g - 1}, {e.x - g + 1, e.y - g + 1, e.z - g + 1}),
103 KOKKOS_LAMBDA(int x, int y, int z, Kokkos::MinMaxScalar<double>& acc) {
104 const long i = (long)x + (long)y * e.x + (long)z * (long)e.x * e.y;
105 const double m = mu(i);
106 if (m < acc.min_val)
107 acc.min_val = m;
108 if (m > acc.max_val)
109 acc.max_val = m;
110 },
111 Kokkos::MinMax<double>(r));
112 lo = r.min_val;
113 hi = r.max_val;
114}
115
116} // namespace peclet::flow
117
118#endif // PECLET_FLOW_FULL_STRESS_HPP
flow — portable (Kokkos) cut-cell pressure-operator face openness from an SDF.
y
Definition cmp.py:24
Kokkos::DefaultExecutionSpace CCExec
Kokkos::MDRangePolicy< Exec, Kokkos::Rank< 3, Kokkos::Iterate::Left, Kokkos::Iterate::Left > > MDRange3
3-D range, x (the first index) fastest (both the tile order and the order within a tile).
Definition policy.hpp:36
Kokkos::View< const double *, CCMem > CCConst
Kokkos::View< const std::uint8_t *, CCMem > RegConst
void addFullStressRhs(int c, CCField bb, CCConst rs, const CCConst(&v)[3], FaceProps fp, C3 e, int g, double wc, bool skipLoC, const RegConst(&reg)[3]={RegConst(), RegConst(), RegConst()})
Add rs_c · T_c(uⁿ) to the momentum RHS bb of component c over the inner cells [g, e−g)³.
Kokkos::View< double *, CCMem > CCField
void ccFor3(const char *name, C3 lo, C3 hi, F f)
void muRangeInner(CCConst mu, C3 e, int g, double &lo, double &hi)
The local min and max of mu over [g−1, e−g+1)³ — the inner cells plus the one ghost ring the transpos...
Kokkos::View< std::uint8_t *, CCMem > RegMask
Per-component regular-node mask (§5.4): 1 = a velocity node with neither a solid nor a cut row.
tuple rc
Definition post.py:37
t
Definition post.py:21
Kokkos::View< const double *, CCMem > CCConst
Kokkos::View< const std::uint8_t *, CCMem > RegConst