ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_SBMPhysicalBoundary.H
Go to the documentation of this file.
1 #ifndef ERF_SBM_PHYSICAL_BOUNDARY_H_
2 #define ERF_SBM_PHYSICAL_BOUNDARY_H_
3 
5 #include "ERF_SBMLayout.H"
7 #include "ERF_IndexDefines.H"
8 
9 #include <AMReX_Orientation.H>
10 #include <AMReX_REAL.H>
11 
12 #include <array>
13 #include <cstdint>
14 #include <string>
15 #include <vector>
16 
17 namespace erf_sbm {
18 
19 inline constexpr int physical_face_count = 2 * AMREX_SPACEDIM;
20 
21 /**
22  * Spectral advection category and constant inflow spectrum of each domain
23  * face, indexed by amrex::Orientation. Inflow values are dry-air-relative
24  * z = U / rho_d for every layout component. `diffusion` is the face's
25  * particle-mixing semantics, which follows ERF's own scalar diffusion there:
26  * an ERF inflow face exchanges with the inflow spectrum, an inflow_outflow
27  * face does so where the carrier is inward, and every other face is closed.
28  */
30  std::array<AdvectionFaceKind, physical_face_count> kind{};
31  std::array<std::vector<amrex::Real>, physical_face_count> inflow_z;
32  std::array<erf_auxiliary::DiffusionFaceKind, physical_face_count> diffusion{};
33 
34  [[nodiscard]] bool all_periodic () const noexcept;
35  [[nodiscard]] bool periodic_in (int dir) const noexcept;
36  /** Restart-schema line; an all-periodic configuration keeps the M4b identity. */
37  [[nodiscard]] std::string identity () const;
38  /** Whether any face is neither periodic nor a wall. */
39  [[nodiscard]] bool has_inflow_or_outflow_face () const noexcept;
40 };
41 
42 [[nodiscard]] const char* face_name (int face) noexcept;
43 [[nodiscard]] const char* face_kind_name (AdvectionFaceKind kind) noexcept;
44 [[nodiscard]] const char* diffusion_face_kind_name (erf_auxiliary::DiffusionFaceKind kind) noexcept;
45 
46 /** Map one ERF physical boundary type, or explain why SBM rejects it. */
47 [[nodiscard]] bool map_erf_boundary (ERF_BC bc, AdvectionFaceKind& kind,
48  std::string& reason);
49 
50 /** The particle-mixing semantics of one ERF physical boundary type. */
52 
53 /** Require a complete, canonical, group-admissible inflow spectrum. */
54 [[nodiscard]] bool validate_inflow_state (const SBMLayout& layout,
55  const std::vector<amrex::Real>& z,
56  std::string& reason);
57 
58 /**
59  * Cumulative composite outward transfer through each physical face: coarse
60  * faces under a finer level are excluded, so the sum closes the leaf-domain
61  * inventory. Gross is the sum of absolute face transfers, a roundoff scale.
62  */
64  int ncomp{0};
65  std::vector<double> outward;
66  std::vector<double> gross;
67  std::uint64_t face_stage_terms{0};
68 
69  void reset (int components);
70  [[nodiscard]] double total_outward (int component) const;
71  [[nodiscard]] double total_gross (int component) const;
72  [[nodiscard]] std::string serialize () const;
73  [[nodiscard]] static bool parse (const std::string& text, int components,
74  SBMBoundaryLedger& ledger,
75  std::string& reason);
76 };
77 
78 } // namespace erf_sbm
79 
80 #endif
ERF_BC
Definition: ERF_IndexDefines.H:293
Definition: ERF_SBMLayout.H:94
Definition: ERF_ConsoleIO.cpp:17
Definition: ERF_AuxiliaryDiffusion.cpp:10
DiffusionFaceKind
Definition: ERF_AuxiliaryDiffusionFace.H:17
Definition: ERF.H:128
erf_auxiliary::DiffusionFaceKind map_erf_diffusion(const ERF_BC bc) noexcept
Definition: ERF_SBMPhysicalBoundary.cpp:101
bool map_erf_boundary(const ERF_BC bc, AdvectionFaceKind &kind, std::string &reason)
Definition: ERF_SBMPhysicalBoundary.cpp:114
const char * face_kind_name(const AdvectionFaceKind kind) noexcept
Definition: ERF_SBMPhysicalBoundary.cpp:78
const char * face_name(const int face) noexcept
Definition: ERF_SBMPhysicalBoundary.cpp:70
bool validate_inflow_state(const SBMLayout &layout, const std::vector< amrex::Real > &z, std::string &reason)
Definition: ERF_SBMPhysicalBoundary.cpp:152
AdvectionFaceKind
Definition: ERF_SBMAdvectionBoundary.H:10
const char * diffusion_face_kind_name(const erf_auxiliary::DiffusionFaceKind kind) noexcept
Definition: ERF_SBMPhysicalBoundary.cpp:90
constexpr int physical_face_count
Definition: ERF_SBMPhysicalBoundary.H:19
real(c_double), private bc
Definition: ERF_module_mp_morr_two_moment.F90:182
Definition: ERF_SBMPhysicalBoundary.H:63
std::vector< double > gross
Definition: ERF_SBMPhysicalBoundary.H:66
std::vector< double > outward
Definition: ERF_SBMPhysicalBoundary.H:65
Definition: ERF_SBMPhysicalBoundary.H:29
std::array< AdvectionFaceKind, physical_face_count > kind
Definition: ERF_SBMPhysicalBoundary.H:30
bool all_periodic() const noexcept
Definition: ERF_SBMPhysicalBoundary.cpp:20
bool has_inflow_or_outflow_face() const noexcept
Definition: ERF_SBMPhysicalBoundary.cpp:37
std::array< erf_auxiliary::DiffusionFaceKind, physical_face_count > diffusion
Definition: ERF_SBMPhysicalBoundary.H:32
std::string identity() const
Definition: ERF_SBMPhysicalBoundary.cpp:49
std::array< std::vector< amrex::Real >, physical_face_count > inflow_z
Definition: ERF_SBMPhysicalBoundary.H:31
bool periodic_in(int dir) const noexcept
Definition: ERF_SBMPhysicalBoundary.cpp:29