flow 1.4.0
Kokkos cut-cell IBM incompressible Navier-Stokes solver + pnm pore extraction
Loading...
Searching...
No Matches
flow_bindings_sharp_viscous.hpp
Go to the documentation of this file.
1
9#pragma once
10
12
13namespace peclet::flow::bindings {
14
16template <class Grid, class C>
17inline void bindSolverSharpViscous(C& cls) {
18 using S = BoundSolver<Grid>;
19 cls.def("set_vof_viscous_interface", &S::setVofViscousInterface, nb::arg("mode"),
20 "The viscous stress at the VoF interface (doc/vof_sharp_viscous_stress.md): 'auto' "
21 "(default), 'sharp' or 'averaged'. 'averaged' = the cell mu(C) and the 4-cell mean on "
22 "the MAC edges, first order across an oblique interface (the operator before the "
23 "sharp interface; it reproduces earlier numbers bitwise). 'sharp' = on every band edge "
24 "the row's own PLIC face-fraction viscosity (implicit band and explicit transpose), a "
25 "per-link interface-traction correction from a kinked least-squares fit of the "
26 "interface state, and the cell midsection force of the normal-stress jump 2[mu]D_nn "
27 "(explicit on u^n): second order. 'auto' resolves at each step to 'sharp' when VoF is "
28 "on, mu = LinearMix(C) (set_property_model('mu', 'linear', 'C', ...)) varies and the "
29 "full viscous stress is active (set_viscous_stress), with no immersed solid, porous "
30 "momentum, moving scene instances or phase change; else to 'averaged' with a one-time "
31 "stderr notice. SolverColocated always resolves 'auto' to 'averaged' and raises on "
32 "'sharp'. An explicit 'sharp' raises at step() outside that scope and with the "
33 "harmonic face viscosity. Inert for a constant mu. A cell is interfacial iff eps < C "
34 "< 1 - eps with eps = diagnostics.vof_interface_eps() (the wisp guard, default 1e-8). "
35 "Read-outs: diagnostics.vof_viscous_interface_census() / vof_viscous_interface_fit(). "
36 "Any other mode raises ValueError.");
37 cls.def("vof_viscous_interface", &S::vofViscousInterface,
38 "The selected VoF viscous interface mode, 'auto', 'sharp' or 'averaged' (see "
39 "set_vof_viscous_interface; what 'auto' resolved to shows in "
40 "diagnostics.vof_viscous_interface_census()).");
41}
42
44template <class Grid, class C>
45inline void bindDiagnosticsSharpViscous(C& cls) {
46 using D = Diagnostics<Grid>;
47 cls.def(
48 "vof_viscous_interface_census",
49 [](D& diag) {
50 const auto c = diag.s->vofViscousInterfaceCensus();
51 nb::dict d;
52 d["band_cells"] = c.band;
53 d["virtual_cells"] = c.virt;
54 d["film_cells"] = c.film;
55 d["fit_fallbacks"] = c.fallback;
56 d["tied_edges"] = c.tied;
57 d["max_tie_spread"] = c.tieSpread;
58 d["min_untied_gap"] = c.untiedGap;
59 d["blended_edges"] = c.blended;
60 return d;
61 },
62 "The sharp interface band of the last step, LOCAL to this rank (sum over ranks "
63 "yourself): 'band_cells' (interfacial cells, PLIC and virtual planes), "
64 "'virtual_cells' (pure cells carrying a face plane), 'film_cells' (virtual cells "
65 "whose two neighbours along the plane axis are both of the other phase) and "
66 "'fit_fallbacks' (cells whose interface fit was singular: tau = D_nn = 0, first order "
67 "locally). The edge-owner ties (§5.8; every in-domain edge of the owned cells, an edge "
68 "on a non-periodic high domain face not counted): 'tied_edges' (band edges whose owner "
69 "set's plateau, the candidates within 1e-6 cells of the closest plane, has two or more "
70 "members), 'max_tie_spread' (the largest distance spread within a plateau, index "
71 "units; 0.0 if none), 'min_untied_gap' (the smallest distance from the closest plane "
72 "to a candidate outside the plateau; inf if none) and 'blended_edges' (band edges with "
73 "a candidate on the owner-weight ramp, 1e-6 to 1e-5 cells beyond the closest, which "
74 "enters the edge's weighted mean with a partial weight) -- INFO, not a defect signal; "
75 "take max/min over ranks yourself. All zero (gap inf) while the sharp interface is "
76 "inactive.");
77 cls.def(
78 "vof_viscous_interface_fit",
79 [](D& diag) {
80 auto f = diag.s->vofViscousInterfaceFit();
81 const char* key[5] = {"tau_x", "tau_y", "tau_z", "dnn", "fallback"};
82 nb::dict d;
83 for (int k = 0; k < 5; ++k)
84 if (!f[k].empty())
85 d[key[k]] = field_out(*diag.s, std::move(f[k]));
86 return d;
87 },
88 "The sharp interface fit of the last step (doc/vof_sharp_viscous_stress.md §5.3), "
89 "LOCAL to this rank, as (nx, ny, nz) arrays: 'tau_x', 'tau_y', 'tau_z' (the interface "
90 "traction tau_hat) and 'dnn' (D_nn_hat), both in internal units, zero off the band, "
91 "and 'fallback' (1 where the fit was singular). Empty while the sharp interface is "
92 "inactive. A read-out for verification; it changes nothing.");
93}
94
95} // namespace peclet::flow::bindings
Shared helpers of the peclet.flow Python binding: array conversion, the string-enum tables,...
void bindDiagnosticsSharpViscous(C &cls)
SolverDiagnostics (and its collocated twin): sharp viscous interface census and fit.
void bindSolverSharpViscous(C &cls)
Solver (and its collocated twin): sharp viscous interface setter and read-out.
nb::ndarray< nb::numpy, double > field_out(S &s, std::vector< double > &&v)
The developer tier: a view onto one Solver<Grid> (no state of its own).