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