flow 0.4.0
Kokkos cut-cell IBM incompressible Navier-Stokes solver + pnm pore extraction
Loading...
Searching...
No Matches
gauge_exact_gradient.hpp
Go to the documentation of this file.
1
9#ifndef PECLET_FLOW_GAUGE_EXACT_GRADIENT_HPP
10#define PECLET_FLOW_GAUGE_EXACT_GRADIENT_HPP
11
12#include <Kokkos_Core.hpp>
13
14#include "mac_cutcell.hpp" // CCField/CCConst, C3, CCExec
15
16namespace peclet::flow {
17
39inline void gpCenterGrad(CCField out, CCConst p, CCConst sdf, int axis, C3 e, int g,
40 bool grad2a = false) {
42 using MD = Kokkos::MDRangePolicy<CCExec, Kokkos::Rank<3>>;
43 Kokkos::parallel_for(
44 "peclet::flow::gp_center_grad", MD(space, {g, g, g}, {e.x - g, e.y - g, e.z - g}),
45 KOKKOS_LAMBDA(int x, int y, int z) {
46 const long sy = e.x, sz = (long)e.x * e.y;
47 const long i = (long)x + (long)y * sy + (long)z * sz;
48 const long sa = (axis == 0) ? 1 : (axis == 1) ? sy : sz;
49 if (sdf(i) < 0.0) {
50 out(i) = 0.0;
51 return;
52 }
53 const bool am = sdf(i - sa) >= 0.0, ap = sdf(i + sa) >= 0.0;
54 // the +/-3 cell of the grad2a stencil can sit one past the g-wide ghost pad; the axis
55 // coordinate guard falls back to the 2-point form there (never reads out of the block)
56 const int ca = (axis == 0) ? x : (axis == 1) ? y : z;
57 const int ea = (axis == 0) ? e.x : (axis == 1) ? e.y : e.z;
58 double gr;
59 if (am && ap)
60 gr = 0.5 * (p(i + sa) - p(i - sa));
61 else if (ap) {
62 if (grad2a)
63 gr = (ca + 3 < ea && sdf(i + 2 * sa) >= 0.0 && sdf(i + 3 * sa) >= 0.0)
64 ? 0.5 * (-2.0 * p(i) + p(i + sa) + 2.0 * p(i + 2 * sa) - p(i + 3 * sa))
65 : (p(i + sa) - p(i));
66 else
67 gr = (sdf(i + 2 * sa) >= 0.0) ? 0.5 * (-3.0 * p(i) + 4.0 * p(i + sa) - p(i + 2 * sa))
68 : (p(i + sa) - p(i));
69 } else if (am) {
70 if (grad2a)
71 gr = (ca - 3 >= 0 && sdf(i - 2 * sa) >= 0.0 && sdf(i - 3 * sa) >= 0.0)
72 ? 0.5 * (2.0 * p(i) - p(i - sa) - 2.0 * p(i - 2 * sa) + p(i - 3 * sa))
73 : (p(i) - p(i - sa));
74 else
75 gr = (sdf(i - 2 * sa) >= 0.0) ? 0.5 * (3.0 * p(i) - 4.0 * p(i - sa) + p(i - 2 * sa))
76 : (p(i) - p(i - sa));
77 } else
78 gr = 0.0;
79 out(i) = gr;
80 });
81}
82
83} // namespace peclet::flow
84
85#endif // PECLET_FLOW_GAUGE_EXACT_GRADIENT_HPP
flow — portable (Kokkos) cut-cell pressure-operator face openness from an SDF.
void gpCenterGrad(CCField out, CCConst p, CCConst sdf, int axis, C3 e, int g, bool grad2a=false)
Directional cell-center gradient (collocated ghost path) of a cell field p whose solid-centered rows ...
void ibmFillEntry(const OV &o, int list_idx, int c_idx, float sdf_c, const float sdf_n[6], int bc_type, const float *thEx)
Kokkos::View< double *, CCMem > CCField
Kokkos::DefaultExecutionSpace CCExec
Kokkos::View< const double *, CCMem > CCConst