ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
erf_sbm::SBMTransport Class Reference

#include <ERF_SBMTransport.H>

Collaboration diagram for erf_sbm::SBMTransport:

Classes

struct  DeviceMetadata
 
struct  LevelStorage
 

Public Member Functions

 SBMTransport (const SBMLayout &layout, int number_of_levels, int max_groups_per_chunk=default_max_groups_per_chunk, bool keep_spectral_ledger_reference=true)
 
 ~SBMTransport ()
 
 SBMTransport (const SBMTransport &)=delete
 
SBMTransport & operator= (const SBMTransport &)=delete
 
void define (int level, const amrex::BoxArray &cell_ba, const amrex::DistributionMapping &dm)
 
bool rebuild_static_measure (int level, const amrex::MultiFab &detJ, const amrex::MultiFab &mx, const amrex::MultiFab &my, std::string &diagnostic)
 
void set_amr_flux_registers (int level, SBMAMRFluxRegister *as_coarse, SBMAMRFluxRegister *as_fine)
 
void set_physical_boundaries (const SBMPhysicalBoundaryConfig &config)
 
const SBMPhysicalBoundaryConfig & physical_boundaries () const noexcept
 
const SBMBoundaryLedger & boundary_ledger () const noexcept
 
void restore_boundary_ledger (const SBMBoundaryLedger &ledger)
 
void set_particle_mixing (const ParticleMixingConfig &config, erf_auxiliary::DiffusionMesh mesh, TerrainMixingQualification terrain={})
 
const ParticleMixingConfig & particle_mixing () const noexcept
 
bool mixes_particles () const noexcept
 
erf_auxiliary::DiffusionMesh mixing_mesh () const noexcept
 
bool admit_terrain_geometry (int level, const amrex::MultiFab &z_nd, std::string &reason) const
 
bool begin_physical_step (int level, double step_begin, double step_end, std::string &diagnostic)
 
bool accept_physical_step (int level, double step_begin, double step_end, std::string &diagnostic)
 
void advance_stage_from_host (int level, erf_auxiliary::HostIntegrator method, int stage, double step_old_time, double input_time, double target_time, double host_stage_interval, SBMStateManager &state_manager, const amrex::MultiFab &S_old_cons, const amrex::MultiFab &S_new_cons, amrex::MultiFab &S_data_cons, const amrex::MultiFab &avg_xmom, const amrex::MultiFab &avg_ymom, const amrex::MultiFab &avg_zmom, const amrex::Geometry &geometry, int qc_component, int qr_component, const SBMAMRStageParent *parent=nullptr, const SBMStageMixingInputs *mixing=nullptr)
 
void advance_stage (int level, erf_auxiliary::HostIntegrator method, int stage, double step_old_time, double input_time, double target_time, double host_stage_interval, SBMStateManager &state_manager, const amrex::MultiFab &conserved_anchor, const amrex::MultiFab &conserved_input, amrex::MultiFab &conserved_target, const amrex::MultiFab &avg_xmom, const amrex::MultiFab &avg_ymom, const amrex::MultiFab &avg_zmom, const amrex::Geometry &geometry, int qc_component, int qr_component, const SBMAMRStageParent *parent=nullptr, const SBMStageMixingInputs *mixing=nullptr)
 
void destroy (int level)
 
int nlevels () const noexcept
 
bool is_defined (int level) const
 
bool measure_is_ready (int level) const
 
SBMStateAdmission & admission () noexcept
 
const amrex::MultiFab & static_measure (int level) const
 
int max_groups_per_chunk () const noexcept
 
const std::vector< ConstraintClosureChunk > & chunks () const noexcept
 
int max_chunk_components () const noexcept
 
const erf_auxiliary::CompletedStepFluxLedger & projected_ledger (int level) const
 
const erf_auxiliary::CompletedStepFluxLedger & completed_spectral_ledger (int level) const
 
void enable_zero_flow_diagnostics (bool enabled) noexcept
 
int interval_limiter_active_groups () const noexcept
 
bool interval_limiter_changed_rate () const noexcept
 
amrex::Real interval_carrier_linf () const noexcept
 
amrex::Real interval_accepted_rate_linf () const noexcept
 

Static Public Attributes

static constexpr int default_max_groups_per_chunk = 16
 

Private Member Functions

void install_mixing_bc ()
 

Private Attributes

const SBMLayout & m_layout
 
SBMBulkProjection m_projection
 
std::vector< ConstraintGroup > m_groups
 
FlattenedConstraintSet m_flat_constraints
 
std::vector< AttachedPropertySupportDescriptor > m_property_support
 
std::vector< ConstraintClosureChunk > m_chunks
 
int m_max_groups_per_chunk {default_max_groups_per_chunk}
 
std::vector< int > m_max_constraints_per_group
 
int m_max_chunk_components {0}
 
std::vector< std::unique_ptr< LevelStorage > > m_levels
 
std::unique_ptr< DeviceMetadata > m_device_metadata
 
std::unique_ptr< SBMStateAdmission > m_admission
 
SBMPhysicalBoundaryConfig m_boundaries
 
amrex::Gpu::DeviceVector< amrex::Real > m_inflow_device
 
SBMBoundaryLedger m_boundary_ledger
 
ParticleMixingConfig m_mixing
 
erf_auxiliary::DiffusionMesh m_mixing_mesh {erf_auxiliary::DiffusionMesh::ConstantDz}
 
bool m_terrain_match {true}
 
amrex::Gpu::DeviceVector< amrex::BCRec > m_mixing_bc
 
bool m_keep_spectral_ledger_reference {true}
 
bool m_zero_flow_diagnostics_enabled {false}
 
std::array< bool, 2 > m_split_ghost_values_checked {}
 
bool m_host_integrator_reported {false}
 
int m_interval_limiter_active_groups {0}
 
bool m_interval_limiter_changed_rate {false}
 
amrex::Real m_interval_carrier_linf {amrex::Real(0.0)}
 
amrex::Real m_interval_accepted_rate_linf {amrex::Real(0.0)}
 

Detailed Description

Bounded mapped advection for the authoritative SBM spectrum.

The state manager remains the owner of prognostic state. This object owns per-level stage scratch, the static mapped measure, the compact projected qc/qr completed-step face ledger, and (in reference mode) an optional all-component completed spectral face ledger. Production AMR instances add accepted chunk-local stage rates directly to their pending interface YA register and do not retain that full spectral ledger. It also owns the physical-face configuration and the cumulative boundary ledger.

Constructor & Destructor Documentation

◆ SBMTransport() [1/2]

erf_sbm::SBMTransport::SBMTransport ( const SBMLayout &  layout,
int  number_of_levels,
int  max_groups_per_chunk = default_max_groups_per_chunk,
bool  keep_spectral_ledger_reference = true 
)
explicit
2002  : m_layout(layout),
2003  m_projection(layout),
2010  m_levels(static_cast<std::size_t>(number_of_levels)),
2011  m_device_metadata(std::make_unique<DeviceMetadata>()),
2012  m_admission(std::make_unique<SBMStateAdmission>(layout)),
2013  m_keep_spectral_ledger_reference(keep_spectral_ledger_reference)
2014 {
2015  AMREX_ALWAYS_ASSERT(number_of_levels > 0);
2016  if (AMREX_SPACEDIM != 3) {
2017  throw std::invalid_argument(
2018  "SBM M3 mapped transport currently requires three dimensions");
2019  }
2020  m_boundary_ledger.reset(layout.ncomp());
2021  // Local slots follow global order, so YA adds each moment family as one run.
2022  for (auto& chunk : m_chunks) {
2023  std::sort(chunk.components.begin(), chunk.components.end());
2024  }
2025 
2026  std::vector<ConstraintDescriptor> local_descriptors;
2027  std::vector<ConstraintTerm> local_terms;
2028  std::vector<LocalPropertySupport> local_supports;
2029  std::vector<MatchingGroup> matching_groups;
2030  std::vector<int> matching_members;
2031  std::vector<ConstraintDescriptor> matching_coordinates;
2032  m_device_metadata->host_groups.resize(m_groups.size());
2033  std::vector<int> group_chunk(m_groups.size(), -1);
2034  std::vector<int> group_local(m_groups.size(), -1);
2035 
2036  for (std::size_t chunk_index = 0; chunk_index < m_chunks.size();
2037  ++chunk_index) {
2038  const auto& chunk = m_chunks[chunk_index];
2039  m_max_chunk_components = std::max(
2041  static_cast<int>(chunk.components.size()));
2042  int chunk_ratio_components = 0;
2043  std::vector<int> global_to_local(
2044  static_cast<std::size_t>(m_layout.ncomp()), -1);
2045  for (std::size_t local = 0; local < chunk.components.size(); ++local) {
2046  global_to_local[static_cast<std::size_t>(chunk.components[local])] =
2047  static_cast<int>(local);
2048  }
2049  m_device_metadata->matching_offsets.push_back(
2050  static_cast<int>(matching_groups.size()));
2051  for (std::size_t local_group = 0;
2052  local_group < chunk.group_indices.size(); ++local_group) {
2053  const int group_index = chunk.group_indices[local_group];
2054  const auto& group =
2055  m_groups[static_cast<std::size_t>(group_index)];
2056  MatchingGroup matching;
2057  matching.members_begin = static_cast<int>(matching_members.size());
2058  matching.coordinates_begin = static_cast<int>(matching_coordinates.size());
2059  for (const int member : group.members) {
2060  matching_members.push_back(
2061  global_to_local[static_cast<std::size_t>(member)]);
2062  }
2063  matching.members_count =
2064  static_cast<int>(matching_members.size()) - matching.members_begin;
2065  group_chunk[static_cast<std::size_t>(group_index)] =
2066  static_cast<int>(chunk_index);
2067  group_local[static_cast<std::size_t>(group_index)] =
2068  static_cast<int>(local_group);
2069  auto& device_group =
2071  ->host_groups[static_cast<std::size_t>(group_index)];
2072  device_group.constraints_begin =
2073  static_cast<int>(local_descriptors.size());
2074  device_group.supports_begin =
2075  static_cast<int>(local_supports.size());
2076  device_group.chunk_index = static_cast<int>(chunk_index);
2077  device_group.local_group_index = static_cast<int>(local_group);
2078 
2079  for (const auto& descriptor : m_flat_constraints.constraints) {
2080  if (descriptor.group_index != group_index) {
2081  continue;
2082  }
2083  ConstraintDescriptor local_descriptor = descriptor;
2084  local_descriptor.term_offset =
2085  static_cast<int>(local_terms.size());
2086  for (int term_index = 0; term_index < descriptor.term_count;
2087  ++term_index) {
2088  auto term =
2089  m_flat_constraints.terms[static_cast<std::size_t>(
2090  descriptor.term_offset + term_index)];
2091  const int local_component =
2092  global_to_local[static_cast<std::size_t>(
2093  term.component)];
2094  if (local_component < 0) {
2095  throw std::logic_error("SBM closure chunk split an "
2096  "atomic constraint group");
2097  }
2098  term.component = local_component;
2099  local_terms.push_back(term);
2100  }
2101  local_descriptor.group_index = static_cast<int>(local_group);
2102  local_descriptors.push_back(local_descriptor);
2103  ++device_group.linear_constraint_count;
2104  if (is_matched_coordinate(group, m_layout, descriptor.constraint_index)) {
2105  matching_coordinates.push_back(local_descriptor);
2106  }
2107  }
2108  matching.coordinates_count =
2109  static_cast<int>(matching_coordinates.size()) - matching.coordinates_begin;
2110  const int expected_coordinates =
2111  (group.moment_mode == MomentMode::TwoMoment ? 2 : 1) +
2112  static_cast<int>(group.attached_property_indices.size());
2113  if (matching.coordinates_count != expected_coordinates) {
2114  throw std::logic_error("SBM transport group " + group.semantic_id +
2115  " lacks the coordinates terrain mixing matches");
2116  }
2117  matching_groups.push_back(matching);
2118 
2119  for (const auto& support : m_property_support) {
2120  if (support.group_index != group_index) {
2121  continue;
2122  }
2123  LocalPropertySupport local_support;
2124  local_support.property_global = support.property_component;
2125  local_support.carrier_global = support.carrier_component;
2126  local_support.property_local =
2127  global_to_local[static_cast<std::size_t>(
2128  support.property_component)];
2129  local_support.carrier_local =
2130  global_to_local[static_cast<std::size_t>(
2131  support.carrier_component)];
2132  local_support.hard_min = support.hard_min;
2133  local_support.hard_max = support.hard_max;
2134  local_support.has_hard_min = support.has_hard_min;
2135  local_support.has_hard_max = support.has_hard_max;
2136  if (local_support.property_local < 0 ||
2137  local_support.carrier_local < 0) {
2138  throw std::logic_error(
2139  "SBM closure chunk split an attached-property group");
2140  }
2141  local_supports.push_back(local_support);
2142  ++device_group.support_count;
2143  }
2144  // Keep the strict persisted upper edge open during transport by
2145  // reserving eta of the endpoint_low margin for interior 2M bins.
2146  if (group.moment_mode == MomentMode::TwoMoment) {
2147  const auto population = std::find_if(
2148  m_layout.populations().begin(), m_layout.populations().end(),
2149  [&group](const PopulationLayout& candidate) {
2150  return candidate.population_id == group.population_id;
2151  });
2152  if (population == m_layout.populations().end()) {
2153  throw std::logic_error(
2154  "SBM transport group has no matching population layout");
2155  }
2156  if (group.bin < population->grid.nbins() - 1) {
2157  const int mass_global = population->mass_offset + group.bin;
2158  const int number_global =
2159  population->number_offset + group.bin;
2160  device_group.canonical_mass_local =
2161  global_to_local[static_cast<std::size_t>(mass_global)];
2162  device_group.canonical_number_local =
2163  global_to_local[static_cast<std::size_t>(number_global)];
2164  if (device_group.canonical_mass_local < 0 ||
2165  device_group.canonical_number_local < 0) {
2166  throw std::logic_error(
2167  "SBM closure chunk split an interior two-moment "
2168  "canonical-reserve group");
2169  }
2170  const Real lower = population->grid.edges()[
2171  static_cast<std::size_t>(group.bin)];
2172  const Real upper = population->grid.edges()[
2173  static_cast<std::size_t>(group.bin + 1)];
2174  const Real width = upper - lower;
2175  const Real eta =
2176  Real(128.0) * std::numeric_limits<Real>::epsilon();
2177  device_group.canonical_mass_coefficient =
2178  -(Real(1.0) + eta) / width;
2179  device_group.canonical_number_coefficient =
2180  (Real(1.0) - eta) * upper / width;
2181  device_group.canonical_reserve = 1;
2182  }
2183  }
2184  device_group.ratio_count = device_group.linear_constraint_count +
2185  2 * device_group.support_count +
2186  device_group.canonical_reserve;
2187  device_group.ratio_offset = chunk_ratio_components;
2188  AMREX_ALWAYS_ASSERT(device_group.ratio_count >= 0);
2190  device_group.ratio_count <=
2191  std::numeric_limits<int>::max() - chunk_ratio_components);
2192  chunk_ratio_components += device_group.ratio_count;
2193  m_max_constraints_per_group[static_cast<std::size_t>(group_index)] =
2194  device_group.ratio_count;
2195  }
2196  }
2197 
2198  auto& device = *m_device_metadata;
2199  device.local_constraints.resize(local_descriptors.size());
2200  device.local_terms.resize(local_terms.size());
2201  device.local_supports.resize(local_supports.size());
2202  if (!local_descriptors.empty()) {
2203  amrex::Gpu::copy(amrex::Gpu::hostToDevice, local_descriptors.begin(),
2204  local_descriptors.end(),
2205  device.local_constraints.begin());
2206  }
2207  if (!local_terms.empty()) {
2208  amrex::Gpu::copy(amrex::Gpu::hostToDevice, local_terms.begin(),
2209  local_terms.end(), device.local_terms.begin());
2210  }
2211  if (!local_supports.empty()) {
2212  amrex::Gpu::copy(amrex::Gpu::hostToDevice, local_supports.begin(),
2213  local_supports.end(), device.local_supports.begin());
2214  }
2215  std::vector<Real> host_edges;
2216  std::vector<Real> host_pivots;
2217  std::vector<int> host_property_components;
2218  std::vector<int> edge_offsets, pivot_offsets, property_offsets;
2219  for (const auto& population : m_layout.populations()) {
2220  edge_offsets.push_back(static_cast<int>(host_edges.size()));
2221  host_edges.insert(host_edges.end(), population.grid.edges().begin(),
2222  population.grid.edges().end());
2223  pivot_offsets.push_back(static_cast<int>(host_pivots.size()));
2224  host_pivots.insert(host_pivots.end(), population.grid.pivots().begin(),
2225  population.grid.pivots().end());
2226  property_offsets.push_back(
2227  static_cast<int>(host_property_components.size()));
2228  host_property_components.insert(
2229  host_property_components.end(),
2230  population.property_component_offsets.begin(),
2231  population.property_component_offsets.end());
2232  }
2233  device.edges.resize(host_edges.size());
2234  device.pivots.resize(host_pivots.size());
2235  device.property_components.resize(host_property_components.size());
2236  if (!host_edges.empty()) {
2237  amrex::Gpu::copy(amrex::Gpu::hostToDevice, host_edges.begin(),
2238  host_edges.end(), device.edges.begin());
2239  }
2240  if (!host_pivots.empty()) {
2241  amrex::Gpu::copy(amrex::Gpu::hostToDevice, host_pivots.begin(),
2242  host_pivots.end(), device.pivots.begin());
2243  }
2244  if (!host_property_components.empty()) {
2245  amrex::Gpu::copy(
2246  amrex::Gpu::hostToDevice, host_property_components.begin(),
2247  host_property_components.end(), device.property_components.begin());
2248  }
2249  std::vector<PopulationRemapView> device_views;
2250  device_views.reserve(m_layout.populations().size());
2251  for (std::size_t p = 0; p < m_layout.populations().size(); ++p) {
2252  const auto& population = m_layout.populations()[p];
2253  auto view = population_remap_view(m_layout, population.population_id);
2254  view.edges = device.edges.data() + edge_offsets[p];
2255  view.pivots = population.grid.pivots().empty()
2256  ? nullptr
2257  : device.pivots.data() + pivot_offsets[p];
2258  view.property_component_offsets =
2259  population.property_component_offsets.empty()
2260  ? nullptr
2261  : device.property_components.data() + property_offsets[p];
2262  device_views.push_back(view);
2263  }
2264  device.populations.resize(device_views.size());
2265  if (!device_views.empty()) {
2266  amrex::Gpu::copy(amrex::Gpu::hostToDevice, device_views.begin(),
2267  device_views.end(), device.populations.begin());
2268  }
2269  device.matching_groups.resize(matching_groups.size());
2270  device.matching_members.resize(matching_members.size());
2271  device.matching_coordinates.resize(matching_coordinates.size());
2272  if (!matching_groups.empty()) {
2273  amrex::Gpu::copy(amrex::Gpu::hostToDevice, matching_groups.begin(),
2274  matching_groups.end(), device.matching_groups.begin());
2275  }
2276  if (!matching_members.empty()) {
2277  amrex::Gpu::copy(amrex::Gpu::hostToDevice, matching_members.begin(),
2278  matching_members.end(), device.matching_members.begin());
2279  }
2280  if (!matching_coordinates.empty()) {
2281  amrex::Gpu::copy(amrex::Gpu::hostToDevice, matching_coordinates.begin(),
2282  matching_coordinates.end(), device.matching_coordinates.begin());
2283  }
2284  std::vector<int> host_chunk_components;
2285  for (const auto& chunk : m_chunks) {
2286  device.chunk_offsets.push_back(static_cast<int>(host_chunk_components.size()));
2287  host_chunk_components.insert(host_chunk_components.end(),
2288  chunk.components.begin(), chunk.components.end());
2289  }
2290  device.chunk_components.resize(host_chunk_components.size());
2291  if (!host_chunk_components.empty()) {
2292  amrex::Gpu::copy(amrex::Gpu::hostToDevice, host_chunk_components.begin(),
2293  host_chunk_components.end(), device.chunk_components.begin());
2294  }
2295 }
AMREX_ALWAYS_ASSERT(bx.length()[2]==khi+1)
DiagnosticDescriptor descriptor
Definition: ERF_Plotfile2DCatalog.cpp:142
const std::vector< PopulationLayout > & populations() const noexcept
Definition: ERF_SBMLayout.H:99
int ncomp() const noexcept
Definition: ERF_SBMLayout.H:103
std::unique_ptr< DeviceMetadata > m_device_metadata
Definition: ERF_SBMTransport.H:301
std::vector< ConstraintClosureChunk > m_chunks
Definition: ERF_SBMTransport.H:296
SBMBulkProjection m_projection
Definition: ERF_SBMTransport.H:292
int max_groups_per_chunk() const noexcept
Definition: ERF_SBMTransport.H:261
std::unique_ptr< SBMStateAdmission > m_admission
Definition: ERF_SBMTransport.H:302
std::vector< ConstraintGroup > m_groups
Definition: ERF_SBMTransport.H:293
std::vector< std::unique_ptr< LevelStorage > > m_levels
Definition: ERF_SBMTransport.H:300
int m_max_chunk_components
Definition: ERF_SBMTransport.H:299
SBMBoundaryLedger m_boundary_ledger
Definition: ERF_SBMTransport.H:305
std::vector< AttachedPropertySupportDescriptor > m_property_support
Definition: ERF_SBMTransport.H:295
bool m_keep_spectral_ledger_reference
Definition: ERF_SBMTransport.H:310
std::vector< int > m_max_constraints_per_group
Definition: ERF_SBMTransport.H:298
int m_max_groups_per_chunk
Definition: ERF_SBMTransport.H:297
FlattenedConstraintSet m_flat_constraints
Definition: ERF_SBMTransport.H:294
const SBMLayout & m_layout
Definition: ERF_SBMTransport.H:291
@ p
Definition: ERF_WSM6.H:303
bool is_matched_coordinate(const ConstraintGroup &group, const SBMLayout &layout, const int constraint_index)
Definition: ERF_SBMTransport.cpp:92
std::vector< ConstraintGroup > make_constraint_groups(const SBMLayout &layout)
Definition: ERF_SBMConstraintGroups.cpp:77
std::vector< AttachedPropertySupportDescriptor > make_attached_property_support_descriptors(const SBMLayout &layout)
Definition: ERF_SBMConstraintGroups.cpp:214
std::vector< ConstraintClosureChunk > make_constraint_closure_chunks(const SBMLayout &layout, const int max_groups)
Definition: ERF_SBMConstraintGroups.cpp:257
FlattenedConstraintSet make_constraint_descriptors(const SBMLayout &layout)
Definition: ERF_SBMConstraintGroups.cpp:208
PopulationRemapView population_remap_view(const SBMLayout &layout, const int population_id) noexcept
Definition: ERF_SBMRemapping.cpp:8
real(c_double), parameter epsilon
Definition: ERF_module_model_constants.F90:12
std::vector< ConstraintTerm > terms
Definition: ERF_SBMConstraintGroups.H:65
std::vector< ConstraintDescriptor > constraints
Definition: ERF_SBMConstraintGroups.H:64
void reset(int components)
Definition: ERF_SBMPhysicalBoundary.cpp:188
Here is the call graph for this function:

◆ ~SBMTransport()

erf_sbm::SBMTransport::~SBMTransport ( )
default

◆ SBMTransport() [2/2]

erf_sbm::SBMTransport::SBMTransport ( const SBMTransport &  )
delete

Member Function Documentation

◆ accept_physical_step()

bool erf_sbm::SBMTransport::accept_physical_step ( int  level,
double  step_begin,
double  step_end,
std::string &  diagnostic 
)
2545 {
2546  diagnostic.clear();
2547  if (!is_defined(level)) {
2548  diagnostic = "SBM transport physical-step acceptance requires a defined level";
2549  return false;
2550  }
2551  auto& data = *m_levels[static_cast<std::size_t>(level)];
2552  if (data.interface_as_coarse &&
2553  !data.interface_as_coarse->accept_level_step(
2554  true, step_begin, step_end, diagnostic)) {
2555  return false;
2556  }
2557  if (data.interface_as_fine &&
2558  !data.interface_as_fine->accept_level_step(
2559  false, step_begin, step_end, diagnostic)) {
2560  return false;
2561  }
2562  return true;
2563 }
bool is_defined(int level) const
Definition: ERF_SBMTransport.cpp:3866
Here is the call graph for this function:

◆ admission()

SBMStateAdmission & erf_sbm::SBMTransport::admission ( )
noexcept
3884 {
3885  return *m_admission;
3886 }

◆ admit_terrain_geometry()

bool erf_sbm::SBMTransport::admit_terrain_geometry ( int  level,
const amrex::MultiFab &  z_nd,
std::string &  reason 
) const

With terrain-fitted particle mixing, admit_terrain_mixing_geometry of a level's static nodal heights (a cell drop of at most one thickness); true with no terrain mixing. Check it once the geometry is final.

2429 {
2430  reason.clear();
2432  return true;
2433  }
2436  z_nd, m_levels[static_cast<std::size_t>(level)]->target.boxArray(), Real(1.0), reason);
2437 }
erf_auxiliary::DiffusionMesh m_mixing_mesh
Definition: ERF_SBMTransport.H:307
bool mixes_particles() const noexcept
Definition: ERF_SBMTransport.H:191
bool admit_terrain_mixing_geometry(const amrex::MultiFab &z_nd, const amrex::BoxArray &cells, const amrex::Real max_drop, std::string &reason)
Definition: ERF_SBMParticleMixing.cpp:368
Here is the call graph for this function:

◆ advance_stage()

void erf_sbm::SBMTransport::advance_stage ( int  level,
erf_auxiliary::HostIntegrator  method,
int  stage,
double  step_old_time,
double  input_time,
double  target_time,
double  host_stage_interval,
SBMStateManager &  state_manager,
const amrex::MultiFab &  conserved_anchor,
const amrex::MultiFab &  conserved_input,
amrex::MultiFab &  conserved_target,
const amrex::MultiFab &  avg_xmom,
const amrex::MultiFab &  avg_ymom,
const amrex::MultiFab &  avg_zmom,
const amrex::Geometry &  geometry,
int  qc_component,
int  qr_component,
const SBMAMRStageParent *  parent = nullptr,
const SBMStageMixingInputs *  mixing = nullptr 
)
2637 {
2639  auto& data = *m_levels[static_cast<std::size_t>(level)];
2640  const bool profile_parent_fill =
2641  parent != nullptr && parent->profile_parent_fill;
2642  using ProfileClock = std::chrono::steady_clock;
2643  const auto profile_stage_start = profile_parent_fill
2644  ? ProfileClock::now() : ProfileClock::time_point{};
2645  if (profile_parent_fill && stage == 0) {
2646  data.profile_stage_seconds.fill(0.0);
2647  data.profile_fine_step_start = profile_stage_start;
2648  }
2650  data.measure_ready,
2651  "SBM M3 cannot advance before its static mapped measure is built");
2652  AMREX_ALWAYS_ASSERT(state_manager.is_defined(level));
2653  for (int face = 0; face < physical_face_count; ++face) {
2654  const bool periodic_face =
2655  m_boundaries.kind[static_cast<std::size_t>(face)] ==
2657  if (periodic_face != geometry.isPeriodic(face % AMREX_SPACEDIM)) {
2658  amrex::Abort(std::string("SBM physical boundary ") + face_name(face) +
2659  " does not match the periodicity of the level geometry");
2660  }
2661  }
2662  const bool physical_faces = !geometry.isAllPeriodic();
2663  const bool mixing_active = mixes_particles();
2664  if (mixing_active != (mixing != nullptr)) {
2665  amrex::Abort(mixing_active
2666  ? std::string("SBM particle mixing ") + particle_mixing_name(m_mixing.policy) +
2667  " received no stage mixing inputs"
2668  : std::string("SBM transport received stage mixing inputs without a "
2669  "particle mixing policy"));
2670  }
2671  if (mixing_active) {
2672  if (mixing->metrics.mesh != m_mixing_mesh) {
2673  amrex::Abort("SBM particle mixing received metrics for another mesh than "
2674  "the one installed with its policy");
2675  }
2676  }
2677  const bool terrain_mixing =
2679  if (terrain_mixing) {
2680  const MultiFab* z_cc = mixing->z_cc;
2681  const MultiFab* z_nd = mixing->metrics.z_nd;
2682  std::string reason;
2683  if (level != 0 || parent != nullptr) {
2684  reason = "is qualified on one level only";
2686  m_boundaries.kind[2 + AMREX_SPACEDIM] != AdvectionFaceKind::ImpermeableWall) {
2687  reason = "requires walls at the bottom and top";
2688  } else if (geometry.Domain().length(2) < 3) {
2689  reason = "requires three cells in each column to extend the stage input past a wall";
2690  } else if (z_cc == nullptr || !erf_auxiliary::SameCellLayout(*z_cc, data.target) ||
2691  !z_cc->nGrowVect().allGE(amrex::IntVect(2)) || z_nd == nullptr ||
2692  !z_nd->nGrowVect().allGE(amrex::IntVect(1))) {
2693  reason = "requires ERF's cell-centre heights with two ghost cells and nodal "
2694  "heights with one";
2695  }
2696  if (reason.empty() && !data.terrain_metrics_checked) {
2697  const std::string mismatch = shared_metric_mismatch(mixing->metrics, geometry);
2698  if (!mismatch.empty()) {
2699  reason = "requires both copies of every face shared by two boxes, or by a "
2700  "box and its periodic image, to read one metric, but " + mismatch +
2701  "; sync them with OverrideSync, as ERF does its nodal heights";
2702  }
2703  data.terrain_metrics_checked = true;
2704  }
2705  if (!reason.empty()) {
2706  amrex::Abort("SBM terrain-fitted particle mixing " + reason);
2707  }
2708  }
2709 
2711  std::string diagnostic;
2713  method, stage, host_stage_interval, recipe, diagnostic)) {
2714  amrex::Abort("SBM M3 stage recipe: " + diagnostic);
2715  }
2716  if (!std::isfinite(step_old_time) || !std::isfinite(input_time) ||
2717  !std::isfinite(target_time)) {
2718  amrex::Abort("SBM M3 received a nonfinite semantic time");
2719  }
2720  if (!state_manager.step_active(level)) {
2721  amrex::Abort("SBM M3 stage requires a state-manager begin-step transition at ERF::Advance");
2722  }
2723  const MultiFab& spectrum = stage == 0
2724  ? state_manager.old_state(level)
2725  : state_manager.new_state(level);
2726  const double spectrum_time = stage == 0
2727  ? state_manager.old_time(level)
2728  : state_manager.new_time(level);
2729  const double expected_spectrum_time = stage == 0 ? step_old_time : input_time;
2730  if (spectrum_time != expected_spectrum_time || input_time != spectrum_time) {
2731  std::ostringstream message;
2732  message.precision(17);
2733  message << "SBM M3 spectral input time mismatch at level " << level
2734  << " stage " << stage << ": expected " << expected_spectrum_time
2735  << " and requested input time " << input_time
2736  << ", got " << spectrum_time;
2737  amrex::Abort(message.str());
2738  }
2739  AMREX_ALWAYS_ASSERT(spectrum.nComp() == m_layout.ncomp());
2740  AMREX_ALWAYS_ASSERT(erf_auxiliary::SameCellLayout(spectrum, data.target));
2742  erf_auxiliary::SameCellLayout(spectrum, conserved_anchor));
2744  erf_auxiliary::SameCellLayout(spectrum, conserved_input));
2746  erf_auxiliary::SameCellLayout(spectrum, conserved_target));
2747  AMREX_ALWAYS_ASSERT(erf_auxiliary::SameCellLayout(spectrum, data.measure));
2748  AMREX_ALWAYS_ASSERT(conserved_anchor.nComp() > Rho_comp &&
2749  conserved_input.nComp() > Rho_comp &&
2750  conserved_target.nComp() > Rho_comp);
2751  if (stage == 0) {
2752  if (data.projected_ledger.step_active()) {
2753  amrex::Abort("SBM M3 received stage 0 before the previous timestep "
2754  "completed");
2755  }
2756  MultiFab::Copy(data.anchor, spectrum, 0, 0, m_layout.ncomp(), 0);
2757  } else if (!data.projected_ledger.step_active() ||
2758  data.projected_ledger.next_stage() != stage) {
2759  amrex::Abort("SBM M3 stage arrived before stage 0 or out of order");
2760  }
2761  if (data.spectral_ledger.is_defined() &&
2762  !data.spectral_ledger.begin_stage(method, stage, step_old_time,
2763  recipe, diagnostic)) {
2764  amrex::Abort("SBM M4a spectral face-ledger stage sequence: " + diagnostic);
2765  }
2766  if (data.interface_as_coarse &&
2767  !data.interface_as_coarse->begin_stage(
2768  true, method, stage, step_old_time, diagnostic)) {
2769  amrex::Abort("SBM YA coarse-side stage sequence: " + diagnostic);
2770  }
2771  if (data.interface_as_fine &&
2772  !data.interface_as_fine->begin_stage(
2773  false, method, stage, step_old_time, diagnostic)) {
2774  amrex::Abort("SBM YA fine-side stage sequence: " + diagnostic);
2775  }
2776 
2777  const MultiFab& trial_state =
2779  ? data.anchor
2780  : spectrum;
2781  const MultiFab& trial_conserved =
2783  ? conserved_anchor
2784  : conserved_input;
2785  if (!erf_auxiliary::ValidatePositiveFiniteComponent(conserved_target,
2786  Rho_comp, diagnostic)) {
2787  std::ostringstream message;
2788  message.precision(17);
2789  message << "SBM M3 target density at level " << level << " stage "
2790  << stage << " (input=" << input_time << ", target="
2791  << target_time << ") is invalid: " << diagnostic
2792  << "; valid-cell min=" << conserved_target.min(Rho_comp)
2793  << " max=" << conserved_target.max(Rho_comp);
2794  amrex::Abort(message.str());
2795  }
2796 
2797 #ifdef ERF_SBM_AMR_QUALIFICATION
2799  m_interval_carrier_linf = std::max(
2801  std::max({avg_xmom.norminf(0), avg_ymom.norminf(0),
2802  avg_zmom.norminf(0)}));
2803  }
2804 #endif
2805 
2806  build_intensive(data.input_intensive, spectrum, conserved_input,
2807  geometry.periodicity(), "input");
2808  build_intensive(data.base_intensive, trial_state, trial_conserved,
2809  geometry.periodicity(), "limiter-trial base");
2810  build_intensive(data.anchor_intensive, data.anchor, conserved_anchor,
2811  geometry.periodicity(), "old-step anchor");
2812 
2813  if (level > 0) {
2814  if (parent == nullptr || parent->conserved_old == nullptr ||
2815  parent->conserved_new == nullptr ||
2816  !state_manager.old_valid(level - 1) ||
2817  !state_manager.new_valid(level - 1)) {
2818  amrex::Abort("fine SBM stage is missing its accepted coarse "
2819  "spectral/density endpoint bracket");
2820  }
2821  const MultiFab& coarse_old_spectrum = state_manager.old_state(level - 1);
2822  const MultiFab& coarse_new_spectrum = state_manager.new_state(level - 1);
2824  data.input_intensive, data.coarse_fill_mask,
2825  coarse_old_spectrum, coarse_new_spectrum, spectrum,
2826  conserved_input, *parent, geometry,
2827  m_chunks, m_max_chunk_components, input_time,
2828  state_manager.old_time(level - 1),
2829  state_manager.new_time(level - 1), level, stage, "input",
2830  data.coarse_source_pack, data.coarse_stage,
2831  parent->ghost_probe, &m_split_ghost_values_checked);
2832  const double base_time =
2833  recipe.limiter_trial_base ==
2835  ? step_old_time : input_time;
2837  data.base_intensive, data.coarse_fill_mask,
2838  coarse_old_spectrum, coarse_new_spectrum, trial_state,
2839  trial_conserved, *parent, geometry,
2840  m_chunks, m_max_chunk_components, base_time,
2841  state_manager.old_time(level - 1),
2842  state_manager.new_time(level - 1), level, stage,
2843  "limiter-base", data.coarse_source_pack, data.coarse_stage,
2844  parent->ghost_probe);
2846  data.anchor_intensive, data.coarse_fill_mask,
2847  coarse_old_spectrum, coarse_new_spectrum, data.anchor,
2848  conserved_anchor, *parent, geometry,
2849  m_chunks, m_max_chunk_components, step_old_time,
2850  state_manager.old_time(level - 1),
2851  state_manager.new_time(level - 1), level, stage, "anchor",
2852  data.coarse_source_pack, data.coarse_stage,
2853  parent->ghost_probe);
2854  } else if (parent != nullptr) {
2855  amrex::Abort("coarse SBM stage unexpectedly received a parent bracket");
2856  }
2857  if (physical_faces) {
2858  for (MultiFab* intensive : {&data.input_intensive, &data.base_intensive,
2859  &data.anchor_intensive}) {
2860  fill_physical_ghosts(*intensive, geometry, m_boundaries,
2861  m_inflow_device.data());
2862  }
2863  }
2864  MultiFab::Copy(data.physical_input_intensive, data.input_intensive, 0, 0,
2865  m_layout.ncomp(), 2);
2866 
2867  // Transform every 2M pair in place to endpoint-number coordinates. The
2868  // canonical transform is shared with persisted-state reconstruction and
2869  // is intentionally performed before native scalar WENO-Z3.
2870  data.invalid.setVal(Real(0.0));
2871  const auto populations = m_device_metadata->populations.data();
2872  const int population_count =
2873  static_cast<int>(m_layout.populations().size());
2874  // A fine level also transforms the parent-filled coarse-only ghosts that
2875  // FillBoundary below does not refill. Level 0 needs valid cells only: its
2876  // physical ghosts reach only donor-band faces, whose WENO rate is replaced.
2877  const bool transform_ghosts = level > 0;
2878  MultiFab& transform_invalid =
2879  transform_ghosts ? data.coarse_fill_mask : data.invalid;
2880  const int transform_ghost_cells = transform_ghosts ? 2 : 0;
2881  if (transform_ghosts) {
2882  data.coarse_fill_mask.setVal(Real(0.0), 0, 1, transform_ghost_cells);
2883  }
2884  for (amrex::MFIter mfi(data.input_intensive,
2885  transform_ghosts ? false : amrex::TilingIfNotGPU());
2886  mfi.isValid(); ++mfi) {
2887  const amrex::Box bx = transform_ghosts ? mfi.fabbox() : mfi.tilebox();
2888  const auto input = data.input_intensive.array(mfi);
2889  const auto invalid = transform_invalid.array(mfi);
2890  const auto endpoint_populations = populations;
2892  bx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept {
2893  int cell_invalid = 0;
2894  for (int p = 0; p < population_count; ++p) {
2895  const auto& pop = endpoint_populations[p];
2896  if (pop.moment_mode != MomentMode::TwoMoment) {
2897  continue;
2898  }
2899  for (int bin = 0; bin < pop.nbins; ++bin) {
2900  const int mass_comp = pop.mass_offset + bin;
2901  const int number_comp = pop.number_offset + bin;
2902  erf_sbm::EndpointTransform endpoint;
2904  input(i, j, k, number_comp),
2905  input(i, j, k, mass_comp), pop.edges[bin],
2906  pop.edges[bin + 1], endpoint)) {
2907  cell_invalid = 1;
2908  } else {
2909  input(i, j, k, mass_comp) = endpoint.L;
2910  input(i, j, k, number_comp) = endpoint.H;
2911  }
2912  }
2913  }
2914  invalid(i, j, k, 0) = static_cast<Real>(cell_invalid);
2915  });
2916  }
2917  if (parent != nullptr) {
2918  sample_probe_endpoint_value(parent->ghost_probe, stage,
2919  data.input_intensive);
2920  for (const auto* probe :
2921  {parent->ghost_probe, parent->secondary_ghost_probe}) {
2922  sample_probe_stencil(probe, stage, data.physical_input_intensive,
2923  data.input_intensive);
2924  }
2925  }
2926  if (transform_invalid.max(0, transform_ghost_cells) != Real(0.0)) {
2927  amrex::Abort("SBM M3 input spectrum could not be represented in "
2928  "endpoint-number coordinates");
2929  }
2930  data.input_intensive.FillBoundary(geometry.periodicity());
2931  if (physical_faces) {
2932  check_physical_face_carriers({&avg_xmom, &avg_ymom, &avg_zmom}, geometry,
2933  m_boundaries, level, stage);
2934  }
2935 
2936  // Check the donor outgoing-demand condition against the semantic limiter
2937  // base before constructing any low-order face rates. Particle mixing adds
2938  // its low-order exchange from the same base to the outgoing demand.
2939  const auto inv_dx = geometry.InvCellSizeArray();
2940  const Real tau = static_cast<Real>(recipe.limiter_trial_interval);
2941  const auto mixing_boundary =
2942  particle_mixing_boundary(m_boundaries, {&avg_xmom, &avg_ymom, &avg_zmom});
2943  if (mixing_active) {
2944  if (!data.transmissibility.is_defined()) {
2945  data.transmissibility.define(data.measure.boxArray(),
2946  data.measure.DistributionMap(), 1, 0);
2947  data.mixing_rate.define(data.measure.boxArray(),
2948  data.measure.DistributionMap(),
2949  data.low_rate.nComp(), 0);
2950  }
2952  m_mixing, geometry, mixing->metrics, trial_conserved, Rho_comp,
2953  mixing->eddy_diffusivity, mixing_boundary, data.transmissibility,
2954  diagnostic)) {
2955  amrex::Abort("SBM stage particle mixing at level " + std::to_string(level) +
2956  " stage " + std::to_string(stage) + ": " + diagnostic);
2957  }
2958  }
2959  if (terrain_mixing) {
2960  const auto& cell_ba = data.measure.boxArray();
2961  const auto& dm = data.measure.DistributionMap();
2962  if (!data.terrain_scalar.ok()) {
2963  const amrex::IntVect z_layer(0, 0, 1);
2964  data.terrain_scalar.define(cell_ba, dm, m_max_chunk_components, 2);
2965  data.terrain_raw[0].define(amrex::convert(cell_ba, amrex::IntVect(1, 0, 0)), dm,
2966  m_max_chunk_components, z_layer);
2967  data.terrain_raw[1].define(amrex::convert(cell_ba, amrex::IntVect(0, 1, 0)), dm,
2968  m_max_chunk_components, z_layer);
2969  data.terrain_raw[2].define(amrex::convert(cell_ba, amrex::IntVect(0, 0, 1)), dm,
2971  data.terrain_side_open[0].define(amrex::convert(cell_ba, amrex::IntVect(1, 0, 0)),
2972  dm, 1, z_layer);
2973  data.terrain_side_open[1].define(amrex::convert(cell_ba, amrex::IntVect(0, 1, 0)),
2974  dm, 1, z_layer);
2975  }
2976  for (int dir = 0; dir < 2; ++dir) {
2977  if (!geometry.isPeriodic(dir)) {
2978  fill_side_open_mask(data.terrain_side_open[static_cast<std::size_t>(dir)], dir,
2979  mixing_boundary, geometry);
2980  }
2981  }
2982  }
2983  data.outgoing_demand.setVal(Real(0.0));
2984  for (amrex::MFIter mfi(data.outgoing_demand, amrex::TilingIfNotGPU());
2985  mfi.isValid(); ++mfi) {
2986  const amrex::Box bx = mfi.tilebox();
2987  const auto fx = avg_xmom.const_array(mfi);
2988  const auto fy = avg_ymom.const_array(mfi);
2989  const auto fz = avg_zmom.const_array(mfi);
2990  const auto rho = trial_conserved.const_array(mfi);
2991  const auto omega = data.measure.const_array(mfi);
2992  const auto out = data.outgoing_demand.array(mfi);
2993  const auto dx_inv = inv_dx;
2994  if (mixing_active) {
2995  const auto tx = data.transmissibility.dir(0).const_array(mfi);
2996  const auto ty = data.transmissibility.dir(1).const_array(mfi);
2997  const auto tz = data.transmissibility.dir(2).const_array(mfi);
2998  amrex::ParallelFor(bx, [=] AMREX_GPU_DEVICE(int i, int j,
2999  int k) noexcept {
3000  out(i, j, k, 0) = tau *
3002  fx(i + 1, j, k, 0), fx(i, j, k, 0),
3003  fy(i, j + 1, k, 0), fy(i, j, k, 0),
3004  fz(i, j, k + 1, 0), fz(i, j, k, 0),
3005  tx(i + 1, j, k, 0), tx(i, j, k, 0),
3006  ty(i, j + 1, k, 0), ty(i, j, k, 0),
3007  tz(i, j, k + 1, 0), tz(i, j, k, 0),
3008  omega(i, j, k, 0), rho(i, j, k, Rho_comp), dx_inv);
3009  });
3010  continue;
3011  }
3012  amrex::ParallelFor(bx, [=] AMREX_GPU_DEVICE(int i, int j,
3013  int k) noexcept {
3014  out(i, j, k, 0) = tau *
3016  fx(i + 1, j, k, 0), fx(i, j, k, 0),
3017  fy(i, j + 1, k, 0), fy(i, j, k, 0),
3018  fz(i, j, k + 1, 0), fz(i, j, k, 0),
3019  omega(i, j, k, 0), rho(i, j, k, Rho_comp), dx_inv);
3020  });
3021  }
3022  const Real max_outgoing = data.outgoing_demand.max(0);
3023  const Real cfl_tolerance =
3024  Real(64.0) * std::numeric_limits<Real>::epsilon();
3025  if (!std::isfinite(max_outgoing) ||
3026  max_outgoing > Real(1.0) + cfl_tolerance) {
3027  std::ostringstream message;
3028  message << (mixing_active
3029  ? "SBM combined advection-diffusion outgoing-demand condition failed: max="
3030  : "SBM M3 donor outgoing-demand condition failed: max=")
3031  << max_outgoing << " tau=" << tau
3032  << " (no SBM subcycling is performed)";
3033  if (mixing_active && m_mixing.policy == ParticleMixingPolicy::HostPassiveScalar) {
3034  message << "; the timestep estimate uses the previous step's eddy diffusivity "
3035  "(none on the first step), so lower erf.cfl or set erf.init_shrink";
3036  }
3037  amrex::Abort(message.str());
3038  }
3039 
3040  data.projected_rate.setVal(Real(0.0));
3041  std::fill(data.boundary_stage.begin(), data.boundary_stage.end(), 0.0);
3042  if (stage == 0) {
3043  std::fill(data.boundary_step.begin(), data.boundary_step.end(), 0.0);
3044  data.boundary_step_terms = 0;
3045  }
3046  const bool record_boundary = physical_faces && recipe.completed_ledger_time != 0.0;
3047  const int boundary_slots = 2 * physical_face_count * m_layout.ncomp();
3048  const int boundary_boxes = data.accepted_rate.dir(0).local_size();
3049  if (record_boundary) {
3050  data.boundary_partial.resize(
3051  static_cast<std::size_t>(boundary_boxes) * static_cast<std::size_t>(boundary_slots));
3052  double* partial = data.boundary_partial.data();
3053  amrex::ParallelFor(boundary_boxes * boundary_slots,
3054  [=] AMREX_GPU_DEVICE(int slot) noexcept { partial[slot] = 0.0; });
3055  }
3056  const auto& device = *m_device_metadata;
3057  for (std::size_t chunk_index = 0; chunk_index < m_chunks.size();
3058  ++chunk_index) {
3059  const auto& chunk = m_chunks[chunk_index];
3060  std::vector<int> global_to_local(
3061  static_cast<std::size_t>(m_layout.ncomp()), -1);
3062  for (std::size_t local = 0; local < chunk.components.size(); ++local) {
3063  global_to_local[static_cast<std::size_t>(chunk.components[local])] =
3064  static_cast<int>(local);
3065  }
3066  data.low_rate.setVal(Real(0.0));
3067  data.high_rate.setVal(Real(0.0));
3068  data.accepted_rate.setVal(Real(0.0));
3069 
3070  // Low-order donor rates use the recipe-selected trial base.
3071  for (amrex::MFIter mfi(data.input_intensive, amrex::TilingIfNotGPU());
3072  mfi.isValid(); ++mfi) {
3073  const amrex::Box bx = mfi.tilebox();
3074  const auto z = data.base_intensive.const_array(mfi);
3075  const auto fd_x = avg_xmom.const_array(mfi);
3076  const auto fd_y = avg_ymom.const_array(mfi);
3077  const auto fd_z = avg_zmom.const_array(mfi);
3078  auto low_x = data.low_rate.dir(0).array(mfi);
3079  auto low_y = data.low_rate.dir(1).array(mfi);
3080  auto low_z = data.low_rate.dir(2).array(mfi);
3081  for (std::size_t local = 0; local < chunk.components.size();
3082  ++local) {
3083  const int component = chunk.components[local];
3084  const int local_component = static_cast<int>(local);
3085  const amrex::Box xbx = amrex::surroundingNodes(bx, 0);
3086  const amrex::Box ybx = amrex::surroundingNodes(bx, 1);
3087  const amrex::Box zbx = amrex::surroundingNodes(bx, 2);
3089  xbx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept {
3090  const Real carrier = fd_x(i, j, k, 0);
3091  const Real donor = carrier >= Real(0.0)
3092  ? z(i - 1, j, k, component)
3093  : z(i, j, k, component);
3094  low_x(i, j, k, local_component) = carrier * donor;
3095  });
3097  ybx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept {
3098  const Real carrier = fd_y(i, j, k, 0);
3099  const Real donor = carrier >= Real(0.0)
3100  ? z(i, j - 1, k, component)
3101  : z(i, j, k, component);
3102  low_y(i, j, k, local_component) = carrier * donor;
3103  });
3105  zbx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept {
3106  const Real carrier = fd_z(i, j, k, 0);
3107  const Real donor = carrier >= Real(0.0)
3108  ? z(i, j, k - 1, component)
3109  : z(i, j, k, component);
3110  low_z(i, j, k, local_component) = carrier * donor;
3111  });
3112  }
3113  }
3114 
3115  // ERF-native WENO-Z3 is applied to all input intensives. The 2M
3116  // mass/number slots currently contain B_lo and B_hi, so the same
3117  // builder also supplies the required endpoint-coordinate candidate.
3118  for (amrex::MFIter mfi(data.input_intensive, amrex::TilingIfNotGPU());
3119  mfi.isValid(); ++mfi) {
3120  const amrex::Box bx = mfi.tilebox();
3121  const GpuArray<const Array4<Real>, AMREX_SPACEDIM> flux_views{
3122  {data.high_rate.dir(0).array(mfi),
3123  data.high_rate.dir(1).array(mfi),
3124  data.high_rate.dir(2).array(mfi)}};
3125  for (std::size_t local = 0; local < chunk.components.size();
3126  ++local) {
3128  bx, data.input_intensive.const_array(mfi),
3129  chunk.components[local], flux_views,
3130  static_cast<int>(local), avg_xmom.const_array(mfi),
3131  avg_ymom.const_array(mfi), avg_zmom.const_array(mfi),
3132  AdvType::Weno_3Z, AdvType::Weno_3Z, Real(0.0), Real(0.0));
3133  }
3134  }
3135 
3136  // Invert endpoint face rates into physical water-mass and number
3137  // rates before the one common group limiter is applied.
3138  for (const auto& population : m_layout.populations()) {
3139  if (population.moment_mode != MomentMode::TwoMoment) {
3140  continue;
3141  }
3142  for (int bin = 0; bin < population.grid.nbins(); ++bin) {
3143  const int mass_global = population.mass_offset + bin;
3144  const int number_global = population.number_offset + bin;
3145  const int mass_local =
3146  global_to_local[static_cast<std::size_t>(mass_global)];
3147  const int number_local =
3148  global_to_local[static_cast<std::size_t>(number_global)];
3149  if (mass_local < 0 || number_local < 0) {
3150  continue;
3151  }
3152  const Real lower =
3153  population.grid.edges()[static_cast<std::size_t>(bin)];
3154  const Real upper =
3155  population.grid.edges()[static_cast<std::size_t>(bin + 1)];
3156  for (int dir = 0; dir < AMREX_SPACEDIM; ++dir) {
3157  auto& face_rate = data.high_rate.dir(dir);
3158  for (amrex::MFIter mfi(face_rate, amrex::TilingIfNotGPU());
3159  mfi.isValid(); ++mfi) {
3160  const amrex::Box bx = mfi.tilebox();
3161  const auto flux = face_rate.array(mfi);
3163  bx,
3164  [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept {
3165  const Real blo = flux(i, j, k, mass_local);
3166  const Real bhi = flux(i, j, k, number_local);
3167  flux(i, j, k, mass_local) =
3168  lower * blo + upper * bhi;
3169  flux(i, j, k, number_local) = blo + bhi;
3170  });
3171  }
3172  }
3173  }
3174  }
3175  if (physical_faces) {
3176  apply_physical_donor_band(data.high_rate, data.low_rate, geometry);
3177  }
3178  // The donor band above covers advection only. The diffusive exchange
3179  // is a two-point stencil, which reads a physical ghost only beyond an
3180  // open face, where it holds the inflow spectrum.
3181  if (terrain_mixing) {
3183  data.mixing_rate, data.terrain_scalar, data.terrain_raw,
3184  data.terrain_side_open, m_mixing, *mixing, m_mixing_bc.data(), geometry,
3185  data.physical_input_intensive, conserved_input, chunk.components);
3187  data.low_rate, data.high_rate, data.mixing_rate, data.transmissibility,
3188  geometry, data.base_intensive,
3189  device.chunk_components.data() + device.chunk_offsets[chunk_index],
3190  device.matching_groups.data() + device.matching_offsets[chunk_index],
3191  static_cast<int>(chunk.group_indices.size()),
3192  device.matching_members.data(), device.matching_coordinates.data(),
3193  device.local_terms.data(), m_terrain_match);
3194  } else if (mixing_active) {
3195  add_low_order_mixing(data.low_rate, data.mixing_rate, data.transmissibility,
3196  geometry, data.base_intensive, chunk.components);
3197  add_high_order_mixing(data.high_rate, data.mixing_rate, m_mixing, *mixing,
3198  m_mixing_bc.data(), mixing_boundary, geometry,
3199  data.physical_input_intensive, conserved_input,
3200  chunk.components);
3201  }
3202 
3203  data.invalid.setVal(Real(0.0));
3204  data.cell_ratios.setVal(Real(0.0));
3205  for (const int group_index : chunk.group_indices) {
3206  const auto& group = m_groups[static_cast<std::size_t>(group_index)];
3207  const auto& group_device =
3208  device.host_groups[static_cast<std::size_t>(group_index)];
3209  AMREX_ALWAYS_ASSERT(group_device.ratio_offset >= 0);
3210  AMREX_ALWAYS_ASSERT(group_device.ratio_count >= 0);
3212  group_device.ratio_offset <= data.cell_ratios.nComp());
3214  group_device.ratio_count <=
3215  data.cell_ratios.nComp() - group_device.ratio_offset);
3216 
3217  // Form the complete donor low-order trial H^L for this atomic
3218  // group from the semantic limiter-trial base.
3219  for (const int component : group.members) {
3220  const int local_component =
3221  global_to_local[static_cast<std::size_t>(component)];
3222  AMREX_ALWAYS_ASSERT(local_component >= 0);
3223  for (amrex::MFIter mfi(data.low_trial_h,
3224  amrex::TilingIfNotGPU());
3225  mfi.isValid(); ++mfi) {
3226  const amrex::Box bx = mfi.tilebox();
3227  const auto u = trial_state.const_array(mfi);
3228  const auto omega = data.measure.const_array(mfi);
3229  const auto fx = data.low_rate.dir(0).const_array(mfi);
3230  const auto fy = data.low_rate.dir(1).const_array(mfi);
3231  const auto fz = data.low_rate.dir(2).const_array(mfi);
3232  const auto hlow = data.low_trial_h.array(mfi);
3233  const Real dx = inv_dx[0], dy = inv_dx[1], dz = inv_dx[2];
3235  bx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept {
3236  const Real div =
3238  fx(i + 1, j, k, local_component),
3239  fx(i, j, k, local_component),
3240  fy(i, j + 1, k, local_component),
3241  fy(i, j, k, local_component),
3242  fz(i, j, k + 1, local_component),
3243  fz(i, j, k, local_component), dx, dy, dz);
3244  hlow(i, j, k, local_component) =
3245  omega(i, j, k, 0) * u(i, j, k, component) -
3246  tau * div;
3247  });
3248  }
3249  }
3250 
3251  const ConstraintDescriptor* local_constraints =
3252  device.local_constraints.data();
3253  const ConstraintTerm* local_terms = device.local_terms.data();
3254  const LocalPropertySupport* local_supports =
3255  device.local_supports.data();
3256  for (amrex::MFIter mfi(data.cell_ratios, amrex::TilingIfNotGPU());
3257  mfi.isValid(); ++mfi) {
3258  const amrex::Box bx = mfi.tilebox();
3259  const auto hlow = data.low_trial_h.const_array(mfi);
3260  const FaceArraySet low_faces{
3261  {data.low_rate.dir(0).const_array(mfi),
3262  data.low_rate.dir(1).const_array(mfi),
3263  data.low_rate.dir(2).const_array(mfi)}};
3264  const FaceArraySet high_faces{
3265  {data.high_rate.dir(0).const_array(mfi),
3266  data.high_rate.dir(1).const_array(mfi),
3267  data.high_rate.dir(2).const_array(mfi)}};
3268  const auto base = data.base_intensive.const_array(mfi);
3269  // Keep donor-envelope ratios in physical (M,N) coordinates.
3270  // The high-order input scratch is endpoint-transformed below.
3271  const auto input =
3272  data.physical_input_intensive.const_array(mfi);
3273  const auto anchor = data.anchor_intensive.const_array(mfi);
3274  const auto ratios = data.cell_ratios.array(mfi);
3275  const auto invalid = data.invalid.array(mfi);
3276  const auto dx = inv_dx;
3277  const int constraints_begin = group_device.constraints_begin;
3278  const int linear_count = group_device.linear_constraint_count;
3279  const int supports_begin = group_device.supports_begin;
3280  const int support_count = group_device.support_count;
3281  const int ratio_offset = group_device.ratio_offset;
3282  const int canonical_reserve =
3283  group_device.canonical_reserve;
3284  const int canonical_mass_local =
3285  group_device.canonical_mass_local;
3286  const int canonical_number_local =
3287  group_device.canonical_number_local;
3288  const Real canonical_mass_coefficient =
3289  group_device.canonical_mass_coefficient;
3290  const Real canonical_number_coefficient =
3291  group_device.canonical_number_coefficient;
3292  const Real roundoff =
3293  Real(128.0) * std::numeric_limits<Real>::epsilon();
3294  amrex::ParallelFor(bx, [=] AMREX_GPU_DEVICE(int i, int j,
3295  int k) noexcept {
3296  int bad = 0;
3297  for (int ci = 0; ci < linear_count; ++ci) {
3298  const auto& descriptor =
3299  local_constraints[constraints_begin + ci];
3300  Real margin = Real(0.0);
3301  Real scale = Real(0.0);
3302  for (int t = 0; t < descriptor.term_count; ++t) {
3303  const auto& term =
3304  local_terms[descriptor.term_offset + t];
3305  const Real value = hlow(i, j, k, term.component);
3306  margin = std::fma(term.coefficient, value, margin);
3307  scale += amrex::Math::abs(term.coefficient * value);
3308  }
3309  Real adverse = Real(0.0);
3310  Real gross = Real(0.0);
3311  for (int dir = 0; dir < AMREX_SPACEDIM; ++dir) {
3312  const Real left_delta = face_correction(
3313  descriptor, local_terms, low_faces, high_faces,
3314  i, j, k, dir, -1, tau, dx);
3315  const Real right_delta = face_correction(
3316  descriptor, local_terms, low_faces, high_faces,
3317  i, j, k, dir, 1, tau, dx);
3318  adverse += amrex::max(Real(0.0), -left_delta) +
3319  amrex::max(Real(0.0), -right_delta);
3320  gross += face_gross(descriptor, local_terms, low_faces,
3321  high_faces, i, j, k, dir, -1, tau, dx) +
3322  face_gross(descriptor, local_terms, low_faces,
3323  high_faces, i, j, k, dir, 1, tau, dx);
3324  }
3325  if (!amrex::Math::isfinite(margin) ||
3326  !amrex::Math::isfinite(adverse) ||
3327  margin < -roundoff * scale) {
3328  bad = 1;
3329  }
3330  ratios(i, j, k, ratio_offset + ci) =
3331  budget_ratio(margin, adverse, scale + gross, roundoff);
3332  }
3333 
3334  for (int si = 0; si < support_count; ++si) {
3335  const auto& support =
3336  local_supports[supports_begin + si];
3337  Real donor_min = std::numeric_limits<Real>::infinity();
3338  Real donor_max = -std::numeric_limits<Real>::infinity();
3339  int found = 0;
3340  include_neighbourhood(base, i, j, k, support, donor_min,
3341  donor_max, found);
3342  include_neighbourhood(input, i, j, k, support,
3343  donor_min, donor_max, found);
3344  include_neighbourhood(anchor, i, j, k, support,
3345  donor_min, donor_max, found);
3346  Real support_min = found != 0 ? donor_min : Real(0.0);
3347  Real support_max = found != 0 ? donor_max : Real(0.0);
3348  if (found != 0 && support.has_hard_min != 0) {
3349  support_min =
3350  amrex::max(support_min, support.hard_min);
3351  }
3352  if (found != 0 && support.has_hard_max != 0) {
3353  support_max =
3354  amrex::min(support_max, support.hard_max);
3355  }
3356  if (!amrex::Math::isfinite(support_min) ||
3357  !amrex::Math::isfinite(support_max) ||
3358  support_min > support_max) {
3359  bad = 1;
3360  }
3361 
3362  const Real property =
3363  hlow(i, j, k, support.property_local);
3364  const Real carrier =
3365  hlow(i, j, k, support.carrier_local);
3366  for (int side = 0; side < 2; ++side) {
3367  const bool upper = side != 0;
3368  const Real slope =
3369  upper ? support_max : support_min;
3370  const Real margin =
3371  upper ? slope * carrier - property
3372  : property - slope * carrier;
3373  const Real scale =
3374  amrex::Math::abs(property) +
3375  amrex::Math::abs(slope * carrier);
3376  Real adverse = Real(0.0);
3377  Real gross = Real(0.0);
3378  for (int dir = 0; dir < AMREX_SPACEDIM; ++dir) {
3379  const Real left_delta =
3381  support, low_faces, high_faces, i, j, k,
3382  dir, -1, tau, dx, slope, upper);
3383  const Real right_delta =
3385  support, low_faces, high_faces, i, j, k,
3386  dir, 1, tau, dx, slope, upper);
3387  adverse += amrex::max(Real(0.0), -left_delta) +
3388  amrex::max(Real(0.0), -right_delta);
3389  for (const int side_of_cell : {-1, 1}) {
3390  gross += pair_face_gross(
3391  support.property_local, support.carrier_local,
3392  Real(1.0), slope, low_faces, high_faces, i, j, k,
3393  dir, side_of_cell, tau, dx);
3394  }
3395  }
3396  if (!amrex::Math::isfinite(margin) ||
3397  !amrex::Math::isfinite(adverse) ||
3398  margin < -roundoff * scale) {
3399  bad = 1;
3400  }
3401  const int ratio_component =
3402  ratio_offset + linear_count + 2 * si + side;
3403  ratios(i, j, k, ratio_component) =
3404  budget_ratio(margin, adverse, scale + gross, roundoff);
3405  }
3406  }
3407 
3408  if (canonical_reserve != 0) {
3409  // This transport-only reserve joins the existing
3410  // closed FCT ratios; final canonical admission stays
3411  // the authoritative persisted-state check.
3412  const Real reserve = std::fma(
3413  canonical_mass_coefficient,
3414  hlow(i, j, k, canonical_mass_local),
3415  canonical_number_coefficient *
3416  hlow(i, j, k, canonical_number_local));
3417  Real adverse = Real(0.0);
3418  Real gross = Real(0.0);
3419  for (int dir = 0; dir < AMREX_SPACEDIM; ++dir) {
3420  const Real left_delta =
3422  canonical_mass_local,
3423  canonical_number_local,
3424  canonical_mass_coefficient,
3425  canonical_number_coefficient, low_faces,
3426  high_faces, i, j, k, dir, -1, tau, dx);
3427  const Real right_delta =
3429  canonical_mass_local,
3430  canonical_number_local,
3431  canonical_mass_coefficient,
3432  canonical_number_coefficient, low_faces,
3433  high_faces, i, j, k, dir, 1, tau, dx);
3434  adverse += amrex::max(Real(0.0), -left_delta) +
3435  amrex::max(Real(0.0), -right_delta);
3436  for (const int side_of_cell : {-1, 1}) {
3437  gross += pair_face_gross(
3438  canonical_mass_local, canonical_number_local,
3439  canonical_mass_coefficient,
3440  canonical_number_coefficient, low_faces,
3441  high_faces, i, j, k, dir, side_of_cell, tau, dx);
3442  }
3443  }
3444  const Real reserve_scale =
3445  amrex::Math::abs(canonical_mass_coefficient *
3446  hlow(i, j, k, canonical_mass_local)) +
3447  amrex::Math::abs(canonical_number_coefficient *
3448  hlow(i, j, k, canonical_number_local));
3449  const int ratio_component =
3450  ratio_offset + linear_count + 2 * support_count;
3451  if (!amrex::Math::isfinite(reserve) ||
3452  !amrex::Math::isfinite(adverse)) {
3453  bad = 1;
3454  ratios(i, j, k, ratio_component) = Real(0.0);
3455  } else if (reserve <= Real(0.0)) {
3456  ratios(i, j, k, ratio_component) = Real(0.0);
3457  } else {
3458  ratios(i, j, k, ratio_component) = budget_ratio(
3459  reserve, adverse, reserve_scale + gross, roundoff);
3460  }
3461  }
3462  if (bad != 0) {
3463  invalid(i, j, k, 0) = Real(1.0);
3464  }
3465  });
3466  }
3467  }
3468 
3469  // Every complete group has now written its own ratio components.
3470  // Exchange the chunk's ratio halo once before any group reads it.
3471  data.cell_ratios.FillBoundary(geometry.periodicity());
3472  if (mixing_active) {
3473  open_face_ratio_ghosts(data.cell_ratios, geometry, m_boundaries);
3474  }
3475  if (data.invalid.max(0) != Real(0.0)) {
3476  std::ostringstream message;
3477  message.precision(17);
3478  message << "SBM M3 donor low-order trial violates a linear or "
3479  << "attached-property/canonical-reserve constraint "
3480  << "(level=" << level << ", stage=" << stage
3481  << ", input_time=" << input_time
3482  << ", target_time=" << target_time
3483  << ", chunk=" << chunk_index << ", rank="
3484  << amrex::ParallelDescriptor::MyProc() << ')';
3485  amrex::Abort(message.str());
3486  }
3487 
3488  for (const int group_index : chunk.group_indices) {
3489  const auto& group = m_groups[static_cast<std::size_t>(group_index)];
3490  const auto& group_device =
3491  device.host_groups[static_cast<std::size_t>(group_index)];
3492  AMREX_ALWAYS_ASSERT(group_device.ratio_offset >= 0);
3493  AMREX_ALWAYS_ASSERT(group_device.ratio_count >= 0);
3495  group_device.ratio_offset <= data.cell_ratios.nComp());
3497  group_device.ratio_count <=
3498  data.cell_ratios.nComp() - group_device.ratio_offset);
3499 
3500  // Each face/group lambda is the minimum budget from both
3501  // adjacent cells and every constraint in the complete group.
3502  for (int dir = 0; dir < AMREX_SPACEDIM; ++dir) {
3503  auto& lambda_field = data.face_lambda.dir(dir);
3504  for (amrex::MFIter mfi(lambda_field, amrex::TilingIfNotGPU());
3505  mfi.isValid(); ++mfi) {
3506  const amrex::Box bx = mfi.tilebox();
3507  const auto ratios = data.cell_ratios.const_array(mfi);
3508  const auto lambda = lambda_field.array(mfi);
3509  const int ratio_count = group_device.ratio_count;
3510  const int ratio_offset = group_device.ratio_offset;
3511  amrex::ParallelFor(bx, [=] AMREX_GPU_DEVICE(
3512  int i, int j, int k) noexcept {
3513  int li = i, lj = j, lk = k;
3514  if (dir == 0) {
3515  --li;
3516  } else if (dir == 1) {
3517  --lj;
3518  } else {
3519  --lk;
3520  }
3521  Real accepted = Real(1.0);
3522  for (int c = 0; c < ratio_count; ++c) {
3523  accepted =
3524  amrex::min(accepted,
3525  ratios(li, lj, lk, ratio_offset + c));
3526  accepted = amrex::min(
3527  accepted, ratios(i, j, k, ratio_offset + c));
3528  }
3529  lambda(i, j, k, 0) = clamp_unit(accepted);
3530  });
3531  }
3532  }
3533 
3534  for (int dir = 0; dir < AMREX_SPACEDIM; ++dir) {
3535  auto& accepted_field = data.accepted_rate.dir(dir);
3536  const auto& low_field = data.low_rate.dir(dir);
3537  const auto& high_field = data.high_rate.dir(dir);
3538  const auto& lambda_field = data.face_lambda.dir(dir);
3539  for (amrex::MFIter mfi(accepted_field, amrex::TilingIfNotGPU());
3540  mfi.isValid(); ++mfi) {
3541  const amrex::Box bx = mfi.tilebox();
3542  const auto low = low_field.const_array(mfi);
3543  const auto high = high_field.const_array(mfi);
3544  const auto lambda = lambda_field.const_array(mfi);
3545  const auto accepted = accepted_field.array(mfi);
3546  for (const int component : group.members) {
3547  const int local_component =
3548  global_to_local[static_cast<std::size_t>(
3549  component)];
3550  AMREX_ALWAYS_ASSERT(local_component >= 0);
3552  bx,
3553  [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept {
3554  const Real alpha = lambda(i, j, k, 0);
3555  accepted(i, j, k, local_component) =
3556  low(i, j, k, local_component) +
3557  alpha * (high(i, j, k, local_component) -
3558  low(i, j, k, local_component));
3559  });
3560  }
3561  }
3562  }
3563 
3564  // A small-grid scientific oracle may observe one group's native
3565  // post-FCT face values.
3566  if (parent != nullptr) {
3567  for (const auto* probe :
3568  {parent->ghost_probe, parent->secondary_ghost_probe}) {
3570  probe, stage, group.members, global_to_local,
3571  data.accepted_rate, data.high_rate, data.low_rate,
3572  data.face_lambda);
3573  }
3574  }
3575 
3576 #ifdef ERF_SBM_AMR_QUALIFICATION
3577  // Qualification-only evidence: record a group when any accepted
3578  // face limiter is below one, and separately prove that at least
3579  // one accepted face rate differs from its unlimited high rate.
3580  data.outgoing_demand.setVal(Real(0.0));
3581  for (amrex::MFIter mfi(data.outgoing_demand,
3582  amrex::TilingIfNotGPU());
3583  mfi.isValid(); ++mfi) {
3584  const amrex::Box bx = mfi.tilebox();
3585  const auto marker = data.outgoing_demand.array(mfi);
3586  const auto lambda_x = data.face_lambda.dir(0).const_array(mfi);
3587  const auto lambda_y = data.face_lambda.dir(1).const_array(mfi);
3588  const auto lambda_z = data.face_lambda.dir(2).const_array(mfi);
3589  amrex::ParallelFor(bx,
3590  [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept {
3591  int active = 0;
3592  active |= lambda_x(i, j, k, 0) < Real(1.0) ||
3593  lambda_x(i + 1, j, k, 0) < Real(1.0);
3594  active |= lambda_y(i, j, k, 0) < Real(1.0) ||
3595  lambda_y(i, j + 1, k, 0) < Real(1.0);
3596  active |= lambda_z(i, j, k, 0) < Real(1.0) ||
3597  lambda_z(i, j, k + 1, 0) < Real(1.0);
3598  marker(i, j, k, 0) = active ? Real(1.0) : Real(0.0);
3599  });
3600  }
3601  for (const int component : group.transport_members) {
3602  const int local_component =
3603  global_to_local[static_cast<std::size_t>(component)];
3604  AMREX_ALWAYS_ASSERT(local_component >= 0);
3605  for (int dir = 0; dir < AMREX_SPACEDIM; ++dir) {
3606  const auto& high_field = data.high_rate.dir(dir);
3607  const auto& accepted_field = data.accepted_rate.dir(dir);
3608  const auto& lambda_field = data.face_lambda.dir(dir);
3609  for (amrex::MFIter mfi(data.outgoing_demand,
3610  amrex::TilingIfNotGPU());
3611  mfi.isValid(); ++mfi) {
3612  const amrex::Box bx = mfi.tilebox();
3613  const auto high = high_field.const_array(mfi);
3614  const auto accepted = accepted_field.const_array(mfi);
3615  const auto lambda = lambda_field.const_array(mfi);
3616  const auto marker = data.outgoing_demand.array(mfi);
3617  amrex::ParallelFor(bx,
3618  [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept {
3619  int changed = 0;
3620  for (int side = 0; side < 2; ++side) {
3621  const int fi = i + (dir == 0 && side != 0);
3622  const int fj = j + (dir == 1 && side != 0);
3623  const int fk = k + (dir == 2 && side != 0);
3624  if (lambda(fi, fj, fk, 0) < Real(1.0) &&
3625  accepted(fi, fj, fk, local_component) !=
3626  high(fi, fj, fk, local_component)) {
3627  changed = 1;
3628  }
3629  }
3630  if (changed != 0) marker(i, j, k, 0) = Real(2.0);
3631  });
3632  }
3633  }
3634  }
3635  const Real limiter_marker = data.outgoing_demand.max(0, 0);
3636  if (limiter_marker >= Real(1.0)) {
3638  }
3639  if (limiter_marker >= Real(2.0)) {
3641  }
3642 #endif
3643 
3644  // Accumulate only the accepted spectral mass rate into the
3645  // two-component fixed liquid projection ledger.
3646  const auto& projection_spec = m_layout.liquid_projection();
3647  if (group.population_id == projection_spec.population_id) {
3648  const int mass_component =
3649  m_layout.mass_offset(group.population_id) + group.bin;
3650  const int local_mass =
3651  global_to_local[static_cast<std::size_t>(mass_component)];
3652  const int projected_component =
3653  group.bin < projection_spec.cloud_rain_split ? 0 : 1;
3654  for (int dir = 0; dir < AMREX_SPACEDIM; ++dir) {
3655  MultiFab::Saxpy(data.projected_rate.dir(dir), Real(1.0),
3656  data.accepted_rate.dir(dir), local_mass,
3657  projected_component, 1, 0);
3658  }
3659  }
3660  }
3661 
3662  // Qualification-only zero-flow evidence records the accepted face
3663  // rates after complete-group FCT, including mass, number and attached
3664  // components. The expensive collective norms are disabled in all
3665  // other qualification cases and production builds.
3666 #ifdef ERF_SBM_AMR_QUALIFICATION
3668  for (int dir = 0; dir < AMREX_SPACEDIM; ++dir) {
3669  const auto& accepted = data.accepted_rate.dir(dir);
3670  m_interval_accepted_rate_linf = std::max(
3672  accepted.norm0(0, accepted.nComp(), amrex::IntVect(0)));
3673  }
3674  }
3675 #endif
3676 
3677  // Hand the accepted, chunk-local rates directly to the YA interface
3678  // register. The owner keeps these additions pending until the full
3679  // physical step is admitted by ERF::Advance.
3680  if (data.interface_as_coarse &&
3681  !data.interface_as_coarse->add_stage_rates(
3682  true, data.accepted_rate, chunk.components,
3683  recipe.completed_ledger_time, diagnostic)) {
3684  amrex::Abort("SBM YA coarse-side accepted-rate accumulation: " + diagnostic);
3685  }
3686  if (data.interface_as_fine &&
3687  !data.interface_as_fine->add_stage_rates(
3688  false, data.accepted_rate, chunk.components,
3689  recipe.completed_ledger_time, diagnostic)) {
3690  amrex::Abort("SBM YA fine-side accepted-rate accumulation: " + diagnostic);
3691  }
3692  if (record_boundary) {
3693  const MultiFab* covered = data.interface_as_coarse
3694  ? &data.interface_as_coarse->covered_parent_mask() : nullptr;
3695  if (covered != nullptr &&
3696  (!covered->boxArray().CellEqual(data.accepted_rate.dir(0).boxArray()) ||
3697  covered->DistributionMap() != data.accepted_rate.dir(0).DistributionMap())) {
3698  amrex::Abort("SBM boundary ledger: the covered-parent mask does not "
3699  "share the level layout");
3700  }
3702  data.accepted_rate,
3703  device.chunk_components.data() + device.chunk_offsets[chunk_index],
3704  static_cast<int>(chunk.components.size()), geometry, covered,
3705  m_layout.ncomp(), data.boundary_partial.data(),
3706  data.boundary_stage.back());
3707  }
3708 
3709  // Apply the ERF stage recurrence component by component while using
3710  // this bounded complete-group chunk's accepted face rates.
3711  for (std::size_t local = 0; local < chunk.components.size(); ++local) {
3712  const int component = chunk.components[local];
3714  context.method = method;
3715  context.level = level;
3716  context.stage = stage;
3717  context.step_old_time = step_old_time;
3718  context.input_time = input_time;
3719  context.target_time = target_time;
3720  context.recurrence = recipe;
3721  context.state_anchor = {&data.anchor, component, step_old_time};
3722  context.state_input = {&spectrum, component, input_time};
3723  context.state_target = {&data.target, component, target_time};
3724  context.rho_anchor = {&conserved_anchor, Rho_comp, step_old_time};
3725  context.rho_input = {&conserved_input, Rho_comp, input_time};
3726  context.rho_target = {&conserved_target, Rho_comp, target_time};
3727  context.measure_anchor = {&data.measure, 0, step_old_time};
3728  context.measure_input = {&data.measure, 0, input_time};
3729  context.measure_target = {&data.measure, 0, target_time};
3730  context.carrier = {&avg_xmom, &avg_ymom, &avg_zmom};
3732  context, data.accepted_rate, inv_dx, static_cast<int>(local));
3733  }
3734 
3735  if (data.spectral_ledger.is_defined()) {
3736  for (std::size_t local = 0; local < chunk.components.size(); ++local) {
3737  if (!data.spectral_ledger.accumulate_stage_component(
3738  data.accepted_rate, static_cast<int>(local),
3739  chunk.components[local], diagnostic)) {
3740  amrex::Abort("SBM M4a spectral chunk-to-ledger mapping: " +
3741  diagnostic);
3742  }
3743  }
3744  }
3745  }
3746 
3747  // Reuse the same persistent full-state gate used by AMR publication.
3748  // Successful candidates are decided on device without a host FAB scan.
3749  if (!m_admission->admissible(data.target, level, diagnostic)) {
3750  amrex::Abort("SBM M3 candidate rejected before commit: " + diagnostic);
3751  }
3752 
3753  // Only fully admitted candidates may finish an authoritative spectral
3754  // ledger stage. Chunk calls above accumulate components without advancing
3755  // the host stage sequence.
3756  // Ledger admission is MPI-collective: every rank on this level must enter
3757  // despite local recoverable errors; do not branch around these calls using
3758  // rank-local predicates.
3759  if (data.spectral_ledger.is_defined() &&
3760  !data.spectral_ledger.finish_stage(diagnostic)) {
3761  amrex::Abort("SBM M4a spectral face-ledger stage finish: " + diagnostic);
3762  }
3763  // Retain the existing two-component projected ledger and its exact host
3764  // stage recipe independently of the full spectral integral.
3765  if (!data.projected_ledger.accept_stage(method, stage, step_old_time,
3766  recipe, data.projected_rate,
3767  diagnostic)) {
3768  amrex::Abort("SBM M3 projected face-ledger stage sequence: " +
3769  diagnostic);
3770  }
3771  MultiFab::Copy(state_manager.new_target_storage(level), data.target, 0, 0,
3772  m_layout.ncomp(), 0);
3773  const int stage_count = erf_auxiliary::HostIntegratorStageCount(method);
3774  const bool physical_step_complete = stage + 1 == stage_count;
3775  if (!state_manager.accept_stage_target(level, target_time,
3776  physical_step_complete, diagnostic)) {
3777  amrex::Abort("SBM M4a accepted-state lifecycle commit: " + diagnostic);
3778  }
3779  if (record_boundary) {
3780  // Sum the boxes in local order, then copy the stage totals once.
3781  const double* partial = data.boundary_partial.data();
3782  double* total = data.boundary_total.data();
3783  amrex::ParallelFor(boundary_slots,
3784  [=] AMREX_GPU_DEVICE(int slot) noexcept {
3785  double sum = 0.0;
3786  for (int box = 0; box < boundary_boxes; ++box) {
3787  sum += partial[box * boundary_slots + slot];
3788  }
3789  total[slot] = sum;
3790  });
3791  amrex::Gpu::copy(amrex::Gpu::deviceToHost, data.boundary_total.begin(),
3792  data.boundary_total.end(), data.boundary_stage.begin());
3793  amrex::ParallelAllReduce::Sum(data.boundary_stage.data(),
3794  static_cast<int>(data.boundary_stage.size()),
3795  amrex::ParallelContext::CommunicatorSub());
3796  for (std::size_t slot = 0; slot < data.boundary_step.size(); ++slot) {
3797  data.boundary_step[slot] +=
3798  recipe.completed_ledger_time * data.boundary_stage[slot];
3799  }
3800  data.boundary_step_terms +=
3801  static_cast<std::uint64_t>(data.boundary_stage.back());
3802  }
3803  if (physical_faces && physical_step_complete) {
3804  for (std::size_t slot = 0; slot < m_boundary_ledger.outward.size(); ++slot) {
3805  m_boundary_ledger.outward[slot] += data.boundary_step[2 * slot];
3806  m_boundary_ledger.gross[slot] += data.boundary_step[2 * slot + 1];
3807  }
3808  m_boundary_ledger.face_stage_terms += data.boundary_step_terms;
3809  std::fill(data.boundary_step.begin(), data.boundary_step.end(), 0.0);
3810  data.boundary_step_terms = 0;
3811  }
3812  if (data.interface_as_coarse &&
3813  !data.interface_as_coarse->finish_stage(true, diagnostic)) {
3814  amrex::Abort("SBM YA coarse-side stage admission: " + diagnostic);
3815  }
3816  if (data.interface_as_fine &&
3817  !data.interface_as_fine->finish_stage(false, diagnostic)) {
3818  amrex::Abort("SBM YA fine-side stage admission: " + diagnostic);
3819  }
3820  state_manager.project_to_core(level, conserved_target, qc_component,
3821  qr_component);
3822  if (profile_parent_fill) {
3823  AMREX_ALWAYS_ASSERT(stage >= 0 &&
3824  stage < static_cast<int>(data.profile_stage_seconds.size()));
3825  data.profile_stage_seconds[static_cast<std::size_t>(stage)] =
3826  std::chrono::duration<double>(ProfileClock::now() -
3827  profile_stage_start).count();
3828  std::cout << std::setprecision(9)
3829  << "SBM_AMR_PROFILE_STAGE rank="
3830  << amrex::ParallelDescriptor::MyProc()
3831  << " level=" << level << " stage=" << stage
3832  << " ncomp=" << m_layout.ncomp()
3833  << " stage_wall_s="
3834  << data.profile_stage_seconds[static_cast<std::size_t>(stage)]
3835  << std::endl;
3836  if (physical_step_complete) {
3837  double stage_sum = 0.0;
3838  for (int s = 0; s < stage_count; ++s) {
3839  stage_sum += data.profile_stage_seconds[static_cast<std::size_t>(s)];
3840  }
3841  std::cout << std::setprecision(9)
3842  << "SBM_AMR_PROFILE_FINE_STEP rank="
3843  << amrex::ParallelDescriptor::MyProc()
3844  << " level=" << level
3845  << " ncomp=" << m_layout.ncomp()
3846  << " fine_step_wall_s="
3847  << std::chrono::duration<double>(
3848  ProfileClock::now() -
3849  data.profile_fine_step_start).count()
3850  << " summed_stage_wall_s=" << stage_sum
3851  << std::endl;
3852  }
3853  }
3854 }
GpuArray< Real, AMREX_SPACEDIM > dx
Definition: ERF_ActuatorSpreading.cpp:131
int count
Definition: ERF_ActuatorSpreading.cpp:264
void BuildScalarAdvectionFluxes(const amrex::Box &bx, const amrex::Array4< const amrex::Real > &scalar, const int scalar_comp, const amrex::GpuArray< const amrex::Array4< amrex::Real >, AMREX_SPACEDIM > &flx_arr, const int flux_comp, const amrex::Array4< const amrex::Real > &avg_xmom, const amrex::Array4< const amrex::Real > &avg_ymom, const amrex::Array4< const amrex::Real > &avg_zmom, const AdvType horiz_adv_type, const AdvType vert_adv_type, const amrex::Real horiz_upw_frac, const amrex::Real vert_upw_frac)
Definition: ERF_AdvectionSrcForScalars.H:342
#define Rho_comp
Definition: ERF_IndexDefines.H:61
const Real dy
Definition: ERF_InitCustomPert_ABL.H:101
AMREX_ALWAYS_ASSERT_WITH_MESSAGE(axis >=0 &&axis< AMREX_SPACEDIM, "prob.axis must be 0, 1 or 2")
for(int i=0;i< m_num_species;i++)
Definition: ERF_InitCustomPert_MultiSpeciesBubble.H:52
std::string message
Definition: ERF_InputPreflight.cpp:25
std::string input
Definition: ERF_InputPreflight.cpp:29
ParallelFor(fab_box, [=] AMREX_GPU_DEVICE(int i, int j, int k) { qrcuten_arr(i, j, k)=Real(0);qscuten_arr(i, j, k)=Real(0);qicuten_arr(i, j, k)=Real(0);})
int mass_offset(const int population) const
Definition: ERF_SBMLayout.cpp:179
const LiquidProjectionSpec & liquid_projection() const noexcept
Definition: ERF_SBMLayout.H:102
bool m_terrain_match
Definition: ERF_SBMTransport.H:308
ParticleMixingConfig m_mixing
Definition: ERF_SBMTransport.H:306
amrex::Gpu::DeviceVector< amrex::Real > m_inflow_device
Definition: ERF_SBMTransport.H:304
amrex::Real m_interval_carrier_linf
Definition: ERF_SBMTransport.H:318
SBMPhysicalBoundaryConfig m_boundaries
Definition: ERF_SBMTransport.H:303
bool m_zero_flow_diagnostics_enabled
Definition: ERF_SBMTransport.H:311
bool m_interval_limiter_changed_rate
Definition: ERF_SBMTransport.H:317
amrex::Gpu::DeviceVector< amrex::BCRec > m_mixing_bc
Definition: ERF_SBMTransport.H:309
std::array< bool, 2 > m_split_ghost_values_checked
Definition: ERF_SBMTransport.H:314
amrex::Real m_interval_accepted_rate_linf
Definition: ERF_SBMTransport.H:319
int m_interval_limiter_active_groups
Definition: ERF_SBMTransport.H:316
@ fi
Definition: ERF_AdvanceMorrison.cpp:109
@ rho
Definition: ERF_Kessler.H:25
@ omega
Definition: ERF_Morrison.H:57
@ total
Definition: ERF_NOAHMP_Fields.H:137
@ alpha
Definition: ERF_SLM.H:153
@ dz
Definition: ERF_AdvanceWDM6.cpp:273
@ t
Definition: ERF_WSM6.H:295
void ApplyAuxiliaryMappedStage(const AuxiliaryStageContext &context, const MappedFaceFluxRate &rate, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &dx_inv, const int rate_component)
Definition: ERF_AuxiliaryStage.cpp:169
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real MappedCombinedOutgoingDemandRate(const amrex::Real fx_hi, const amrex::Real fx_lo, const amrex::Real fy_hi, const amrex::Real fy_lo, const amrex::Real fz_hi, const amrex::Real fz_lo, const amrex::Real tx_hi, const amrex::Real tx_lo, const amrex::Real ty_hi, const amrex::Real ty_lo, const amrex::Real tz_hi, const amrex::Real tz_lo, const amrex::Real measure, const amrex::Real density, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &dx_inv) noexcept
Definition: ERF_AuxiliaryDiffusion.H:146
int HostIntegratorStageCount(const HostIntegrator method) noexcept
Definition: ERF_AuxiliaryStage.cpp:47
bool MakeAuxiliaryStageRecipe(const HostIntegrator method, const int stage, const double host_stage_interval, AuxiliaryStageRecipe &recipe, std::string &diagnostic)
Definition: ERF_AuxiliaryStage.cpp:67
bool ValidatePositiveFiniteComponent(const amrex::MultiFab &field, const int component, std::string &diagnostic)
Definition: ERF_AuxiliaryMappedTransport.cpp:291
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real ComputationalMappedDivergence(const amrex::Real fx_hi, const amrex::Real fx_lo, const amrex::Real fy_hi, const amrex::Real fy_lo, const amrex::Real fz_hi, const amrex::Real fz_lo, const amrex::Real dx_inv, const amrex::Real dy_inv, const amrex::Real dzeta_inv) noexcept
Definition: ERF_AuxiliaryMappedTransport.H:123
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real MappedOutgoingDemandRate(const amrex::Real fx_hi, const amrex::Real fx_lo, const amrex::Real fy_hi, const amrex::Real fy_lo, const amrex::Real fz_hi, const amrex::Real fz_lo, const amrex::Real measure, const amrex::Real density, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &dx_inv) noexcept
Definition: ERF_AuxiliaryMappedTransport.H:140
bool SameCellLayout(const amrex::MultiFab &lhs, const amrex::MultiFab &rhs)
Definition: ERF_AuxiliaryMappedTransport.cpp:33
void add_high_order_mixing(erf_auxiliary::MappedFaceFluxRate &high, erf_auxiliary::MappedFaceFluxRate &scratch, const ParticleMixingConfig &config, const SBMStageMixingInputs &inputs, const amrex::BCRec *bc, const erf_auxiliary::MappedDiffusionBoundary &boundary, const amrex::Geometry &geometry, const MultiFab &input_intensive, const MultiFab &input_conserved, const std::vector< int > &components)
Definition: ERF_SBMTransport.cpp:293
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real face_correction(const erf_sbm::ConstraintDescriptor &descriptor, const erf_sbm::ConstraintTerm *terms, const FaceArraySet &low, const FaceArraySet &high, const int i, const int j, const int k, const int dir, const int side, const Real tau, const GpuArray< Real, AMREX_SPACEDIM > &dx_inv) noexcept
Definition: ERF_SBMTransport.cpp:1576
void build_terrain_high_order_mixing(erf_auxiliary::MappedFaceFluxRate &diffusive, MultiFab &scalar, std::array< MultiFab, AMREX_SPACEDIM > &raw, const std::array< MultiFab, 2 > &side_open, const ParticleMixingConfig &config, const SBMStageMixingInputs &inputs, const amrex::BCRec *bc, const amrex::Geometry &geometry, const MultiFab &input_intensive, const MultiFab &input_conserved, const std::vector< int > &components)
Definition: ERF_SBMTransport.cpp:532
void check_physical_face_carriers(const std::array< const MultiFab *, AMREX_SPACEDIM > &carrier, const amrex::Geometry &geometry, const SBMPhysicalBoundaryConfig &boundaries, const int level, const int stage)
Definition: ERF_SBMTransport.cpp:825
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real face_gross(const erf_sbm::ConstraintDescriptor &descriptor, const erf_sbm::ConstraintTerm *terms, const FaceArraySet &low, const FaceArraySet &high, const int i, const int j, const int k, const int dir, const int side, const Real tau, const GpuArray< Real, AMREX_SPACEDIM > &dx_inv) noexcept
Definition: ERF_SBMTransport.cpp:1606
void build_intensive(MultiFab &intensive, const MultiFab &state, const MultiFab &conserved, const amrex::Periodicity &periodicity, const char *what)
Definition: ERF_SBMTransport.cpp:116
void accumulate_boundary_rates(const erf_auxiliary::MappedFaceFluxRate &accepted, const int *components, const int component_count, const amrex::Geometry &geometry, const MultiFab *covered, const int ncomp, double *partial, double &face_terms)
Definition: ERF_SBMTransport.cpp:888
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real pair_face_gross(const int first, const int second, const Real first_coefficient, const Real second_coefficient, const FaceArraySet &low, const FaceArraySet &high, const int i, const int j, const int k, const int dir, const int side, const Real tau, const GpuArray< Real, AMREX_SPACEDIM > &dx_inv) noexcept
Definition: ERF_SBMTransport.cpp:1635
void add_matched_terrain_mixing(erf_auxiliary::MappedFaceFluxRate &low, erf_auxiliary::MappedFaceFluxRate &high, const erf_auxiliary::MappedFaceFluxRate &diffusive, const erf_auxiliary::MappedFaceTransmissibility &transmissibility, const amrex::Geometry &geometry, const MultiFab &base_intensive, const int *chunk_components, const MatchingGroup *groups, const int group_count, const int *members, const ConstraintDescriptor *coordinates, const ConstraintTerm *terms, const bool match)
Definition: ERF_SBMTransport.cpp:710
void fill_coarse_parent_ghosts(MultiFab &destination, MultiFab &missing_fine_ghosts, const MultiFab &coarse_old_spectrum, const MultiFab &coarse_new_spectrum, const MultiFab &fine_source_state, const MultiFab &fine_source_conserved, const SBMAMRStageParent &parent, const amrex::Geometry &fine_geometry, const std::vector< ConstraintClosureChunk > &chunks, const int max_chunk_components, const double requested_time, const double coarse_old_spectrum_time, const double coarse_new_spectrum_time, const int level, const int stage, const char *role, MultiFab &coarse_pack, MultiFab &coarse_stage, const SBMAMRStageGhostProbe *probe=nullptr, std::array< bool, 2 > *split_values_checked=nullptr)
Definition: ERF_SBMTransport.cpp:1023
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real property_face_correction(const LocalPropertySupport &support, const FaceArraySet &low, const FaceArraySet &high, const int i, const int j, const int k, const int dir, const int side, const Real tau, const GpuArray< Real, AMREX_SPACEDIM > &dx_inv, const Real slope, const bool upper) noexcept
Definition: ERF_SBMTransport.cpp:1702
void fill_side_open_mask(MultiFab &mask, const int dir, const erf_auxiliary::MappedDiffusionBoundary &boundary, const amrex::Geometry &geometry)
Definition: ERF_SBMTransport.cpp:492
void open_face_ratio_ghosts(MultiFab &ratios, const amrex::Geometry &geometry, const SBMPhysicalBoundaryConfig &boundaries)
Definition: ERF_SBMTransport.cpp:790
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void include_neighbourhood(const Array4< const Real > &field, const int i, const int j, const int k, const LocalPropertySupport &support, Real &lower, Real &upper, int &found) noexcept
Definition: ERF_SBMTransport.cpp:1757
void add_low_order_mixing(erf_auxiliary::MappedFaceFluxRate &low, erf_auxiliary::MappedFaceFluxRate &scratch, const erf_auxiliary::MappedFaceTransmissibility &transmissibility, const amrex::Geometry &geometry, const MultiFab &base_intensive, const std::vector< int > &components)
Definition: ERF_SBMTransport.cpp:272
void sample_probe_endpoint_value(const SBMAMRStageGhostProbe *probe, const int stage, const MultiFab &endpoint_input)
Definition: ERF_SBMTransport.cpp:1778
void sample_probe_face_rates(const SBMAMRStageGhostProbe *probe, const int stage, const std::vector< int > &members, const std::vector< int > &global_to_local, const erf_auxiliary::MappedFaceFluxRate &accepted_rate, const erf_auxiliary::MappedFaceFluxRate &high_rate, const erf_auxiliary::MappedFaceFluxRate &low_rate, const erf_auxiliary::MappedFaceFluxRate &face_lambda)
Definition: ERF_SBMTransport.cpp:1843
void apply_physical_donor_band(erf_auxiliary::MappedFaceFluxRate &high, const erf_auxiliary::MappedFaceFluxRate &low, const amrex::Geometry &geometry)
Definition: ERF_SBMTransport.cpp:226
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real budget_ratio(const Real margin, const Real adverse, const Real scale, const Real roundoff) noexcept
Definition: ERF_SBMTransport.cpp:1665
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real clamp_unit(const Real value) noexcept
Definition: ERF_SBMTransport.cpp:110
void sample_probe_stencil(const SBMAMRStageGhostProbe *probe, const int stage, const MultiFab &physical_input, const MultiFab &endpoint_input)
Definition: ERF_SBMTransport.cpp:1803
void fill_physical_ghosts(MultiFab &field, const amrex::Geometry &geometry, const SBMPhysicalBoundaryConfig &boundaries, const Real *inflow_device)
Definition: ERF_SBMTransport.cpp:155
std::string shared_metric_mismatch(const erf_auxiliary::MappedDiffusionMetrics &metrics, const amrex::Geometry &geometry)
Definition: ERF_SBMTransport.cpp:656
GpuArray< Array4< const Real >, AMREX_SPACEDIM > FaceArraySet
Definition: ERF_SBMTransport.cpp:46
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real canonical_reserve_face_correction(const int mass_component, const int number_component, const Real mass_coefficient, const Real number_coefficient, const FaceArraySet &low, const FaceArraySet &high, const int i, const int j, const int k, const int dir, const int side, const Real tau, const GpuArray< Real, AMREX_SPACEDIM > &dx_inv) noexcept
Definition: ERF_SBMTransport.cpp:1673
const char * particle_mixing_name(const ParticleMixingPolicy policy) noexcept
Definition: ERF_SBMParticleMixing.cpp:17
bool build_particle_mixing_transmissibility(const ParticleMixingConfig &config, const amrex::Geometry &geom, const erf_auxiliary::MappedDiffusionMetrics &metrics, const amrex::MultiFab &density, const int density_component, const amrex::MultiFab *eddy_diffusivity, erf_auxiliary::MappedFaceTransmissibility &transmissibility, std::string &diagnostic)
Definition: ERF_SBMParticleMixing.cpp:303
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool try_two_moment_to_endpoints(const amrex::Real C, const amrex::Real M, const amrex::Real lower, const amrex::Real upper, EndpointTransform &result) noexcept
Definition: ERF_SpectralGrid.H:48
const char * face_name(const int face) noexcept
Definition: ERF_SBMPhysicalBoundary.cpp:70
erf_auxiliary::MappedDiffusionBoundary particle_mixing_boundary(const SBMPhysicalBoundaryConfig &boundaries, const std::array< const amrex::MultiFab *, AMREX_SPACEDIM > &carrier)
Definition: ERF_SBMParticleMixing.cpp:428
constexpr int physical_face_count
Definition: ERF_SBMPhysicalBoundary.H:19
real(c_double), private ci
Definition: ERF_module_mp_morr_two_moment.F90:203
void fill(MultiFab &dst, int temperature_comp, int mixing_ratio_comp, int source_comp, const Sources &sources, Real missing_value)
Definition: ERF_NearSurfaceDiagnostics.cpp:42
Definition: ERF_AuxiliaryStage.H:63
int level
Definition: ERF_AuxiliaryStage.H:65
ConstTimedFieldView rho_anchor
Definition: ERF_AuxiliaryStage.H:78
AuxiliaryStageRecipe recurrence
Definition: ERF_AuxiliaryStage.H:72
ConstTimedFieldView rho_input
Definition: ERF_AuxiliaryStage.H:79
int stage
Definition: ERF_AuxiliaryStage.H:66
ConstTimedFieldView measure_anchor
Definition: ERF_AuxiliaryStage.H:82
double input_time
Definition: ERF_AuxiliaryStage.H:69
ConstTimedFieldView measure_input
Definition: ERF_AuxiliaryStage.H:83
HostIntegrator method
Definition: ERF_AuxiliaryStage.H:64
ConstTimedFieldView state_input
Definition: ERF_AuxiliaryStage.H:75
double target_time
Definition: ERF_AuxiliaryStage.H:70
ConstTimedFieldView measure_target
Definition: ERF_AuxiliaryStage.H:84
double step_old_time
Definition: ERF_AuxiliaryStage.H:68
HostCarrierFluxView carrier
Definition: ERF_AuxiliaryStage.H:86
ConstTimedFieldView rho_target
Definition: ERF_AuxiliaryStage.H:80
MutableTimedFieldView state_target
Definition: ERF_AuxiliaryStage.H:76
ConstTimedFieldView state_anchor
Definition: ERF_AuxiliaryStage.H:74
Definition: ERF_AuxiliaryStage.H:41
double limiter_trial_interval
Definition: ERF_AuxiliaryStage.H:45
double completed_ledger_time
Definition: ERF_AuxiliaryStage.H:47
LimiterTrialBase limiter_trial_base
Definition: ERF_AuxiliaryStage.H:42
Definition: ERF_SpectralGrid.H:34
ParticleMixingPolicy policy
Definition: ERF_SBMParticleMixing.H:37
std::vector< double > gross
Definition: ERF_SBMPhysicalBoundary.H:66
std::vector< double > outward
Definition: ERF_SBMPhysicalBoundary.H:65
std::uint64_t face_stage_terms
Definition: ERF_SBMPhysicalBoundary.H:67
std::array< AdvectionFaceKind, physical_face_count > kind
Definition: ERF_SBMPhysicalBoundary.H:30

Referenced by advance_stage_from_host().

Here is the caller graph for this function:

◆ advance_stage_from_host()

void erf_sbm::SBMTransport::advance_stage_from_host ( int  level,
erf_auxiliary::HostIntegrator  method,
int  stage,
double  step_old_time,
double  input_time,
double  target_time,
double  host_stage_interval,
SBMStateManager &  state_manager,
const amrex::MultiFab &  S_old_cons,
const amrex::MultiFab &  S_new_cons,
amrex::MultiFab &  S_data_cons,
const amrex::MultiFab &  avg_xmom,
const amrex::MultiFab &  avg_ymom,
const amrex::MultiFab &  avg_zmom,
const amrex::Geometry &  geometry,
int  qc_component,
int  qr_component,
const SBMAMRStageParent *  parent = nullptr,
const SBMStageMixingInputs *  mixing = nullptr 
)

ERF slow-RHS seam. The conserved-state views are ordered as the old-step anchor, the actual host predictor/input, and the target being written. Keep this forwarding point shared by the ERF call site and seam-level tests so density-time pairing cannot drift silently.

2601 {
2602  // Preserve ERF's semantic state roles at the integration boundary:
2603  // S_old anchors the step, S_new is the stage predictor, and S_data is the
2604  // target. In particular, do not substitute S_data for the predictor
2605  // density used to form the high-order intensive spectrum.
2607  amrex::Print() << "SBM transport host integrator: "
2608  << erf_auxiliary::HostIntegratorName(method) << "\n";
2610  }
2611  advance_stage(level, method, stage, step_old_time, input_time, target_time,
2612  host_stage_interval, state_manager, S_old_cons, S_new_cons,
2613  S_data_cons, avg_xmom, avg_ymom, avg_zmom, geometry,
2614  qc_component, qr_component, parent, mixing);
2615 }
void advance_stage(int level, erf_auxiliary::HostIntegrator method, int stage, double step_old_time, double input_time, double target_time, double host_stage_interval, SBMStateManager &state_manager, const amrex::MultiFab &conserved_anchor, const amrex::MultiFab &conserved_input, amrex::MultiFab &conserved_target, const amrex::MultiFab &avg_xmom, const amrex::MultiFab &avg_ymom, const amrex::MultiFab &avg_zmom, const amrex::Geometry &geometry, int qc_component, int qr_component, const SBMAMRStageParent *parent=nullptr, const SBMStageMixingInputs *mixing=nullptr)
Definition: ERF_SBMTransport.cpp:2618
bool m_host_integrator_reported
Definition: ERF_SBMTransport.H:315
const char * HostIntegratorName(const HostIntegrator method) noexcept
Definition: ERF_AuxiliaryStage.cpp:57

Referenced by erf_slow_rhs_post().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ begin_physical_step()

bool erf_sbm::SBMTransport::begin_physical_step ( int  level,
double  step_begin,
double  step_end,
std::string &  diagnostic 
)
2512 {
2513  diagnostic.clear();
2514  if (!is_defined(level)) {
2515  diagnostic = "SBM transport physical step requires a defined level";
2516  return false;
2517  }
2518  auto& data = *m_levels[static_cast<std::size_t>(level)];
2519 #ifdef ERF_SBM_AMR_QUALIFICATION
2520  if (level == 0) {
2523  m_interval_carrier_linf = Real(0.0);
2524  m_interval_accepted_rate_linf = Real(0.0);
2525  }
2526 #endif
2527  if (data.interface_as_coarse &&
2528  !data.interface_as_coarse->begin_level_step(
2529  true, step_begin, step_end, diagnostic)) {
2530  return false;
2531  }
2532  if (data.interface_as_fine &&
2533  !data.interface_as_fine->begin_level_step(
2534  false, step_begin, step_end, diagnostic)) {
2535  return false;
2536  }
2537  return true;
2538 }
Here is the call graph for this function:

◆ boundary_ledger()

const SBMBoundaryLedger& erf_sbm::SBMTransport::boundary_ledger ( ) const
inlinenoexcept
176  { return m_boundary_ledger; }

◆ chunks()

const std::vector<ConstraintClosureChunk>& erf_sbm::SBMTransport::chunks ( ) const
inlinenoexcept
264  { return m_chunks; }

◆ completed_spectral_ledger()

const erf_auxiliary::CompletedStepFluxLedger & erf_sbm::SBMTransport::completed_spectral_ledger ( int  level) const

Full all-component accepted-integral reference, present only when enabled.

3912 {
3913  if (!is_defined(level)) {
3914  throw std::logic_error("SBM transport level is not defined");
3915  }
3916  const auto& ledger = m_levels[static_cast<std::size_t>(level)]->spectral_ledger;
3917  if (!ledger.is_defined()) {
3918  throw std::logic_error(
3919  "completed spectral transfer is available only on AMR-capable transport instances");
3920  }
3921  if (!ledger.step_complete()) {
3922  throw std::logic_error(
3923  "spectral transfer is available only after a complete host step");
3924  }
3925  return ledger;
3926 }
Here is the call graph for this function:

◆ define()

void erf_sbm::SBMTransport::define ( int  level,
const amrex::BoxArray &  cell_ba,
const amrex::DistributionMapping &  dm 
)
2301 {
2302  AMREX_ALWAYS_ASSERT(level >= 0 &&
2303  level < static_cast<int>(m_levels.size()));
2304  AMREX_ALWAYS_ASSERT(m_levels[static_cast<std::size_t>(level)] == nullptr);
2305  int max_chunk_components = 0;
2306  int max_chunk_ratio_components = 0;
2307  for (const auto& chunk : m_chunks) {
2308  max_chunk_components = std::max(
2309  max_chunk_components, static_cast<int>(chunk.components.size()));
2310  int chunk_ratio_components = 0;
2311  for (const int group : chunk.group_indices) {
2312  chunk_ratio_components +=
2313  m_max_constraints_per_group[static_cast<std::size_t>(group)];
2314  }
2315  max_chunk_ratio_components =
2316  std::max(max_chunk_ratio_components, chunk_ratio_components);
2317  }
2318  auto data = std::make_unique<LevelStorage>();
2319  m_admission->define_level(level, cell_ba, dm);
2320  const int ncomp = m_layout.ncomp();
2321  data->anchor.define(cell_ba, dm, ncomp, 0);
2322  data->target.define(cell_ba, dm, ncomp, 0);
2323  data->input_intensive.define(cell_ba, dm, ncomp, 2);
2324  data->physical_input_intensive.define(cell_ba, dm, ncomp, 2);
2325  data->base_intensive.define(cell_ba, dm, ncomp, 2);
2326  data->anchor_intensive.define(cell_ba, dm, ncomp, 2);
2327  if (level > 0) {
2328  data->coarse_fill_mask.define(cell_ba, dm, 3, 2);
2329  }
2330  data->low_trial_h.define(cell_ba, dm, max_chunk_components, 0);
2331  data->cell_ratios.define(cell_ba, dm,
2332  std::max(1, max_chunk_ratio_components), 1);
2333  data->invalid.define(cell_ba, dm, 1, 0);
2334  data->outgoing_demand.define(cell_ba, dm, 1, 0);
2335  data->measure.define(cell_ba, dm, 1, 0);
2336  data->low_rate.define(cell_ba, dm, max_chunk_components, 0);
2337  data->high_rate.define(cell_ba, dm, max_chunk_components, 0);
2338  data->accepted_rate.define(cell_ba, dm, max_chunk_components, 0);
2339  data->face_lambda.define(cell_ba, dm, 1, 0);
2340  data->projected_rate.define(cell_ba, dm, 2, 0);
2341  data->projected_ledger.define(cell_ba, dm, 2);
2342  if (m_keep_spectral_ledger_reference && m_levels.size() > 1) {
2343  data->spectral_ledger.define(cell_ba, dm, ncomp);
2344  }
2345  data->anchor.setVal(Real(0.0));
2346  data->target.setVal(Real(0.0));
2347  data->invalid.setVal(Real(0.0));
2348  data->projected_rate.setVal(Real(0.0));
2349  data->boundary_stage.assign(
2350  static_cast<std::size_t>(2 * physical_face_count * ncomp + 1), 0.0);
2351  data->boundary_step.assign(
2352  static_cast<std::size_t>(2 * physical_face_count * ncomp), 0.0);
2353  data->boundary_total.resize(
2354  static_cast<std::size_t>(2 * physical_face_count * ncomp));
2355  m_levels[static_cast<std::size_t>(level)] = std::move(data);
2356 }
int max_chunk_components() const noexcept
Definition: ERF_SBMTransport.H:265
Here is the call graph for this function:

◆ destroy()

void erf_sbm::SBMTransport::destroy ( int  level)
3858 {
3859  AMREX_ALWAYS_ASSERT(level >= 0 &&
3860  level < static_cast<int>(m_levels.size()));
3861  m_admission->destroy_level(level);
3862  m_levels[static_cast<std::size_t>(level)].reset();
3863 }
Here is the call graph for this function:

◆ enable_zero_flow_diagnostics()

void erf_sbm::SBMTransport::enable_zero_flow_diagnostics ( bool  enabled)
inlinenoexcept
273  { m_zero_flow_diagnostics_enabled = enabled; }

◆ install_mixing_bc()

void erf_sbm::SBMTransport::install_mixing_bc ( )
private
2441 {
2442  // A closed face's high-order transfer is discarded, so it needs no
2443  // Dirichlet stencil; an open face takes ERF's ext_dir stencil against the
2444  // inflow spectrum in its ghost cells. An inward-only face is masked by the
2445  // carrier sign afterwards, since the builder has no velocity to judge it.
2446  amrex::BCRec bc;
2447  for (int dir = 0; dir < AMREX_SPACEDIM; ++dir) {
2448  const auto type = [&] (const int face) {
2449  return m_boundaries.diffusion[static_cast<std::size_t>(face)] ==
2452  };
2453  bc.setLo(dir, type(dir));
2454  bc.setHi(dir, type(dir + AMREX_SPACEDIM));
2455  }
2456  m_mixing_bc.resize(1);
2457  amrex::Gpu::copy(amrex::Gpu::hostToDevice, &bc, &bc + 1, m_mixing_bc.begin());
2458 }
@ foextrap
Definition: ERF_IndexDefines.H:316
@ ext_dir
Definition: ERF_IndexDefines.H:317
real(c_double), private bc
Definition: ERF_module_mp_morr_two_moment.F90:182
std::array< erf_auxiliary::DiffusionFaceKind, physical_face_count > diffusion
Definition: ERF_SBMPhysicalBoundary.H:32

Referenced by set_particle_mixing(), and set_physical_boundaries().

Here is the caller graph for this function:

◆ interval_accepted_rate_linf()

amrex::Real erf_sbm::SBMTransport::interval_accepted_rate_linf ( ) const
inlinenoexcept

◆ interval_carrier_linf()

amrex::Real erf_sbm::SBMTransport::interval_carrier_linf ( ) const
inlinenoexcept
279  { return m_interval_carrier_linf; }

◆ interval_limiter_active_groups()

int erf_sbm::SBMTransport::interval_limiter_active_groups ( ) const
inlinenoexcept

◆ interval_limiter_changed_rate()

bool erf_sbm::SBMTransport::interval_limiter_changed_rate ( ) const
inlinenoexcept

◆ is_defined()

bool erf_sbm::SBMTransport::is_defined ( int  level) const
3867 {
3868  if (level < 0 || level >= static_cast<int>(m_levels.size())) {
3869  throw std::out_of_range("SBM transport level is outside the workspace");
3870  }
3871  return static_cast<bool>(m_levels[static_cast<std::size_t>(level)]);
3872 }

Referenced by accept_physical_step(), admit_terrain_geometry(), advance_stage(), begin_physical_step(), completed_spectral_ledger(), measure_is_ready(), projected_ledger(), rebuild_static_measure(), set_amr_flux_registers(), and static_measure().

Here is the caller graph for this function:

◆ max_chunk_components()

int erf_sbm::SBMTransport::max_chunk_components ( ) const
inlinenoexcept
266  { return m_max_chunk_components; }

Referenced by define().

Here is the caller graph for this function:

◆ max_groups_per_chunk()

int erf_sbm::SBMTransport::max_groups_per_chunk ( ) const
inlinenoexcept

Complete constraint-group chunks shared by transport and AMR transfer.

262  { return m_max_groups_per_chunk; }

◆ measure_is_ready()

bool erf_sbm::SBMTransport::measure_is_ready ( int  level) const
3876 {
3877  if (!is_defined(level)) {
3878  return false;
3879  }
3880  return m_levels[static_cast<std::size_t>(level)]->measure_ready;
3881 }
Here is the call graph for this function:

◆ mixes_particles()

bool erf_sbm::SBMTransport::mixes_particles ( ) const
inlinenoexcept

Referenced by admit_terrain_geometry(), advance_stage(), and erf_slow_rhs_post().

Here is the caller graph for this function:

◆ mixing_mesh()

erf_auxiliary::DiffusionMesh erf_sbm::SBMTransport::mixing_mesh ( ) const
inlinenoexcept
194  { return m_mixing_mesh; }

Referenced by erf_sbm::make_stage_mixing_inputs().

Here is the caller graph for this function:

◆ nlevels()

int erf_sbm::SBMTransport::nlevels ( ) const
inlinenoexcept
255  { return static_cast<int>(m_levels.size()); }

◆ operator=()

SBMTransport& erf_sbm::SBMTransport::operator= ( const SBMTransport &  )
delete

◆ particle_mixing()

const ParticleMixingConfig& erf_sbm::SBMTransport::particle_mixing ( ) const
inlinenoexcept
190  { return m_mixing; }

Referenced by erf_sbm::make_stage_mixing_inputs().

Here is the caller graph for this function:

◆ physical_boundaries()

const SBMPhysicalBoundaryConfig& erf_sbm::SBMTransport::physical_boundaries ( ) const
inlinenoexcept
174  { return m_boundaries; }

◆ projected_ledger()

const erf_auxiliary::CompletedStepFluxLedger & erf_sbm::SBMTransport::projected_ledger ( int  level) const
3903 {
3904  if (!is_defined(level)) {
3905  throw std::logic_error("SBM transport level is not defined");
3906  }
3907  return m_levels[static_cast<std::size_t>(level)]->projected_ledger;
3908 }
const erf_auxiliary::CompletedStepFluxLedger & projected_ledger(int level) const
Definition: ERF_SBMTransport.cpp:3902
Here is the call graph for this function:

◆ rebuild_static_measure()

bool erf_sbm::SBMTransport::rebuild_static_measure ( int  level,
const amrex::MultiFab &  detJ,
const amrex::MultiFab &  mx,
const amrex::MultiFab &  my,
std::string &  diagnostic 
)
2571 {
2572  diagnostic.clear();
2573  if (!is_defined(level)) {
2574  diagnostic =
2575  "static mapped measure requires a defined SBM transport level";
2576  return false;
2577  }
2578  auto& data = *m_levels[static_cast<std::size_t>(level)];
2579  data.measure_ready = false;
2580  if (!erf_auxiliary::BuildMappedCellMeasure(data.measure, detJ, mx, my,
2581  diagnostic))
2582  return false;
2583  data.measure_ready = true;
2584  // New static geometry: check its shared metric copies again.
2585  data.terrain_metrics_checked = false;
2586  return true;
2587 }
bool BuildMappedCellMeasure(amrex::MultiFab &omega, const amrex::MultiFab &detJ, const amrex::MultiFab &mx, const amrex::MultiFab &my, std::string &diagnostic)
Definition: ERF_AuxiliaryMappedTransport.cpp:39
Here is the call graph for this function:

◆ restore_boundary_ledger()

void erf_sbm::SBMTransport::restore_boundary_ledger ( const SBMBoundaryLedger &  ledger)
2391 {
2392  if (ledger.ncomp != m_layout.ncomp() ||
2393  ledger.outward.size() != m_boundary_ledger.outward.size() ||
2394  ledger.gross.size() != m_boundary_ledger.gross.size()) {
2395  throw std::invalid_argument(
2396  "SBM boundary ledger does not match the active spectral layout");
2397  }
2398  m_boundary_ledger = ledger;
2399 }
Here is the call graph for this function:

◆ set_amr_flux_registers()

void erf_sbm::SBMTransport::set_amr_flux_registers ( int  level,
SBMAMRFluxRegister *  as_coarse,
SBMAMRFluxRegister *  as_fine 
)

Bind the adjacent interface registers after final level layouts exist.

2499 {
2500  if (!is_defined(level)) {
2501  throw std::logic_error("SBM transport level must be defined before binding AMR registers");
2502  }
2503  auto& data = *m_levels[static_cast<std::size_t>(level)];
2504  data.interface_as_coarse = as_coarse;
2505  data.interface_as_fine = as_fine;
2506 }
Here is the call graph for this function:

◆ set_particle_mixing()

void erf_sbm::SBMTransport::set_particle_mixing ( const ParticleMixingConfig &  config,
erf_auxiliary::DiffusionMesh  mesh,
TerrainMixingQualification  terrain = {} 
)

Install the particle mixing policy and its mesh. With a policy other than None, every stage adds the low-order diffusive exchange to the donor rates and ERF's diffusion of the stage input to the high-order rates, so the group limiter bounds their combined correction. Open diffusive faces of the physical boundaries exchange with their inflow spectrum in both.

2405 {
2406  std::string reason;
2407  if (!validate_particle_mixing_config(config, reason)) {
2408  throw std::invalid_argument("SBM particle mixing: " + reason);
2409  }
2410  // The terrain stage operator has not passed its release gates.
2411  if (config.policy != ParticleMixingPolicy::None &&
2412  mesh == erf_auxiliary::DiffusionMesh::VariableDz && !terrain.accept) {
2413  throw std::invalid_argument(
2414  "SBM particle mixing: the terrain-fitted (VariableDz) stage operator "
2415  "is not qualified");
2416  }
2418  throw std::invalid_argument(reason);
2419  }
2420  m_mixing = config;
2421  m_mixing_mesh = mesh;
2422  m_terrain_match = terrain.match;
2424 }
const auto config
Definition: ERF_InitCustomPert_CloudChamber.H:38
void install_mixing_bc()
Definition: ERF_SBMTransport.cpp:2440
bool validate_particle_mixing_config(const ParticleMixingConfig &config, std::string &reason)
Definition: ERF_SBMParticleMixing.cpp:57
bool validate_particle_mixing_boundaries(const ParticleMixingConfig &config, const SBMPhysicalBoundaryConfig &boundaries, std::string &reason)
Definition: ERF_SBMParticleMixing.cpp:180
Here is the call graph for this function:

◆ set_physical_boundaries()

void erf_sbm::SBMTransport::set_physical_boundaries ( const SBMPhysicalBoundaryConfig &  config)

Install validated face kinds and inflow spectra; every stage checks them against its geometry.

2360 {
2361  const int ncomp = m_layout.ncomp();
2362  std::vector<Real> host_inflow(
2363  static_cast<std::size_t>(physical_face_count * ncomp), Real(0.0));
2364  for (int face = 0; face < physical_face_count; ++face) {
2365  if (config.kind[static_cast<std::size_t>(face)] !=
2367  continue;
2368  }
2369  const auto& z = config.inflow_z[static_cast<std::size_t>(face)];
2370  std::string reason;
2371  if (!validate_inflow_state(m_layout, z, reason)) {
2372  throw std::invalid_argument(std::string("SBM inflow spectrum at ") +
2373  face_name(face) + " is not admissible: " + reason);
2374  }
2375  std::copy(z.begin(), z.end(),
2376  host_inflow.begin() + static_cast<std::ptrdiff_t>(face * ncomp));
2377  }
2378  std::string reason;
2380  throw std::invalid_argument(reason);
2381  }
2382  m_boundaries = config;
2383  m_inflow_device.resize(host_inflow.size());
2384  amrex::Gpu::copy(amrex::Gpu::hostToDevice, host_inflow.begin(),
2385  host_inflow.end(), m_inflow_device.begin());
2387 }
bool validate_inflow_state(const SBMLayout &layout, const std::vector< amrex::Real > &z, std::string &reason)
Definition: ERF_SBMPhysicalBoundary.cpp:152
Here is the call graph for this function:

◆ static_measure()

const MultiFab & erf_sbm::SBMTransport::static_measure ( int  level) const
3890 {
3891  if (!is_defined(level)) {
3892  throw std::logic_error("SBM transport level is not defined");
3893  }
3894  const auto& data = *m_levels[static_cast<std::size_t>(level)];
3895  if (!data.measure_ready) {
3896  throw std::logic_error("SBM static measure is not ready");
3897  }
3898  return data.measure;
3899 }
Here is the call graph for this function:

Member Data Documentation

◆ default_max_groups_per_chunk

constexpr int erf_sbm::SBMTransport::default_max_groups_per_chunk = 16
staticconstexpr

Referenced by ERF::ERF_shared().

◆ m_admission

std::unique_ptr<SBMStateAdmission> erf_sbm::SBMTransport::m_admission
private

◆ m_boundaries

◆ m_boundary_ledger

SBMBoundaryLedger erf_sbm::SBMTransport::m_boundary_ledger
private

◆ m_chunks

std::vector<ConstraintClosureChunk> erf_sbm::SBMTransport::m_chunks
private

◆ m_device_metadata

std::unique_ptr<DeviceMetadata> erf_sbm::SBMTransport::m_device_metadata
private

Referenced by advance_stage(), and SBMTransport().

◆ m_flat_constraints

FlattenedConstraintSet erf_sbm::SBMTransport::m_flat_constraints
private

Referenced by SBMTransport().

◆ m_groups

std::vector<ConstraintGroup> erf_sbm::SBMTransport::m_groups
private

Referenced by advance_stage(), and SBMTransport().

◆ m_host_integrator_reported

bool erf_sbm::SBMTransport::m_host_integrator_reported {false}
private

Referenced by advance_stage_from_host().

◆ m_inflow_device

amrex::Gpu::DeviceVector<amrex::Real> erf_sbm::SBMTransport::m_inflow_device
private

◆ m_interval_accepted_rate_linf

amrex::Real erf_sbm::SBMTransport::m_interval_accepted_rate_linf {amrex::Real(0.0)}
private

◆ m_interval_carrier_linf

amrex::Real erf_sbm::SBMTransport::m_interval_carrier_linf {amrex::Real(0.0)}
private

◆ m_interval_limiter_active_groups

int erf_sbm::SBMTransport::m_interval_limiter_active_groups {0}
private

◆ m_interval_limiter_changed_rate

bool erf_sbm::SBMTransport::m_interval_limiter_changed_rate {false}
private

◆ m_keep_spectral_ledger_reference

bool erf_sbm::SBMTransport::m_keep_spectral_ledger_reference {true}
private

Referenced by define().

◆ m_layout

const SBMLayout& erf_sbm::SBMTransport::m_layout
private

◆ m_levels

◆ m_max_chunk_components

int erf_sbm::SBMTransport::m_max_chunk_components {0}
private

◆ m_max_constraints_per_group

std::vector<int> erf_sbm::SBMTransport::m_max_constraints_per_group
private

Referenced by define(), and SBMTransport().

◆ m_max_groups_per_chunk

int erf_sbm::SBMTransport::m_max_groups_per_chunk {default_max_groups_per_chunk}
private

Referenced by max_groups_per_chunk().

◆ m_mixing

◆ m_mixing_bc

amrex::Gpu::DeviceVector<amrex::BCRec> erf_sbm::SBMTransport::m_mixing_bc
private

Referenced by advance_stage(), and install_mixing_bc().

◆ m_mixing_mesh

◆ m_projection

SBMBulkProjection erf_sbm::SBMTransport::m_projection
private

◆ m_property_support

std::vector<AttachedPropertySupportDescriptor> erf_sbm::SBMTransport::m_property_support
private

Referenced by SBMTransport().

◆ m_split_ghost_values_checked

std::array<bool, 2> erf_sbm::SBMTransport::m_split_ghost_values_checked {}
private

Referenced by advance_stage().

◆ m_terrain_match

bool erf_sbm::SBMTransport::m_terrain_match {true}
private

◆ m_zero_flow_diagnostics_enabled

bool erf_sbm::SBMTransport::m_zero_flow_diagnostics_enabled {false}
private

The documentation for this class was generated from the following files: