flow 1.3.0
Kokkos cut-cell IBM incompressible Navier-Stokes solver + pnm pore extraction
Loading...
Searching...
No Matches
colour_bc.hpp
Go to the documentation of this file.
1
56#ifndef PECLET_FLOW_VOF_COLOUR_BC_HPP
57#define PECLET_FLOW_VOF_COLOUR_BC_HPP
58
59#include <Kokkos_Core.hpp>
60
61#include "mac_stencils.hpp" // peclet::flow::SExec, SField, I3, L3
62#include "policy.hpp"
63#include "vof/advect_wy.hpp" // UCField
64
65namespace peclet::flow::vof {
66
67namespace bcdetail {
68KOKKOS_INLINE_FUNCTION void axisDims(I3 e, int (&dims)[3], long (&strides)[3]) {
69 dims[0] = e.x;
70 dims[1] = e.y;
71 dims[2] = e.z;
72 strides[0] = 1;
73 strides[1] = e.x;
74 strides[2] = static_cast<long>(e.x) * e.y;
75}
76} // namespace bcdetail
77
84inline void buildOutsideMask(UCField m, I3 e, int g, I3 o, I3 gs, bool px, bool py, bool pz) {
85 const bool p0 = px, p1 = py, p2 = pz;
86 const int q0 = gs.x, q1 = gs.y, q2 = gs.z;
87 Kokkos::parallel_for(
88 "vof::buildOutsideMask", MDRange3<SExec>(SExec(), {0, 0, 0}, {e.x, e.y, e.z}),
89 KOKKOS_LAMBDA(int x, int y, int z) {
90 const int gx = x - g + o.x, gy = y - g + o.y, gz = z - g + o.z;
91 const bool out = (!p0 && (gx < 0 || gx >= q0)) || (!p1 && (gy < 0 || gy >= q1)) ||
92 (!p2 && (gz < 0 || gz >= q2));
93 m(L3(x, y, z, e)) = out ? 1u : 0u;
94 });
95 Kokkos::fence();
96}
97
101inline void bcColourConst(SField f, I3 e, int g, int a, int s, double value) {
102 int dims[3];
103 long strides[3];
105 const int b = (a + 1) % 3, c = (a + 2) % 3;
106 const long sa = strides[a], sb = strides[b], sc = strides[c];
107 const int na = dims[a];
108 const int lo = (s == 0) ? 0 : (na - g);
109 Kokkos::parallel_for(
110 "vof::bcColourConst", MDRange2<SExec>(SExec(), {0, 0}, {dims[b], dims[c]}),
111 KOKKOS_LAMBDA(int p0, int p1) {
112 const long base = static_cast<long>(p0) * sb + static_cast<long>(p1) * sc;
113 for (int k = 0; k < g; ++k)
114 f(base + static_cast<long>(lo + k) * sa) = value;
115 });
116 Kokkos::fence();
117}
118
123inline void bcColourProfile(SField f, I3 e, int g, int a, int s, SField prof, int nc) {
124 int dims[3];
125 long strides[3];
127 const int b = (a + 1) % 3, c = (a + 2) % 3;
128 const long sa = strides[a], sb = strides[b], sc = strides[c];
129 const int na = dims[a];
130 const int lo = (s == 0) ? 0 : (na - g);
131 Kokkos::parallel_for(
132 "vof::bcColourProfile", MDRange2<SExec>(SExec(), {0, 0}, {dims[b], dims[c]}),
133 KOKKOS_LAMBDA(int p0, int p1) {
134 const long base = static_cast<long>(p0) * sb + static_cast<long>(p1) * sc;
135 const double v = prof(static_cast<long>(p0) * nc + p1);
136 for (int k = 0; k < g; ++k)
137 f(base + static_cast<long>(lo + k) * sa) = v;
138 });
139 Kokkos::fence();
140}
141
152inline void bcColourBackflow(SField f, I3 e, int g, int a, int s, SField un, double backflow) {
153 int dims[3];
154 long strides[3];
156 const int b = (a + 1) % 3, c = (a + 2) % 3;
157 const long sa = strides[a], sb = strides[b], sc = strides[c];
158 const int na = dims[a];
159 const int lo = (s == 0) ? 0 : (na - g);
160 const int fa = (s == 0) ? (g - 1) : (na - g - 1); // a-index of the cell owning the boundary face
161 const double sgn = (s == 0) ? 1.0 : -1.0; // sign of an INWARD normal velocity
162 Kokkos::parallel_for(
163 "vof::bcColourBackflow", MDRange2<SExec>(SExec(), {0, 0}, {dims[b], dims[c]}),
164 KOKKOS_LAMBDA(int p0, int p1) {
165 const long base = static_cast<long>(p0) * sb + static_cast<long>(p1) * sc;
166 if (sgn * un(base + static_cast<long>(fa) * sa) <= 0.0)
167 return; // leaving (or exactly zero): keep the zero-gradient band
168 for (int k = 0; k < g; ++k)
169 f(base + static_cast<long>(lo + k) * sa) = backflow;
170 });
171 Kokkos::fence();
172}
173
174} // namespace peclet::flow::vof
175
176#endif // PECLET_FLOW_VOF_COLOUR_BC_HPP
flow — VoF rung V1: Weymouth & Yue (2010) directionally-split, exactly volume-conserving geometric ad...
flow — portable (Kokkos) MAC stencil operators: Red-Black Gauss-Seidel smoothers + divergence.
void axisDims(I3 e, int(&dims)[3], long(&strides)[3])
Definition colour_bc.hpp:68
void bcColourBackflow(SField f, I3 e, int g, int a, int s, SField un, double backflow)
inletOutlet on an outflow face: where the boundary face velocity points INTO the domain,...
void bcColourConst(SField f, I3 e, int g, int a, int s, double value)
Overwrite ALL g ghost layers of domain face (axis a, side s) with a constant colour.
void bcColourProfile(SField f, I3 e, int g, int a, int s, SField prof, int nc)
Same, with a per-position colour on the face's (b, c) plane.
void buildOutsideMask(UCField m, I3 e, int g, I3 o, I3 gs, bool px, bool py, bool pz)
1 for every ghost cell of the block that lies OUTSIDE the global domain on a non-periodic axis,...
Definition colour_bc.hpp:84
Kokkos::View< unsigned char *, SMem > UCField
Definition advect_wy.hpp:89
long L3(int x, int y, int z, I3 e)
Kokkos::DefaultExecutionSpace SExec
Kokkos::View< double *, SMem > SField
Definition prof.py:1
flow — the multidimensional iteration policies: iteration order follows storage.