include/pops/coupling/base/aux_fill.hpp Source FileΒΆ

adc_cpp: include/pops/coupling/base/aux_fill.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
aux_fill.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <pops/core/state/state.hpp> // kAuxBaseComps
4#include <pops/mesh/index/box2d.hpp> // Box2D
5#include <pops/mesh/storage/fab2d.hpp> // Fab2D
6#include <pops/mesh/geometry/geometry.hpp> // Geometry (x_cell / y_cell)
7#include <pops/mesh/boundary/physical_bc.hpp> // BCRec / BCType
8
20
21namespace pops {
22namespace detail {
23
27inline BCRec derive_aux_bc(const BCRec& b) {
28 auto t = [](BCType x) { return x == BCType::Periodic ? BCType::Periodic : BCType::Foextrap; };
29 BCRec a;
30 a.xlo = t(b.xlo);
31 a.xhi = t(b.xhi);
32 a.ylo = t(b.ylo);
33 a.yhi = t(b.yhi);
34 return a;
35}
36
41template <class Bz>
42inline void fill_bz_box(Fab2D& f, const Box2D& box, const Geometry& g, const Bz& bz) {
43 for (int j = box.lo[1]; j <= box.hi[1]; ++j)
44 for (int i = box.lo[0]; i <= box.hi[0]; ++i)
45 f(i, j, kAuxBaseComps) = bz(g.x_cell(i), g.y_cell(j));
46}
47
48} // namespace detail
49} // namespace pops
Box2D: the integer index space of a 2D cell-centered Cartesian grid.
Single-grid data on a Box2D: VALID box + ng ghost layers, ncomp components, component-slow layout.
Definition fab2d.hpp:59
Fab2D: single-grid data on a Box2D (in-house equivalent of AMReX's FArrayBox); Array4 / ConstArray4: ...
Geometry: index-space (Box2D) <-> Cartesian physical-space mapping; PolarGeometry: SIBLING for a glob...
void fill_bz_box(Fab2D &f, const Box2D &box, const Geometry &g, const Bz &bz)
Writes B_z(x, y) at component kAuxBaseComps on box box of fab f, sampling bz at the cell centers of g...
Definition aux_fill.hpp:42
BCRec derive_aux_bc(const BCRec &b)
Aux-channel BC derived from the potential phi BC: a periodic BC stays periodic, any other becomes Foe...
Definition aux_fill.hpp:27
Definition amr_hierarchy.hpp:29
constexpr int kAuxBaseComps
Definition state.hpp:147
BCType
Boundary condition type for a face: Periodic (handled by fill_boundary), Foextrap (zero gradient,...
Definition physical_bc.hpp:25
PHYSICAL boundary conditions at the domain edge (BCType, BCRec, fill_physical_bc, fill_ghosts).
Pointwise types of the physics layer: StateVec<N> (conserved state) and Aux (auxiliary fields from th...
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
2D integer index space, cell-centered.
Definition box2d.hpp:37
int hi[2]
Definition box2d.hpp:39
int lo[2]
Definition box2d.hpp:38
Cartesian geometry of a level: index domain + physical bounds [xlo, xhi] x [ylo, yhi].
Definition geometry.hpp:20
POPS_HD Real x_cell(int i) const
Abscissa at the CENTER of cell index i (i = 0 -> xlo + dx/2; defined for negative i)....
Definition geometry.hpp:35
POPS_HD Real y_cell(int j) const
Ordinate at the CENTER of cell index j. POPS_HD.
Definition geometry.hpp:37