16#include <Kokkos_Core.hpp>
20#include "peclet/core/common/types.hpp"
21#include "peclet/core/decomp/block_decomposer.hpp"
23using peclet::core::IVec;
26static constexpr int N = 32,
STEPS = 120;
27static constexpr double RHO = 1.0,
MU = 0.1,
F = 1e-3,
DT = 60.0;
32 const double R =
rfrac *
N;
33 std::vector<double> sdf((std::size_t)
N *
N *
N);
34 const double cs[2] = {0.25 *
N, 0.75 *
N};
35 for (
int z = 0; z <
N; ++z)
36 for (
int y = 0; y <
N; ++y)
37 for (
int x = 0; x <
N; ++x) {
41 for (
double sz : cs) {
42 auto wrap = [](
double d) {
return d -
N * std::round(d /
N); };
43 const double dx = wrap(x -
sx), dy = wrap(y - sy), dz = wrap(z - sz);
44 best = std::min(
best, std::sqrt(dx * dx + dy * dy + dz * dz) - R);
46 sdf[(std::size_t)x + (std::size_t)y *
N + (std::size_t)z *
N *
N] =
best;
74 Kokkos::initialize(
argc, argv);
75 int fail = 0, size = 1, rank = 0;
83 peclet::core::decomp::BlockDecomposer<3>
dec(
static_cast<std::size_t
>(size),
IVec<3>{
N,
N,
N});
84 auto blk =
dec.block(rank);
85 const int ox = (int)blk.origin[0], oy = (
int)blk.origin[1], oz = (int)blk.origin[2];
86 const int lnx = (int)blk.size[0],
lny = (
int)blk.size[1],
lnz = (int)blk.size[2];
88 for (
int z = 0; z <
lnz; ++z)
89 for (
int y = 0; y <
lny; ++y)
90 for (
int x = 0; x <
lnx; ++x)
91 lsdf[(std::size_t)x + (std::size_t)y *
lnx + (std::size_t)z *
lnx *
lny] =
92 gsdf[(std::size_t)(x + ox) + (std::size_t)(y + oy) *
N +
93 (std::size_t)(z + oz) *
N *
N];
99 for (
int it = 0; it <
STEPS; ++it)
111 ref.setSolid(
gsdf,
true);
112 for (
int it = 0; it <
STEPS; ++it)
116 auto u = ref.getVelocity(0);
126 (size == 1) ? 1e-12 : 2e-5;
128 std::printf(
" k_dist=%.8e k_ref=%.8e rel=%.2e div=%.2e (np=%d, tol %.0e)\n",
k_dist,
137 std::printf(
"OK (np=%d): distributed IbmSolver Stokes permeability == single-rank\n", size);
139 std::fprintf(
stderr,
"FAILED (np=%d)\n", size);
void setSolid(const std::vector< double > &sdfInner, bool cutcellPressure)
Host entry point: upload the inner SDF once and delegate.
double maxOpenDivergence()
void setAdvection(bool on)
void setVelocityIterations(int it)
void setPressureLevels(int levels)
void setBodyForce(double fx, double fy, double fz)
Body force per unit volume, in the caller's units (e.g. a mean pressure gradient, or rho*g).
std::vector< double > getVelocity(int c)
void setPressurePcg(bool on, int maxit, double rtol)
void setMu(double m)
Dynamic viscosity, in the caller's units.
void setRho(double r)
Fluid density, in the caller's units.
flow — host-facing Kokkos IBM Navier-Stokes solver (drop-in flow-style API).
static constexpr double RHO
static constexpr double MU
static double localUSum(IbmSolver &s)
static constexpr int STEPS
static constexpr double DT
static constexpr double F
static void configure(IbmSolver &s)
static std::vector< double > packingSdf(double rfrac=0.18)