ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_SBMAdvectionBoundary.H
Go to the documentation of this file.
1 #ifndef ERF_SBM_ADVECTION_BOUNDARY_H_
2 #define ERF_SBM_ADVECTION_BOUNDARY_H_
3 
4 #include <AMReX_GpuQualifiers.H>
5 #include <AMReX_REAL.H>
6 
7 namespace erf_sbm {
8 
9 /** Physical face categories understood by the bounded M3 advection contract. */
10 enum class AdvectionFaceKind : int {
11  Periodic,
15 };
16 
17 /** Result of applying the M3 spectral state policy at one oriented face. */
18 enum class AdvectionFaceAction : int {
26 };
27 
30  // Positive is outward from the physical domain at this particular face.
31  amrex::Real outward_carrier{amrex::Real(0.0)};
33  // True only when every member of the atomic group, including all attached
34  // properties, is present. Compact qc/qr fields are not spectral inflow.
37 };
38 
41  bool use_interior_donor{false};
44 
45  [[nodiscard]] AMREX_GPU_HOST_DEVICE constexpr bool accepted () const noexcept
46  {
50  }
51 };
52 
53 /**
54  * Decide the face-level spectral advection semantics; the transport fills the
55  * physical ghosts. At a physical face whose
56  * high-order stencil is not qualified, the admissible donor proposal remains
57  * available and high-order transport falls back to it.
58  */
59 [[nodiscard]] AMREX_GPU_HOST_DEVICE constexpr AdvectionFacePolicy
61 {
62  using Action = AdvectionFaceAction;
63  if (input.kind == AdvectionFaceKind::Periodic) {
64  return {Action::PeriodicSharedFace, false, false, true};
65  }
67  input.outward_carrier == amrex::Real(0.0)) {
68  return {Action::ZeroNormalFlux, false, false, false};
69  }
70 
71  if (input.outward_carrier > amrex::Real(0.0)) {
72  // Outward flow uses the interior spectrum. The donor path is always
73  // defined; high order is used only with a qualified physical stencil.
74  return {Action::InteriorDonor, true, false,
75  input.high_order_stencil_available};
76  }
77 
78  // Reverse flow contradicts a face declared as advective outflow. External
79  // spectral data must not silently change that declared boundary policy.
81  return {Action::RejectInwardOutflow, false, false, false};
82  }
83 
84  // The remaining negative-carrier boundary category is prescribed inflow.
85  // A complete explicit atomic-group spectrum is required; qc/qr cannot
86  // supply missing bin or attached-property composition.
87  if (!input.explicit_spectral_state_present) {
88  return {Action::RejectMissingInflowState, false, false, false};
89  }
90  if (!input.explicit_spectral_group_complete) {
91  return {Action::RejectIncompleteInflowState, false, false, false};
92  }
93  return {Action::ExplicitSpectralInflow, false, true,
94  input.high_order_stencil_available};
95 }
96 
97 } // namespace erf_sbm
98 
99 #endif // ERF_SBM_ADVECTION_BOUNDARY_H_
std::string input
Definition: ERF_InputPreflight.cpp:29
Definition: ERF.H:128
AdvectionFaceAction
Definition: ERF_SBMAdvectionBoundary.H:18
constexpr AMREX_GPU_HOST_DEVICE AdvectionFacePolicy make_advection_face_policy(const AdvectionFacePolicyInput &input) noexcept
Definition: ERF_SBMAdvectionBoundary.H:60
AdvectionFaceKind
Definition: ERF_SBMAdvectionBoundary.H:10
Definition: ERF_SBMAdvectionBoundary.H:28
bool explicit_spectral_state_present
Definition: ERF_SBMAdvectionBoundary.H:32
AdvectionFaceKind kind
Definition: ERF_SBMAdvectionBoundary.H:29
amrex::Real outward_carrier
Definition: ERF_SBMAdvectionBoundary.H:31
bool high_order_stencil_available
Definition: ERF_SBMAdvectionBoundary.H:36
bool explicit_spectral_group_complete
Definition: ERF_SBMAdvectionBoundary.H:35
Definition: ERF_SBMAdvectionBoundary.H:39
bool use_high_order_candidate
Definition: ERF_SBMAdvectionBoundary.H:43
constexpr AMREX_GPU_HOST_DEVICE bool accepted() const noexcept
Definition: ERF_SBMAdvectionBoundary.H:45
bool use_explicit_spectral_state
Definition: ERF_SBMAdvectionBoundary.H:42
bool use_interior_donor
Definition: ERF_SBMAdvectionBoundary.H:41
AdvectionFaceAction action
Definition: ERF_SBMAdvectionBoundary.H:40