flow 1.3.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#include "policy.hpp"
16
17namespace peclet::flow {
18
35inline void gpCenterGrad(CCField out, CCConst p, CCConst sdf, int axis, C3 e, int g,
36 double wa = 1.0) {
38 using MD = MDRange3<CCExec>;
39 Kokkos::parallel_for(
40 "peclet::flow::gp_center_grad", MD(space, {g, g, g}, {e.x - g, e.y - g, e.z - g}),
41 KOKKOS_LAMBDA(int x, int y, int z) {
42 const long sy = e.x, sz = (long)e.x * e.y;
43 const long i = (long)x + (long)y * sy + (long)z * sz;
44 const long sa = (axis == 0) ? 1 : (axis == 1) ? sy : sz;
45 if (sdf(i) < 0.0) {
46 out(i) = 0.0;
47 return;
48 }
49 const bool am = sdf(i - sa) >= 0.0, ap = sdf(i + sa) >= 0.0;
50 double gr;
51 if (am && ap)
52 gr = 0.5 * (p(i + sa) - p(i - sa));
53 else if (ap)
54 gr = (sdf(i + 2 * sa) >= 0.0) ? 0.5 * (-3.0 * p(i) + 4.0 * p(i + sa) - p(i + 2 * sa))
55 : (p(i + sa) - p(i));
56 else if (am)
57 gr = (sdf(i - 2 * sa) >= 0.0) ? 0.5 * (3.0 * p(i) - 4.0 * p(i - sa) + p(i - 2 * sa))
58 : (p(i) - p(i - sa));
59 else
60 gr = 0.0;
61 out(i) = wa * gr;
62 });
63}
64
65} // namespace peclet::flow
66
67#endif // PECLET_FLOW_GAUGE_EXACT_GRADIENT_HPP
flow — portable (Kokkos) cut-cell pressure-operator face openness from an SDF.
Kokkos::View< double *, CCMem > CCField
Kokkos::DefaultExecutionSpace CCExec
void gpCenterGrad(CCField out, CCConst p, CCConst sdf, int axis, C3 e, int g, double wa=1.0)
Directional cell-center gradient (collocated ghost path) of a cell field p whose solid-centered rows ...
Kokkos::View< const double *, CCMem > CCConst
flow — the multidimensional iteration policies: iteration order follows storage.