flow
Kokkos cut-cell IBM incompressible Navier-Stokes solver + pnm pore extraction
Loading...
Searching...
No Matches
grid_layout.hpp
Go to the documentation of this file.
1
12#ifndef PECLET_FLOW_GRID_LAYOUT_HPP
13#define PECLET_FLOW_GRID_LAYOUT_HPP
14
15#include "colocated_advection.hpp" // cadv::advect / advect_fou / fou_operator
16#include "mac_ibm.hpp" // peclet::flow::Off3
17#include "staggered_advection.hpp" // sadv::advect / advect_fou / fou_operator
18
19namespace peclet::flow {
20
21// A GridLayout policy supplies the two grid-position-dependent pieces the orchestrator needs:
22// - offset(c): where component c's velocity unknown sits (drives the cut-cell IBM overlay /
23// openness /
24// volume-fraction kernels);
25// - advect / advect_fou / fou_operator: the conservative momentum advection for that
26// control-volume
27// placement (forwarded to the sadv:: or cadv:: free functions).
28// The policy is stateless; the advection methods are KOKKOS_INLINE_FUNCTION so they inline on
29// device.
30
31// Staggered MAC grid: component c (0=u,1=v,2=w) lives on the low face along axis c (offset -1/2
32// there), i.e. u@(i-1/2,j,k), v@(i,j-1/2,k), w@(i,j,k-1/2). This is the existing flow grid; the
33// offsets reproduce the previously hard-coded {-0.5,0,0}/{0,-0.5,0}/{0,0,-0.5} arrays exactly
34// (bit-identical).
35struct Staggered {
36 static constexpr const char* name = "staggered";
37 static constexpr bool collocated = false; // stored velocity IS the face velocity (MAC)
38 static constexpr Off3 offset(int c) {
39 return c == 0 ? Off3{-0.5f, 0.0f, 0.0f}
40 : c == 1 ? Off3{0.0f, -0.5f, 0.0f}
41 : Off3{0.0f, 0.0f, -0.5f};
42 }
43 template <class A>
44 KOKKOS_INLINE_FUNCTION static double advect(int c, int x, int y, int z, A U, A V, A W, A F) {
45 return sadv::advect(c, x, y, z, U, V, W, F);
46 }
47 template <class A>
48 KOKKOS_INLINE_FUNCTION static double advect_sou(int c, int x, int y, int z, A U, A V, A W, A F) {
49 return sadv::advect_sou(c, x, y, z, U, V, W, F);
50 }
51 template <class A>
52 KOKKOS_INLINE_FUNCTION static double advect_fou(int c, int x, int y, int z, A U, A V, A W, A F) {
53 return sadv::advect_fou(c, x, y, z, U, V, W, F);
54 }
55 template <class A>
56 KOKKOS_INLINE_FUNCTION static void fou_operator(int c, int x, int y, int z, A U, A V, A W,
57 double dt, double& cC, double& cxm, double& cxp,
58 double& cym, double& cyp, double& czm,
59 double& czp) {
60 sadv::fou_operator(c, x, y, z, U, V, W, dt, cC, cxm, cxp, cym, cyp, czm, czp);
61 }
62};
63
64// Collocated (cell-centered) grid: all three components live at the cell center (offset 0),
65// advected on the cell control volume with cell->face-averaged advecting velocities (cadv). The
66// pressure coupling (approximate/MAC projection) is added in a later phase; this policy carries the
67// predictor pieces.
68struct Colocated {
69 static constexpr const char* name = "colocated";
70 static constexpr bool collocated = true; // cell-centered velocity; approximate (MAC) projection
71 static constexpr Off3 offset(int /*c*/) { return Off3{0.0f, 0.0f, 0.0f}; }
72 template <class A>
73 KOKKOS_INLINE_FUNCTION static double advect(int c, int x, int y, int z, A U, A V, A W, A F) {
74 return cadv::advect(c, x, y, z, U, V, W, F);
75 }
76 template <class A>
77 KOKKOS_INLINE_FUNCTION static double advect_sou(int c, int x, int y, int z, A U, A V, A W, A F) {
78 return cadv::advect_sou(c, x, y, z, U, V, W, F);
79 }
80 template <class A>
81 KOKKOS_INLINE_FUNCTION static double advect_fou(int c, int x, int y, int z, A U, A V, A W, A F) {
82 return cadv::advect_fou(c, x, y, z, U, V, W, F);
83 }
84 template <class A>
85 KOKKOS_INLINE_FUNCTION static void fou_operator(int c, int x, int y, int z, A U, A V, A W,
86 double dt, double& cC, double& cxm, double& cxp,
87 double& cym, double& cyp, double& czm,
88 double& czp) {
89 cadv::fou_operator(c, x, y, z, U, V, W, dt, cC, cxm, cxp, cym, cyp, czm, czp);
90 }
91};
92
93} // namespace peclet::flow
94
95#endif // PECLET_FLOW_GRID_LAYOUT_HPP
flow — collocated (cell-centered) momentum advection (Koren TVD + FOU).
flow — portable (Kokkos) IBM geometric fields + variable-coefficient RB-GS smoother.
void fou_operator(int comp, int x, int y, int z, A U, A V, A W, double dt, double &cC, double &cxm, double &cxp, double &cym, double &cyp, double &czm, double &czp)
double advect_fou(int comp, int x, int y, int z, A U, A V, A W, A PHI)
double advect_sou(int comp, int x, int y, int z, A U, A V, A W, A PHI)
double advect(int comp, int x, int y, int z, A U, A V, A W, A PHI)
double advect(int comp, int x, int y, int z, A U, A V, A W, A PHI)
double advect_sou(int comp, int x, int y, int z, A U, A V, A W, A PHI)
void fou_operator(int comp, int x, int y, int z, A U, A V, A W, double dt, double &cC, double &cxm, double &cxp, double &cym, double &cyp, double &czm, double &czp)
double advect_fou(int comp, int x, int y, int z, A U, A V, A W, A PHI)
flow — portable (Kokkos) staggered MAC momentum advection (Koren TVD + FOU).
static void fou_operator(int c, int x, int y, int z, A U, A V, A W, double dt, double &cC, double &cxm, double &cxp, double &cym, double &cyp, double &czm, double &czp)
static constexpr const char * name
static constexpr Off3 offset(int)
static constexpr bool collocated
static double advect_sou(int c, int x, int y, int z, A U, A V, A W, A F)
static double advect(int c, int x, int y, int z, A U, A V, A W, A F)
static double advect_fou(int c, int x, int y, int z, A U, A V, A W, A F)
static double advect(int c, int x, int y, int z, A U, A V, A W, A F)
static constexpr const char * name
static double advect_fou(int c, int x, int y, int z, A U, A V, A W, A F)
static constexpr bool collocated
static constexpr Off3 offset(int c)
static double advect_sou(int c, int x, int y, int z, A U, A V, A W, A F)
static void fou_operator(int c, int x, int y, int z, A U, A V, A W, double dt, double &cC, double &cxm, double &cxp, double &cym, double &cyp, double &czm, double &czp)
static constexpr double F