include/pops/runtime/program/program_context.hpp Source File

adc_cpp: include/pops/runtime/program/program_context.hpp Source File
adc_cpp 0.3.0
Model-free C++23 core for coupled hyperbolic-elliptic systems on adaptive (AMR) meshes, with MPI and GPU (Kokkos) backends
program_context.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <chrono>
4#include <cstdint>
5#include <functional>
6#include <optional>
7#include <stdexcept>
8#include <string>
9#include <utility>
10
11#include <pops/core/foundation/types.hpp> // Real, POPS_HD
12#include <pops/runtime/program/profiler.hpp> // Profiler / ProfileScope (per-node timing, ADC-459)
13#include <pops/coupling/schur/core/schur_condensation.hpp> // SchurOperatorCoeffKernel / SchurExplicitFluxKernel (native coeff assembly, ADC-421)
14#include <pops/mesh/boundary/physical_bc.hpp> // fill_ghosts (periodic / physical halo exchange)
15#include <pops/mesh/execution/for_each.hpp> // for_each_cell (per-cell coeff / reconstruct kernels + negated divergence copy)
16#include <pops/mesh/geometry/geometry.hpp> // Geometry (mesh metric of the Laplacian / gradient)
17#include <pops/mesh/storage/fab2d.hpp> // Array4 / ConstArray4 (per-cell handles)
18#include <pops/mesh/storage/mf_arith.hpp> // saxpy (linear combine over a MultiFab)
19#include <pops/mesh/storage/multifab.hpp> // MultiFab
20#include <pops/numerics/elliptic/interface/elliptic_problem.hpp> // field_postprocess (centered gradient)
21#include <pops/numerics/elliptic/mg/geometric_mg.hpp> // GeometricMG (the wired V-cycle, reused as a precond, ADC-516)
22#include <pops/numerics/elliptic/poisson/poisson_operator.hpp> // apply_laplacian (shared 5-point matvec)
23#include <pops/numerics/linalg/lorentz_eliminator.hpp> // LorentzEliminator (closed B^{-1}, ADC-421 reconstruct)
24#include <pops/runtime/config/runtime_params.hpp> // RuntimeParams (compiled-Program runtime params, ADC-510)
25#include <pops/runtime/context/grid_context.hpp> // GridContext (System aux seam)
26#include <pops/runtime/program/cache_manager.hpp> // CacheManager (held-node value cache, ADC-458)
27#include <pops/runtime/system.hpp> // System (the runtime this facade forwards to)
28
51namespace pops {
52namespace runtime {
53namespace program {
54
55namespace detail {
56
64
74 int c_rho, c_bz;
75 POPS_HD void operator()(int i, int j) const {
76 const Real rho = s(i, j, c_rho);
77 const LorentzEliminator le(th_dt, Real(1), aux(i, j, c_bz));
78 const Real cr = c * rho; // c rho: common factor of the 4 entries of A - I
79 ex(i, j, 0) = Real(1) + cr * le.binv_11();
80 ey(i, j, 0) = Real(1) + cr * le.binv_22();
81 axy(i, j, 0) = cr * le.binv_12();
82 ayx(i, j, 0) = cr * le.binv_21();
83 }
84};
85
92 int c_mx, c_my, c_bz;
93 POPS_HD void operator()(int i, int j) const {
94 const LorentzEliminator le(th_dt, Real(1), aux(i, j, c_bz));
95 Real Fx, Fy;
96 le.apply_Binv(s(i, j, c_mx), s(i, j, c_my), Fx, Fy); // B^{-1} (mx, my) = rho*B^{-1}*v
97 out(i, j, 0) = Fx;
98 out(i, j, 1) = Fy;
99 }
100};
101
112 POPS_HD void operator()(int i, int j) const {
113 const Real divF =
114 (f(i + 1, j, 0) - f(i - 1, j, 0)) * half_idx + (f(i, j + 1, 1) - f(i, j - 1, 1)) * half_idy;
115 rhs(i, j, 0) = neg_lap(i, j, 0) - g * divF;
116 }
117};
118
129 POPS_HD void operator()(int i, int j) const {
130 const Real rho = st(i, j, c_rho);
131 const Real inv_rho = rho != Real(0) ? Real(1) / rho : Real(0);
132 const Real vx = st(i, j, c_mx) * inv_rho; // v^n = (mx, my)/rho
133 const Real vy = st(i, j, c_my) * inv_rho;
134 const Real gx = (phi(i + 1, j, 0) - phi(i - 1, j, 0)) * half_idx; // d_x phi^{n+theta}
135 const Real gy = (phi(i, j + 1, 0) - phi(i, j - 1, 0)) * half_idy;
136 const LorentzEliminator le(th_dt, Real(1), aux(i, j, c_bz));
137 Real nx, ny;
138 le.apply_Binv(vx - th_dt * gx, vy - th_dt * gy, nx, ny); // B^{-1}(v^n - theta dt grad phi)
139 st(i, j, c_mx) = rho * nx;
140 st(i, j, c_my) = rho * ny;
141 }
142};
143
154 POPS_HD void operator()(int i, int j) const {
155 const Real rho = st(i, j, c_rho);
156 const Real inv_rho = rho != Real(0) ? Real(1) / rho : Real(0);
157 const Real vx_new = st(i, j, c_mx) * inv_rho;
158 const Real vy_new = st(i, j, c_my) * inv_rho;
159 const Real vx_old = st_old(i, j, c_mx) * inv_rho; // rho frozen: rho^n == rho^{n+1}
160 const Real vy_old = st_old(i, j, c_my) * inv_rho;
161 const Real ke_new = Real(0.5) * rho * (vx_new * vx_new + vy_new * vy_new);
162 const Real ke_old = Real(0.5) * rho * (vx_old * vx_old + vy_old * vy_old);
163 st(i, j, c_E) += ke_new - ke_old;
164 }
165};
166
167} // namespace detail
168
170 public:
171 explicit ProgramContext(System* sys) : sys_(sys) {}
173 explicit ProgramContext(void* sys) : sys_(static_cast<System*>(sys)) {}
174
177 void install(std::function<void(double)> step) const {
178 sys_->install_program_step(std::move(step));
179 }
180
187 int sys_block(int b) const {
188 const std::vector<int>& m = sys_->program_block_map();
189 return (b >= 0 && b < static_cast<int>(m.size())) ? m[static_cast<std::size_t>(b)] : b;
190 }
191
192 void solve_fields() const {
193 // No count_kernel() here: this forwards to the PUBLIC System::solve_fields() -> Impl::solve_fields(),
194 // which already counts the kernel. (The from_state/from_blocks/named seams below DO count, because
195 // their Impl paths do not.) Counting here too would double-count this one op.
196 sys_->solve_fields();
197 }
203 void solve_fields_from_state(int b, MultiFab& u_stage) const {
204 count_kernel();
205 sys_->solve_fields_from_state(sys_block(b), u_stage);
206 }
213 void solve_fields_from_state(const std::string& field, int b, MultiFab& u_stage) const {
214 count_kernel();
215 sys_->solve_fields_from_state(field, sys_block(b), u_stage);
216 }
225 void solve_fields_from_blocks(const std::vector<const MultiFab*>& u_stages) const {
226 count_kernel();
227 // The codegen builds @p u_stages indexed BY PROGRAM block index (a stage state slotted at its own
228 // Program index, the rest nullptr). The System solver expects it indexed by SYSTEM block index, so
229 // re-slot each Program entry p at its name-matched System index sys_block(p) (Spec 3 criterion 23,
230 // ADC-457). Identity map -> the vector is copied unchanged (order-matching Program, byte-identical).
231 const std::vector<int>& m = sys_->program_block_map();
232 if (m.empty()) {
233 sys_->solve_fields_from_blocks(u_stages);
234 return;
235 }
236 std::vector<const MultiFab*> remapped(static_cast<std::size_t>(sys_->n_blocks()), nullptr);
237 // Iterate the PROGRAM block indices [0, m.size()) -- NOT u_stages.size(), which is the larger
238 // SYSTEM block count. The codegen sizes u_stages to ctx.n_blocks() but only fills Program slots
239 // [0, n_program_blocks); when the System has MORE blocks than the Program declares (a subset
240 // install), walking the System-sized range would re-map the nullptr padding through the identity
241 // fallthrough and clobber real entries. m[p] is Program block p's System index (install-validated
242 // in range); the unlisted System slots stay nullptr = their live state.
243 for (std::size_t p = 0; p < m.size(); ++p)
244 remapped[static_cast<std::size_t>(m[p])] = u_stages[p];
245 sys_->solve_fields_from_blocks(remapped);
246 }
247 int n_blocks() const { return sys_->n_blocks(); }
248 MultiFab& state(int b) const { return sys_->block_state(sys_block(b)); }
249 void rhs_into(int b, MultiFab& u, MultiFab& r) const {
250 count_kernel();
251 sys_->block_rhs_into(sys_block(b), u, r);
252 }
253
261 void neg_div_flux_default_into(int b, MultiFab& u, MultiFab& r) const {
262 count_kernel();
263 sys_->block_neg_div_flux_into(sys_block(b), u, r);
264 }
265
273 void source_default_into(int b, MultiFab& u, MultiFab& r) const {
274 count_kernel();
275 sys_->block_source_into(sys_block(b), u, r);
276 }
277
281 Real hmin() const { return sys_->cfl_min_dx(); }
282
288 Real max_wave_speed(int b, const MultiFab& u) const {
289 return sys_->block_max_speed(sys_block(b), u);
290 }
291
296 MultiFab& aux() const { return *sys_->grid_context().aux; }
297
303 MultiFab alloc_scalar_field(int n_comp = 1, int n_ghost = 1) const {
304 return sys_->alloc_scalar_field(n_comp, n_ghost);
305 }
306
310 Geometry geom() const { return sys_->grid_context().geom; }
311
318 void laplacian(MultiFab& out, MultiFab& in) const {
319 count_kernel();
320 const GridContext gc = sys_->grid_context();
321 fill_ghosts(in, gc.geom.domain, gc.bc);
322 apply_laplacian(in, gc.geom, out); // all optional pointers null -> bare 5-point Laplacian
323 }
324
329 void gradient(MultiFab& out, MultiFab& phi) const {
330 count_kernel();
331 const GridContext gc = sys_->grid_context();
332 fill_ghosts(phi, gc.geom.domain, gc.bc);
333 const Real cx = Real(1) / (Real(2) * gc.geom.dx());
334 const Real cy = Real(1) / (Real(2) * gc.geom.dy());
336 }
337
348 void divergence(MultiFab& out, MultiFab& fx, MultiFab& fy) const {
349 count_kernel();
350 const GridContext gc = sys_->grid_context();
351 fill_ghosts(fx, gc.geom.domain, gc.bc);
352 if (&fy != &fx)
353 fill_ghosts(fy, gc.geom.domain, gc.bc); // skip the redundant halo fill when fy aliases fx
354 apply_divergence(fx, fy, gc.geom, out, /*cx=*/0, /*cy=*/1);
355 }
356
375 void geometric_mg_precond_apply(MultiFab& out, const MultiFab& in) const {
376 count_kernel();
377 if (!mg_precond_) {
378 // Build once, on the System mesh: a scratch scalar field exposes block 0's BoxArray /
379 // DistributionMapping (the same the Krylov solve allocates its r/p/Ap from), and grid_context()
380 // gives the geometry + transport BC. The default V-cycle parameters (nu1=nu2=2, nbottom=50) match
381 // the field-solve GeometricMG.
382 const GridContext gc = sys_->grid_context();
383 const MultiFab tmpl = sys_->alloc_scalar_field(1, 1);
384 mg_precond_.emplace(gc.geom, tmpl.box_array(), gc.bc);
385 }
386 GeometricMG& mg = *mg_precond_;
387 // rhs <- in (the vector to precondition); phi <- 0 (a fixed-linear cycle starts cold).
388 lincomb(mg.rhs(), Real(1), in, Real(0), in);
389 mg.phi().set_val(Real(0));
390 mg.vcycle(); // ONE V-cycle: out ~= L^{-1} in (fixed linear M^{-1})
391 lincomb(out, Real(1), mg.phi(), Real(0), out); // out <- phi
392 }
393
402
412 void assemble_schur_coeffs(MultiFab& eps_x, MultiFab& eps_y, MultiFab& a_xy, MultiFab& a_yx,
413 const MultiFab& state, Real c, Real th_dt, int c_rho, int c_bz) const {
414 count_kernel();
415 const GridContext gc = sys_->grid_context();
416 const MultiFab& aux = *sys_->grid_context().aux;
417 for (int li = 0; li < eps_x.local_size(); ++li) {
418 const ConstArray4 s = state.fab(li).const_array();
419 const ConstArray4 b = aux.fab(li).const_array();
420 for_each_cell(eps_x.box(li),
421 detail::SchurOperatorCoeffKernelC{s, b, eps_x.fab(li).array(),
422 eps_y.fab(li).array(), a_xy.fab(li).array(),
423 a_yx.fab(li).array(), c, th_dt, c_rho, c_bz});
424 }
425 const BCRec ebc = coeff_bc(gc.bc);
426 fill_ghosts(eps_x, gc.geom.domain, ebc);
427 fill_ghosts(eps_y, gc.geom.domain, ebc);
428 fill_ghosts(a_xy, gc.geom.domain, ebc);
429 fill_ghosts(a_yx, gc.geom.domain, ebc);
430 }
431
439 void apply_laplacian_coeff(MultiFab& out, MultiFab& in, const MultiFab& eps_x,
440 const MultiFab& eps_y, const MultiFab& a_xy,
441 const MultiFab& a_yx) const {
442 count_kernel();
443 const GridContext gc = sys_->grid_context();
444 fill_ghosts(in, gc.geom.domain, gc.bc);
445 apply_laplacian(in, gc.geom, out, /*coef=*/nullptr, /*eps=*/&eps_x, /*kappa=*/nullptr,
446 /*eps_y=*/&eps_y, /*a_xy=*/&a_xy, /*a_yx=*/&a_yx);
447 }
448
455 void schur_explicit_flux(MultiFab& out, const MultiFab& state, Real th_dt, int c_mx, int c_my,
456 int c_bz) const {
457 count_kernel();
458 const GridContext gc = sys_->grid_context();
459 const MultiFab& aux = *sys_->grid_context().aux;
460 for (int li = 0; li < out.local_size(); ++li) {
461 const ConstArray4 s = state.fab(li).const_array();
462 const ConstArray4 b = aux.fab(li).const_array();
463 Array4 o = out.fab(li).array();
464 for_each_cell(out.box(li),
465 detail::SchurExplicitFluxKernelC{s, b, o, th_dt, c_mx, c_my, c_bz});
466 }
467 const BCRec ebc = coeff_bc(gc.bc);
468 fill_ghosts(out, gc.geom.domain, ebc);
469 }
470
479 void assemble_schur_rhs(MultiFab& rhs, MultiFab& phi_n, const MultiFab& state, Real th_dt, Real g,
480 int c_mx, int c_my, int c_bz) const {
481 count_kernel();
482 const GridContext gc = sys_->grid_context();
483 const MultiFab& aux = *sys_->grid_context().aux;
484 const BoxArray& ba = rhs.box_array();
485 const DistributionMapping& dm = rhs.dmap();
486 // 1) -Lap phi^n (bare 5-point Laplacian of the warm-started potential, negated).
487 fill_ghosts(phi_n, gc.geom.domain, gc.bc);
488 MultiFab lap(ba, dm, 1, 0);
489 apply_laplacian(phi_n, gc.geom, lap);
490 MultiFab neg_lap(ba, dm, 1, 0);
491 for (int li = 0; li < neg_lap.local_size(); ++li)
492 for_each_cell(neg_lap.box(li),
493 pops::detail::NegateKernel{lap.fab(li).const_array(), neg_lap.fab(li).array()});
494 // 2) explicit flux F = B^{-1}(mx, my) at the center (1 ghost for the centered divergence).
495 MultiFab fx(ba, dm, 2, 1);
496 for (int li = 0; li < state.local_size(); ++li) {
497 const ConstArray4 s = state.fab(li).const_array();
498 const ConstArray4 b = aux.fab(li).const_array();
499 for_each_cell(fx.box(li), detail::SchurExplicitFluxKernelC{s, b, fx.fab(li).array(), th_dt,
500 c_mx, c_my, c_bz});
501 }
502 const BCRec ebc = coeff_bc(gc.bc);
503 fill_ghosts(fx, gc.geom.domain, ebc);
504 // 3) rhs = -Lap phi^n - g*div(F) (centered FV divergence; Fx in comp 0, Fy in comp 1 of fx).
505 const Real half_idx = Real(1) / (Real(2) * gc.geom.dx());
506 const Real half_idy = Real(1) / (Real(2) * gc.geom.dy());
507 for (int li = 0; li < rhs.local_size(); ++li)
509 neg_lap.fab(li).const_array(), fx.fab(li).const_array(),
510 rhs.fab(li).array(), g, half_idx, half_idy});
511 }
512
518 void schur_reconstruct(MultiFab& state, MultiFab& phi, Real th_dt, int c_rho, int c_mx, int c_my,
519 int c_bz) const {
520 count_kernel();
521 const GridContext gc = sys_->grid_context();
522 const MultiFab& aux = *sys_->grid_context().aux;
523 fill_ghosts(phi, gc.geom.domain, gc.bc);
524 const Real half_idx = Real(1) / (Real(2) * gc.geom.dx());
525 const Real half_idy = Real(1) / (Real(2) * gc.geom.dy());
526 for (int li = 0; li < state.local_size(); ++li) {
527 const ConstArray4 ph = phi.fab(li).const_array();
528 const ConstArray4 b = aux.fab(li).const_array();
529 Array4 st = state.fab(li).array();
531 detail::SchurReconstructKernelC{ph, b, st, th_dt, half_idx, half_idy, c_rho,
532 c_mx, c_my, c_bz});
533 }
534 }
535
541 void schur_energy(MultiFab& state, const MultiFab& state_old, int c_rho, int c_mx, int c_my,
542 int c_E) const {
543 count_kernel();
544 for (int li = 0; li < state.local_size(); ++li) {
545 Array4 st = state.fab(li).array();
546 const ConstArray4 so = state_old.fab(li).const_array();
547 for_each_cell(state.box(li), detail::SchurEnergyKernelC{st, so, c_rho, c_mx, c_my, c_E});
548 }
549 }
560 void neg_div_flux_into(MultiFab& r, MultiFab& fx, MultiFab& fy) const {
561 count_kernel();
562 const GridContext gc = sys_->grid_context();
563 fill_ghosts(fx, gc.geom.domain, gc.bc);
564 fill_ghosts(fy, gc.geom.domain, gc.bc);
565 MultiFab divc(r.box_array(), r.dmap(), 1,
566 0); // 1-component divergence scratch (no ghosts needed)
567 for (int c = 0; c < r.ncomp(); ++c) {
568 apply_divergence(fx, fy, gc.geom, divc, /*cx=*/c, /*cy=*/c); // divc(.,0) = div(fx_c, fy_c)
569 for (int li = 0; li < r.local_size(); ++li) {
570 const ConstArray4 d = divc.fab(li).const_array();
571 Array4 rv = r.fab(li).array();
572 const int comp = c;
573 for_each_cell(r.box(li), [=] POPS_HD(int i, int j) { rv(i, j, comp) = -d(i, j, 0); });
574 }
575 }
576 }
577
583 MultiFab scratch(u.box_array(), u.dmap(), u.ncomp(), u.n_grow());
584 count_scratch(scratch);
585 return scratch;
586 }
587
592
594 void axpy(MultiFab& u, Real a, const MultiFab& r) const {
595 count_kernel();
596 pops::saxpy(u, a, r);
597 }
598
602 void lincomb(MultiFab& z, Real a, const MultiFab& x, Real b, const MultiFab& y) const {
603 count_kernel();
604 pops::lincomb(z, a, x, b, y);
605 }
606
612 void register_history(const std::string& name, int lag) const {
613 sys_->register_history(name, lag);
614 }
615
621 MultiFab& history(const std::string& name, int lag = 1) const {
622 sys_->register_history(name, lag); // idempotent: allocate the ring on first use
623 return sys_->read_history(name, lag);
624 }
625
630 void store_history(const std::string& name, const MultiFab& value) const {
631 sys_->register_history(name, 1); // idempotent: at least a current slot exists before the store
632 sys_->store_history(name, value);
633 }
634
638 void rotate_histories() const { sys_->rotate_histories(); }
639
646 Real sum_component(const MultiFab& u, int comp) const { return pops::reduce_sum(u, comp); }
647 Real max_component(const MultiFab& u, int comp) const { return pops::reduce_max(u, comp); }
648 Real min_component(const MultiFab& u, int comp) const { return pops::reduce_min(u, comp); }
649 Real sum(const MultiFab& u) const { return pops::reduce_sum(u, 0); }
650 Real max(const MultiFab& u) const { return pops::reduce_max(u, 0); }
651 Real min(const MultiFab& u) const { return pops::reduce_min(u, 0); }
653
657 void fill_boundary(MultiFab& x) const {
658 const GridContext gc = sys_->grid_context();
659 fill_ghosts(x, gc.geom.domain, gc.bc);
660 }
661
666 void apply_projection(int b, MultiFab& u) const { sys_->block_project(sys_block(b), u); }
667
673 void record_scalar(const std::string& name, Real value) const {
674 sys_->record_program_diagnostic(name, value);
675 }
676
687 RuntimeParams program_params(int b) const { return sys_->program_params(b); }
688
697 runtime::program::Profiler& profiler() const { return sys_->profiler(); }
702 runtime::program::ProfileScope profile_node(const std::string& name) const {
703 return runtime::program::ProfileScope(sys_->profiler(), name);
704 }
710 void profile_record(const std::string& name, std::chrono::steady_clock::time_point t0) const {
711 const auto t1 = std::chrono::steady_clock::now();
712 sys_->profiler().record(name, std::chrono::duration<double>(t1 - t0).count());
713 }
715
729 void count_kernel(std::int64_t by = 1) const { sys_->profiler().count("kernels", by); }
735 void count_scratch(const MultiFab& mf) const {
736 runtime::program::Profiler& prof = sys_->profiler();
737 if (!prof.enabled()) {
738 return; // skip the byte-summing loop entirely when profiling is off (zero hot-path cost)
739 }
740 prof.count("scratch_allocs");
741 std::int64_t bytes = 0;
742 for (int li = 0; li < mf.local_size(); ++li) {
743 bytes += mf.fab(li).size() * static_cast<std::int64_t>(sizeof(Real));
744 }
745 prof.count_max("scratch_peak_bytes", bytes);
746 }
748
767 bool cache_should_update(int node_id, int every_n) const {
768 const bool due = sys_->program_cache().is_due(node_id, sys_->macro_step(), every_n);
769 if (due) {
770 sys_->profiler().count("cache_misses");
771 sys_->profiler().count("nodes_due");
772 } else {
773 sys_->profiler().count("cache_hits");
774 sys_->profiler().count("nodes_skipped");
775 }
776 return due;
777 }
780 void cache_store_aux(int node_id) const {
781 sys_->program_cache().store(node_id, *sys_->grid_context().aux, sys_->macro_step());
782 }
784 void cache_restore_aux(int node_id) const {
785 *sys_->grid_context().aux = sys_->program_cache().retrieve(node_id);
786 }
787
792 void cache_store_scratch(int node_id, const MultiFab& scratch) const {
793 sys_->program_cache().store(node_id, scratch, sys_->macro_step());
794 }
796 void cache_restore_scratch(int node_id, MultiFab& scratch) const {
797 scratch = sys_->program_cache().retrieve(node_id);
798 }
801 int macro_step() const { return sys_->macro_step(); }
805 void cache_accumulate_dt(int node_id, Real dt) const {
806 sys_->program_cache().accumulate_dt(node_id, dt);
807 }
811 Real cache_effective_dt(int node_id, Real dt_now) const {
812 return sys_->program_cache().effective_dt(node_id, dt_now);
813 }
816 [[noreturn]] void scheduler_error(const std::string& what) const {
817 throw std::runtime_error("pops Program scheduler: " + what);
818 }
820
821 private:
825 static BCRec coeff_bc(const BCRec& bc) {
826 auto fo = [](BCType t) { return t == BCType::Periodic ? t : BCType::Foextrap; };
827 BCRec b;
828 b.xlo = fo(bc.xlo);
829 b.xhi = fo(bc.xhi);
830 b.ylo = fo(bc.ylo);
831 b.yhi = fo(bc.yhi);
832 return b;
833 }
834
835 System* sys_;
836
841 mutable std::optional<GeometricMG> mg_precond_;
842};
843
844} // namespace program
845} // namespace runtime
846} // namespace pops
Ordered list of boxes tiling a level.
Definition box_array.hpp:22
Owning MPI rank of each box, indexed by GLOBAL box index (parallel to a BoxArray).
Definition distribution_mapping.hpp:19
ConstArray4 const_array() const
READ handle (POD device-copyable) over this Fab. Valid as long as the Fab lives.
Definition fab2d.hpp:96
Array4 array()
WRITE handle (POD device-copyable) over this Fab. Valid as long as the Fab lives.
Definition fab2d.hpp:91
std::int64_t size() const
Buffer size (nx_tot * ny_tot * ncomp).
Definition fab2d.hpp:82
Definition geometric_mg.hpp:79
void vcycle()
Definition geometric_mg.hpp:389
MultiFab & rhs()
Definition geometric_mg.hpp:222
MultiFab & phi()
Definition geometric_mg.hpp:221
Field distributed over a level: decomposition (BoxArray) + distribution (DistributionMapping) + ncomp...
Definition multifab.hpp:33
Fab2D & fab(int li)
Local fab at index li (0 <= li < local_size()), for writing.
Definition multifab.hpp:67
int ncomp() const
Number of components.
Definition multifab.hpp:60
const DistributionMapping & dmap() const
GLOBAL distribution (owner rank per box).
Definition multifab.hpp:58
int n_grow() const
Number of ghost layers.
Definition multifab.hpp:62
const BoxArray & box_array() const
GLOBAL decomposition of the level (all boxes, all ranks).
Definition multifab.hpp:56
const Box2D & box(int li) const
VALID box of local fab li.
Definition multifab.hpp:71
void set_val(Real v)
Fills all cells (valid + ghosts) of every local fab with v.
Definition multifab.hpp:85
int local_size() const
Number of fabs OWNED by this rank (bound on local indices).
Definition multifab.hpp:65
Coupled multi-species system, composed at runtime from generic bricks.
Definition system.hpp:89
POPS_EXPORT Real cfl_min_dx() const
The MIN physical cell size of the grid (Cartesian min(dx, dy); polar min(dr, r_min*dtheta)) – the SAM...
POPS_EXPORT MultiFab & read_history(const std::string &name, int lag)
The history slot lag macro-steps back (lag 0 = the current slot, lag 1 = the previous step's stored v...
POPS_EXPORT void block_neg_div_flux_into(int b, MultiFab &U, MultiFab &R)
R <- -div F(U) for block b – the SAME flux divergence as block_rhs_into but WITHOUT the model's defau...
POPS_EXPORT RuntimeParams program_params(int prog_block) const
Block prog_block's CURRENT RuntimeParams (a device-clean by-value copy: trivially copyable,...
POPS_EXPORT int macro_step() const
MACRO-STEP counter (0-indexed; incremented by step / step_cfl / step_adaptive).
POPS_EXPORT int n_blocks() const
Number of blocks (species) installed.
POPS_EXPORT GridContext grid_context()
REAL mesh + BC + aux of the System (aux not owned)
POPS_EXPORT void block_source_into(int b, MultiFab &U, MultiFab &R)
R <- S(U, aux) for block b – the model's default/composite SOURCE only, WITHOUT the flux divergence (...
POPS_EXPORT MultiFab & block_state(int b)
The conservative state MultiFab of block b (zero-copy, non-owning reference).
POPS_EXPORT void solve_fields_from_state(int block_idx, const MultiFab &U_stage)
Per-stage field solve (ADC-409): SAME elliptic solve + aux derivation as solve_fields(),...
POPS_EXPORT runtime::program::CacheManager & program_cache()
POPS_EXPORT Real block_max_speed(int b, const MultiFab &U) const
The maximum |wave speed| of block b evaluated on U – the SAME per-block reduction step_cfl reads (Blo...
POPS_EXPORT void rotate_histories()
Shift every history ring buffer one step (slot k <- slot k-1, for k = depth-1 .
POPS_EXPORT void record_program_diagnostic(const std::string &name, Real value)
POPS_EXPORT void solve_fields()
solves Poisson then derives aux = (phi, grad phi); exported
POPS_EXPORT const std::vector< int > & program_block_map() const
The installed program-index -> system-index map (empty = identity). Read by ProgramContext.
POPS_EXPORT runtime::program::Profiler & profiler()
The System-owned Profiler (a non-owning reference; lives as long as the System).
POPS_EXPORT void block_rhs_into(int b, MultiFab &U, MultiFab &R)
R <- -div F(U) + S(U, aux) for block b (the block's frozen-Poisson residual closure).
POPS_EXPORT MultiFab & register_history(const std::string &name, int lag)
POPS_EXPORT MultiFab alloc_scalar_field(int n_comp, int n_ghost)
A fresh scalar field co-distributed with the System mesh: block 0's BoxArray and DistributionMapping,...
POPS_EXPORT void install_program_step(std::function< void(double)> step)
POPS_EXPORT void block_project(int b, MultiFab &u)
Apply block b's post-step positivity projection to u in place (ADC-177): U <- project(U,...
POPS_EXPORT void store_history(const std::string &name, const MultiFab &value)
Copy value (valid cells) into the CURRENT slot [0] of history name and mark it initialized.
POPS_EXPORT void solve_fields_from_blocks(const std::vector< const MultiFab * > &U_stages)
Coupled multi-block field solve (Spec 3 criterion 24, ADC-457): SAME elliptic solve + aux derivation ...
const MultiFab & retrieve(int node_id) const
Definition cache_manager.hpp:83
Real effective_dt(int node_id, Real dt_now)
Definition cache_manager.hpp:100
void store(int node_id, const MultiFab &value, int macro_step)
Definition cache_manager.hpp:65
bool is_due(int node_id, int macro_step, int every_n) const
Definition cache_manager.hpp:52
void accumulate_dt(int node_id, Real dt)
Definition cache_manager.hpp:88
Definition profiler.hpp:151
Definition profiler.hpp:27
void record(const std::string &name, double seconds)
Definition profiler.hpp:50
void count(const std::string &name, std::int64_t by=1)
Definition profiler.hpp:69
void count_max(const std::string &name, std::int64_t value)
Definition profiler.hpp:85
bool enabled() const
Definition profiler.hpp:39
Definition program_context.hpp:169
void record_scalar(const std::string &name, Real value) const
Store a runtime Scalar value into the System diagnostics map under name (spec op 23),...
Definition program_context.hpp:673
void store_history(const std::string &name, const MultiFab &value) const
Store value into the CURRENT slot of history name (ADC-406a).
Definition program_context.hpp:630
void count_scratch(const MultiFab &mf) const
Record one scratch MultiFab allocation: bumps the allocation count and updates the byte peak with THI...
Definition program_context.hpp:735
void count_kernel(std::int64_t by=1) const
Definition program_context.hpp:729
bool cache_should_update(int node_id, int every_n) const
Definition program_context.hpp:767
MultiFab & state(int b) const
Definition program_context.hpp:248
void cache_restore_aux(int node_id) const
Restore node node_id's cached aux into the System aux (a held step: no elliptic solve).
Definition program_context.hpp:784
Real cache_effective_dt(int node_id, Real dt_now) const
The effective dt a due accumulate_dt step applies: dt_now plus the summed skipped dt since the last r...
Definition program_context.hpp:811
Real hmin() const
The MIN physical cell size of the grid (Cartesian min(dx, dy); polar min(dr, r_min*dtheta)) – the SAM...
Definition program_context.hpp:281
void source_default_into(int b, MultiFab &u, MultiFab &r) const
r <- S(u, aux) for block b – the model's default/composite SOURCE only, WITHOUT the flux divergence (...
Definition program_context.hpp:273
MultiFab alloc_scalar_field(int n_comp=1, int n_ghost=1) const
A fresh scalar field co-distributed with the System mesh (block 0's box array / distribution),...
Definition program_context.hpp:303
void apply_projection(int b, MultiFab &u) const
Apply block b's post-step positivity projection to u in place: U <- project(U, aux) over the valid ce...
Definition program_context.hpp:666
MultiFab & history(const std::string &name, int lag=1) const
The history slot lag macro-steps back (the SYSTEM-OWNED ring buffer, ADC-406a): lag 1 = the previous ...
Definition program_context.hpp:621
MultiFab rhs_scratch_like(const MultiFab &u) const
A zero-initialized RHS scratch with the SAME layout (box array / distribution / ghosts) as u,...
Definition program_context.hpp:582
void solve_fields_from_state(int b, MultiFab &u_stage) const
Per-stage field solve (ADC-409): re-solve the elliptic fields and re-fill the shared aux from block b...
Definition program_context.hpp:203
runtime::program::Profiler & profiler() const
Definition program_context.hpp:697
void solve_fields_from_blocks(const std::vector< const MultiFab * > &u_stages) const
Coupled multi-block field solve (Spec 3 criterion 24, ADC-457): re-solve the elliptic fields and re-f...
Definition program_context.hpp:225
void apply_laplacian_coeff(MultiFab &out, MultiFab &in, const MultiFab &eps_x, const MultiFab &eps_y, const MultiFab &a_xy, const MultiFab &a_yx) const
out = div(A grad in), A = [[eps_x, a_xy], [a_yx, eps_y]] – the coefficiented matrix-free matvec of th...
Definition program_context.hpp:439
void schur_energy(MultiFab &state, const MultiFab &state_old, int c_rho, int c_mx, int c_my, int c_E) const
Condensed-Schur kinetic-energy increment (ADC-427): E^{n+1} = E^n + (1/2)*rho*(|v^{n+1}|^2 - |v^n|^2)...
Definition program_context.hpp:541
void laplacian(MultiFab &out, MultiFab &in) const
out = Lap(in): fill in's ghosts (transport BC, periodic by default) then apply the SHARED discrete 5-...
Definition program_context.hpp:318
void cache_store_aux(int node_id) const
Store a copy of the System aux (the field solve's output) as node node_id's cached value,...
Definition program_context.hpp:780
void schur_reconstruct(MultiFab &state, MultiFab &phi, Real th_dt, int c_rho, int c_mx, int c_my, int c_bz) const
Reconstruct v^{n+theta} = B^{-1}(v^n - theta*dt*grad phi^{n+theta}) and write mom = rho^n*v into stat...
Definition program_context.hpp:518
int n_blocks() const
Definition program_context.hpp:247
Real max(const MultiFab &u) const
Definition program_context.hpp:650
int macro_step() const
The current macro step (0-based).
Definition program_context.hpp:801
void rotate_histories() const
Shift every history ring one macro-step (slot k <- slot k-1).
Definition program_context.hpp:638
Real max_wave_speed(int b, const MultiFab &u) const
The maximum |wave speed| of block b on the state u: the SAME per-block reduction step_cfl reads (Bloc...
Definition program_context.hpp:288
void solve_fields() const
Definition program_context.hpp:192
RuntimeParams program_params(int b) const
The CURRENT RuntimeParams of PROGRAM block b (epic ADC-479 / ADC-510, Spec 5 C5): the per-block runti...
Definition program_context.hpp:687
void solve_fields_from_state(const std::string &field, int b, MultiFab &u_stage) const
Named multi-elliptic field solve (ADC-428): re-solve the SECOND elliptic field field from block b's s...
Definition program_context.hpp:213
void neg_div_flux_default_into(int b, MultiFab &u, MultiFab &r) const
r <- -div F(u) for block b – the SAME flux divergence as rhs_into but WITHOUT the model's default/com...
Definition program_context.hpp:261
void rhs_into(int b, MultiFab &u, MultiFab &r) const
Definition program_context.hpp:249
void divergence(MultiFab &out, MultiFab &fx, MultiFab &fy) const
out = div(fx, fy) by centered differences: out = d fx/dx + d fy/dy (component 0).
Definition program_context.hpp:348
MultiFab scratch_state_like(const MultiFab &u) const
A zero-initialized scratch STATE with the same layout as u: an intermediate stage state of a multi-st...
Definition program_context.hpp:591
runtime::program::ProfileScope profile_node(const std::string &name) const
RAII timer for one node: pops::runtime::program::ProfileScope s = ctx.profile_node("node:x"); times i...
Definition program_context.hpp:702
void lincomb(MultiFab &z, Real a, const MultiFab &x, Real b, const MultiFab &y) const
z <- a x + b y over the valid cells (assignment, not accumulation; z may alias x or y).
Definition program_context.hpp:602
void gradient(MultiFab &out, MultiFab &phi) const
out = grad(phi) by centered differences: out(.,0) = d phi/dx, out(.,1) = d phi/dy (out needs >= 2 com...
Definition program_context.hpp:329
int sys_block(int b) const
Translate a PROGRAM block index b (P.state declaration order, what the codegen emits) to the SYSTEM b...
Definition program_context.hpp:187
void fill_boundary(MultiFab &x) const
Fill the ghost cells (halos) of x in place: the transport BC (periodic by default),...
Definition program_context.hpp:657
Real sum_component(const MultiFab &u, int comp) const
Definition program_context.hpp:646
void cache_store_scratch(int node_id, const MultiFab &scratch) const
Store a copy of a NAMED scratch MultiFab (a held rhs / source / linear_combine output) as node node_i...
Definition program_context.hpp:792
ProgramContext(System *sys)
Definition program_context.hpp:171
void cache_restore_scratch(int node_id, MultiFab &scratch) const
Restore node node_id's cached scratch into scratch (a held step: no recompute).
Definition program_context.hpp:796
MultiFab & aux() const
The System aux MultiFab (phi=0, grad_x=1, grad_y=2, B_z=3, T_e=4, named fields from kAuxNamedBase).
Definition program_context.hpp:296
void assemble_schur_rhs(MultiFab &rhs, MultiFab &phi_n, const MultiFab &state, Real th_dt, Real g, int c_mx, int c_my, int c_bz) const
rhs = -Lap(phi_n) - g*div(F), F = B^{-1}(mx, my) – the FUSED condensed-Schur right-hand side (the nat...
Definition program_context.hpp:479
Geometry geom() const
The System mesh geometry (index domain + physical bounds, dx/dy).
Definition program_context.hpp:310
ProgramContext(void *sys)
Wraps a System passed as a flat void* (what pops_install_program(void* sys) receives).
Definition program_context.hpp:173
Real min(const MultiFab &u) const
Definition program_context.hpp:651
void register_history(const std::string &name, int lag) const
Register (idempotent) the history name with maximum lag lag, allocating the ring buffer WITHOUT readi...
Definition program_context.hpp:612
void geometric_mg_precond_apply(MultiFab &out, const MultiFab &in) const
out <- M^{-1}(in): ONE geometric-multigrid V-cycle of the bare 5-point Laplacian, used as a matrix-fr...
Definition program_context.hpp:375
void install(std::function< void(double)> step) const
Register the macro-step body.
Definition program_context.hpp:177
void cache_accumulate_dt(int node_id, Real dt) const
Add a skipped step's dt to node node_id's accumulator (accumulate_dt policy): on a NOT-due step the h...
Definition program_context.hpp:805
void axpy(MultiFab &u, Real a, const MultiFab &r) const
u <- u + a r over the valid cells (linear combine; forwards to pops::saxpy).
Definition program_context.hpp:594
Real min_component(const MultiFab &u, int comp) const
Definition program_context.hpp:648
void assemble_schur_coeffs(MultiFab &eps_x, MultiFab &eps_y, MultiFab &a_xy, MultiFab &a_yx, const MultiFab &state, Real c, Real th_dt, int c_rho, int c_bz) const
Assemble the tensor coefficient A_op = I + c*rho*B^{-1} of the condensed-Schur operator per cell: eps...
Definition program_context.hpp:412
void profile_record(const std::string &name, std::chrono::steady_clock::time_point t0) const
Record one node's elapsed time (now() - t0) under name into the System Profiler.
Definition program_context.hpp:710
Real sum(const MultiFab &u) const
Definition program_context.hpp:649
void scheduler_error(const std::string &what) const
Fail loud: a node with an error policy was reached off its schedule cadence (a stale value would be r...
Definition program_context.hpp:816
Real max_component(const MultiFab &u, int comp) const
Definition program_context.hpp:647
void neg_div_flux_into(MultiFab &r, MultiFab &fx, MultiFab &fy) const
r <- -div(fx, fy) per conservative component (ADC-419 named fluxes): r(.,c) = -(d fx(....
Definition program_context.hpp:560
void schur_explicit_flux(MultiFab &out, const MultiFab &state, Real th_dt, int c_mx, int c_my, int c_bz) const
out = B^{-1} (mx, my) per cell – the EXPLICIT condensed-Schur flux F = rho*B^{-1}*v^n (= B^{-1} appli...
Definition program_context.hpp:455
DESCRIPTIVE types of the elliptic stage: EllipticProblem (problem definition) and FieldPostProcess (f...
Fab2D: single-grid data on a Box2D (in-house equivalent of AMReX's FArrayBox); Array4 / ConstArray4: ...
for_each_cell and reductions: the parallelism SEAM over the cells of a Box2D; sync_host / sync_device...
GeometricMG: in-house geometric multigrid (V-cycle) for the elliptic operator, Gauss-Seidel smoother ...
Geometry: index-space (Box2D) <-> Cartesian physical-space mapping; PolarGeometry: SIBLING for a glob...
Block grid context plus closures, shared between System (which installs them) and block_builder....
LorentzEliminator: 2x2 operator B of the Schur scheme for implicit velocity elimination.
MultiFab arithmetic (saxpy, lincomb, norm_inf, dot) over VALID cells.
MultiFab: a field DISTRIBUTED over a level (equivalent of AMReX's MultiFab).
Definition amr_hierarchy.hpp:29
void for_each_cell(const Box2D &b, F f)
Applies f to EACH cell (i, j) of box b (bounds inclusive), via Kokkos::parallel_for (Serial / OpenMP ...
Definition for_each.hpp:138
double Real
Definition types.hpp:30
void saxpy(MultiFab &y, Real a, const MultiFab &x)
y <- y + a x over ALL components of the valid cells. Identical layouts required.
Definition mf_arith.hpp:102
Real reduce_min(const MultiFab &mf, int comp=0)
Signed minimum min_cells f(.,.,comp) over component comp, reduced over ALL ranks (all_reduce_min) – t...
Definition mf_arith.hpp:223
void apply_laplacian(const MultiFab &phi, const Geometry &geom, MultiFab &lap, const MultiFab *coef=nullptr, const MultiFab *eps=nullptr, const MultiFab *kappa=nullptr, const MultiFab *eps_y=nullptr, const MultiFab *a_xy=nullptr, const MultiFab *a_yx=nullptr)
Definition poisson_operator.hpp:191
void lincomb(MultiFab &z, Real a, const MultiFab &x, Real b, const MultiFab &y)
z <- a x + b y over ALL components of the valid cells. Identical layouts; aliasing safe.
Definition mf_arith.hpp:133
void field_postprocess(const MultiFab &phi, MultiFab &out, Real cx, Real cy, FieldPostProcess spec)
Definition elliptic_problem.hpp:104
Real reduce_max(const MultiFab &mf, int comp=0)
Signed maximum max_cells f(.,.,comp) over component comp, reduced over ALL ranks (all_reduce_max) – t...
Definition mf_arith.hpp:211
Real reduce_sum(const MultiFab &mf, int comp=0)
Sum Sum_cells f(.,.,comp) over component comp, reduced over ALL ranks (all_reduce_sum) – the compiled...
Definition mf_arith.hpp:198
void apply_divergence(const MultiFab &fx, const MultiFab &fy, const Geometry &geom, MultiFab &div_out, int cx=0, int cy=0)
Definition poisson_operator.hpp:256
BCType
Boundary condition type for a face: Periodic (handled by fill_boundary), Foextrap (zero gradient,...
Definition physical_bc.hpp:25
void fill_ghosts(MultiFab &mf, const Box2D &domain, const BCRec &bc)
COMPLETE ghost filling: fill_boundary (interior + periodic, periodicity deduced from bc) THEN fill_ph...
Definition physical_bc.hpp:227
PHYSICAL boundary conditions at the domain edge (BCType, BCRec, fill_physical_bc, fill_ghosts).
Free functions of the elliptic operator: apply_laplacian (matvec), poisson_residual (residual),...
RuntimeParams: carrier for the RUNTIME PARAMETERS of a DSL model (P7-b).
BUILDER (NOT solver) of the Schur-condensed source stage of the implicit source coupling potential / ...
WRITE POD handle (raw pointer + strides) over a Fab2D buffer, indexed by (i, j, c) IN GLOBAL INDICES ...
Definition fab2d.hpp:29
Boundary conditions for the FOUR faces of the domain (type + associated Dirichlet value).
Definition physical_bc.hpp:29
BCType yhi
Definition physical_bc.hpp:31
BCType xlo
Definition physical_bc.hpp:30
BCType ylo
Definition physical_bc.hpp:31
BCType xhi
Definition physical_bc.hpp:30
READ-only handle (const counterpart of Array4): same layout and same contract (POD device-copyable,...
Definition fab2d.hpp:44
Definition elliptic_problem.hpp:73
Cartesian geometry of a level: index domain + physical bounds [xlo, xhi] x [ylo, yhi].
Definition geometry.hpp:20
POPS_HD Real dy() const
Grid spacing in y (= (yhi - ylo) / domain.ny()). POPS_HD.
Definition geometry.hpp:33
POPS_HD Real dx() const
Grid spacing in x (= (xhi - xlo) / domain.nx()). POPS_HD.
Definition geometry.hpp:31
Box2D domain
Definition geometry.hpp:21
Mesh + transport BC + aux shared by a block closures.
Definition grid_context.hpp:41
Geometry geom
geometry (dx, dy, bounds)
Definition grid_context.hpp:44
BCRec bc
transport BC
Definition grid_context.hpp:43
MultiFab * aux
System aux (phi, grad phi); NOT owned.
Definition grid_context.hpp:45
LorentzEliminator: operator B = [[1,-w],[w,1]] and its analytic inverse.
Definition lorentz_eliminator.hpp:55
POPS_HD Real binv_11() const
Definition lorentz_eliminator.hpp:81
POPS_HD Real binv_21() const
Definition lorentz_eliminator.hpp:83
POPS_HD Real binv_12() const
Definition lorentz_eliminator.hpp:82
POPS_HD void apply_Binv(Real vx, Real vy, Real &vxp, Real &vyp) const
apply_Binv: applies B^{-1} = (1/det)*[[1,w],[-w,1]] to (vx, vy), writes (vxp, vyp)....
Definition lorentz_eliminator.hpp:73
POPS_HD Real binv_22() const
Definition lorentz_eliminator.hpp:84
FLAT carrier (fixed size, by value) of the runtime parameter values of a block.
Definition runtime_params.hpp:38
neg(i,j) = -src(i,j) (negation of component 0). Device-clean NAMED functor.
Definition schur_condensation.hpp:126
Condensed-Schur kinetic-energy increment (ADC-427), mirroring the native detail::SchurEnergyKernel: E...
Definition program_context.hpp:150
int c_mx
Definition program_context.hpp:153
int c_E
Definition program_context.hpp:153
int c_rho
Definition program_context.hpp:153
ConstArray4 st_old
U^n (READ mx, my = mom^n)
Definition program_context.hpp:152
Array4 st
updated state (READ rho, mx, my = mom^{n+1}; READ+WRITE E)
Definition program_context.hpp:151
POPS_HD void operator()(int i, int j) const
Definition program_context.hpp:154
int c_my
Definition program_context.hpp:153
out = B^{-1} (mx, my) at the center (Fx in comp 0, Fy in comp 1): the explicit flux F = rho*B^{-1}*v.
Definition program_context.hpp:87
Array4 out
output: Fx (comp 0), Fy (comp 1)
Definition program_context.hpp:90
POPS_HD void operator()(int i, int j) const
Definition program_context.hpp:93
Real th_dt
theta*dt (w = th_dt*B_z)
Definition program_context.hpp:91
ConstArray4 s
fluid state (mx, my at c_mx / c_my)
Definition program_context.hpp:88
ConstArray4 aux
System aux (B_z at c_bz)
Definition program_context.hpp:89
Aux-component-aware variants of the native Schur kernels (coupling/schur/core/schur_condensation....
Definition program_context.hpp:67
Array4 ex
Definition program_context.hpp:70
Real th_dt
theta*dt (w = th_dt*B_z)
Definition program_context.hpp:73
Array4 axy
Definition program_context.hpp:71
ConstArray4 s
fluid state (rho at c_rho)
Definition program_context.hpp:68
POPS_HD void operator()(int i, int j) const
Definition program_context.hpp:75
Real c
c = theta^2 dt^2 alpha
Definition program_context.hpp:72
Array4 ayx
output: cross terms a_xy, a_yx
Definition program_context.hpp:71
ConstArray4 aux
System aux (B_z at c_bz)
Definition program_context.hpp:69
Array4 ey
output: eps_x, eps_y (diagonal of A)
Definition program_context.hpp:70
Reconstruct v^{n+theta} = B^{-1}(v^n - theta*dt*grad phi) and write mom = rho^n*v (rho frozen).
Definition program_context.hpp:122
Real half_idy
1/(2 dx), 1/(2 dy) (centered gradient)
Definition program_context.hpp:127
int c_my
Definition program_context.hpp:128
Real th_dt
Definition program_context.hpp:126
int c_rho
Definition program_context.hpp:128
ConstArray4 phi
phi^{n+theta} (ghosts filled: centered grad reads i+-1, j+-1)
Definition program_context.hpp:123
POPS_HD void operator()(int i, int j) const
Definition program_context.hpp:129
Real half_idx
Definition program_context.hpp:127
int c_mx
Definition program_context.hpp:128
Array4 st
fluid state (READ rho, mx, my; WRITE mx, my)
Definition program_context.hpp:125
int c_bz
Definition program_context.hpp:128
ConstArray4 aux
System aux (B_z at c_bz)
Definition program_context.hpp:124
rhs = -Lap phi^n - g*div(F), the centered FV divergence of the explicit flux F packed in ONE 2-compon...
Definition program_context.hpp:106
ConstArray4 neg_lap
-Lap phi^n (already negated)
Definition program_context.hpp:107
ConstArray4 f
explicit flux F at the center (Fx comp 0, Fy comp 1; ghosts filled)
Definition program_context.hpp:108
POPS_HD void operator()(int i, int j) const
Definition program_context.hpp:112
Real half_idx
Definition program_context.hpp:111
Array4 rhs
output: condensed right-hand side
Definition program_context.hpp:109
Real g
theta dt alpha
Definition program_context.hpp:110
Real half_idy
1/(2 dx), 1/(2 dy)
Definition program_context.hpp:111
Runtime multi-species composition: one coupled system, block by block.
Base scalar types and the POPS_HD macro (host+device portability).
#define POPS_HD
Definition types.hpp:25