ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
erf_cloud_chamber_wall_flux Namespace Reference

Classes

struct  WallFlux
 
struct  FaceRuntimeCoefficients
 
struct  MostStabilityResult
 
struct  ScalarWallSample
 
struct  NeutralLogMomentumState
 
struct  MomentumWallSample
 
struct  ScalarFluxReplacement
 
struct  DirectionalMomentumRate
 
struct  CellScalarWallRate
 

Enumerations

enum  OwnedChannel : unsigned char {
  OwnNone = 0 , OwnMomentum = 1 << 0 , OwnHeat = 1 << 1 , OwnVapor = 1 << 2 ,
  OwnCloudWater = 1 << 3
}
 
enum class  ScalarChannel : unsigned char { None , Heat , Vapor , CloudWater }
 

Functions

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool wall_uses_most_heat (const erf_wall_thermodynamics::FaceWall &wall) noexcept
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool wall_uses_most_vapor (const erf_wall_thermodynamics::FaceWall &wall) noexcept
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool wall_uses_most (const erf_wall_thermodynamics::FaceWall &wall) noexcept
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE ScalarChannel scalar_channel_from_quantity (int quantity) noexcept
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int primitive_component (ScalarChannel channel) noexcept
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool wall_owns_scalar_channel (const erf_wall_thermodynamics::FaceWall &wall, ScalarChannel channel) noexcept
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE unsigned char scalar_channel_mask (ScalarChannel channel) noexcept
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool owns (const WallFlux &flux, ScalarChannel channel) noexcept
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE NeutralLogMomentumState neutral_log_momentum_state (amrex::Real U_t, amrex::Real wall_distance, amrex::Real z0_m) noexcept
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real neutral_log_scalar_coefficient (amrex::Real wall_distance, amrex::Real z0_m, amrex::Real z0_scalar) noexcept
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void most_stability_require (bool condition, const char *message) noexcept
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE MostStabilityResult most_stability_coordinate (amrex::Real Ri, amrex::Real D_m, amrex::Real D_s) noexcept
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real wet_wall_qv (const erf_wall_thermodynamics::FaceWall &wall, amrex::Real p_hse) noexcept
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE FaceRuntimeCoefficients most_wall_coefficients (const erf_wall_thermodynamics::FaceWall &wall, amrex::Real theta_air, amrex::Real qv_air, amrex::Real p_hse, amrex::Real rdOcp, amrex::Real U_t, amrex::Real wall_distance, int gravity_sign) noexcept
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > neutral_log_traction_on_fluid (const MomentumWallSample &sample, const NeutralLogMomentumState &neutral) noexcept
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real neutral_scalar_rate (amrex::Real coefficient, amrex::Real U_t, amrex::Real dx_inv) noexcept
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real momentum_infinity_row_sum_factor () noexcept
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real momentum_row_sum_rate (int component, const amrex::GpuArray< DirectionalMomentumRate, AMREX_SPACEDIM > &rates) noexcept
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real momentum_rate_for_face (const erf_wall_thermodynamics::FaceWall &wall, amrex::Real U_t, amrex::Real dx_inv, const FaceRuntimeCoefficients &runtime=FaceRuntimeCoefficients{}) noexcept
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool requires_tangential_speed (const erf_wall_thermodynamics::FaceWall &wall, ScalarChannel channel) noexcept
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool requires_tangential_momentum (const erf_wall_thermodynamics::FaceWall &wall) noexcept
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool wall_rate_requires_tangential_speed (const erf_wall_thermodynamics::FaceWall &wall) noexcept
 
template<int DIR, bool HIGH>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real to_coordinate_flux (amrex::Real inward) noexcept
 
template<int DIR, bool HIGH>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > traction_from_local_inward (amrex::Real normal_in, amrex::Real tangent_a, amrex::Real tangent_b) noexcept
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real bulk_theta_flux_in (amrex::Real rho, amrex::Real C_H, amrex::Real U_t, amrex::Real wall_temperature_K, amrex::Real theta_air, amrex::Real p_hse, amrex::Real rdOcp, amrex::Real molecular_speed=amrex::Real(0)) noexcept
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real bulk_vapor_flux_in (amrex::Real rho, amrex::Real C_E, amrex::Real U_t, const erf_wall_thermodynamics::FaceWall &wall, amrex::Real qv_air, amrex::Real p_hse, amrex::Real molecular_speed=amrex::Real(0)) noexcept
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > relative_tangential_velocity_cell_centered (int dir, int i, int j, int k, const amrex::Array4< const amrex::Real > &u, const amrex::Array4< const amrex::Real > &v, const amrex::Array4< const amrex::Real > &w, const erf_wall_thermodynamics::FaceWall &wall) noexcept
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real tangential_magnitude (const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &u_t) noexcept
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real tangential_speed (int dir, int i, int j, int k, const amrex::Array4< const amrex::Real > &u, const amrex::Array4< const amrex::Real > &v, const amrex::Array4< const amrex::Real > &w, const erf_wall_thermodynamics::FaceWall &wall) noexcept
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real tangential_speed_cell_centered (int dir, int i, int j, int k, const amrex::Array4< const amrex::Real > &velocity, const erf_wall_thermodynamics::FaceWall &wall) noexcept
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real wall_rate_for_cell (int i, int j, int k, const amrex::Box &domain, const erf_wall_thermodynamics::Boundary &walls, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &dx_inv, const amrex::Array4< const amrex::Real > &velocity) noexcept
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real resolved_theta_flux_in (amrex::Real rho, amrex::Real alpha_T, amrex::Real wall_temperature_K, amrex::Real theta_air, amrex::Real p_hse, amrex::Real dx_inv, amrex::Real rdOcp) noexcept
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real resolved_vapor_flux_in (amrex::Real rho, amrex::Real alpha_C, const erf_wall_thermodynamics::FaceWall &wall, amrex::Real qv_air, amrex::Real p_hse, amrex::Real dx_inv) noexcept
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE WallFlux evaluate_momentum_traction (const erf_wall_thermodynamics::FaceWall &wall, const MomentumWallSample &sample) noexcept
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE WallFlux evaluate_scalar_flux_in (const erf_wall_thermodynamics::FaceWall &wall, ScalarChannel channel, const ScalarWallSample &sample) noexcept
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real scalar_flux_in (const WallFlux &flux, ScalarChannel channel) noexcept
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real evaluate_face_scalar_flux_in (const erf_wall_thermodynamics::FaceWall &wall, ScalarChannel channel, const ScalarWallSample &sample, const erf_wall_thermodynamics::TemperatureBandView &bands, int k) noexcept
 
template<int DIR, bool HIGH>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE ScalarFluxReplacement scalar_flux_replacement (amrex::Real old_flux, amrex::Real inward_flux, amrex::Real dx_inv) noexcept
 
template<int DIR, bool HIGH>
AMREX_FORCE_INLINE void apply_face (const amrex::Box &bx, const amrex::Box &domain, const int quantity, const int flux_comp, const amrex::Array4< const amrex::Real > &state, const amrex::Array4< const amrex::Real > &prim, const amrex::Array4< const amrex::Real > &base_state, const amrex::Array4< const amrex::Real > &u, const amrex::Array4< const amrex::Real > &v, const amrex::Array4< const amrex::Real > &w, const amrex::Array4< amrex::Real > &rhs, const amrex::Array4< amrex::Real > &xflux, const amrex::Array4< amrex::Real > &yflux, const amrex::Array4< amrex::Real > &zflux, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &dx_inv, const erf_wall_thermodynamics::Boundary &walls, const amrex::Real alpha_T, const amrex::Real alpha_C, const amrex::Real rdOcp, const bool cloudy, const erf_wall_thermodynamics::TemperatureBandView bands={})
 
void apply (const amrex::Box &bx, const amrex::Box &domain, const int quantity, const int flux_comp, const amrex::Array4< const amrex::Real > &state, const amrex::Array4< const amrex::Real > &prim, const amrex::Array4< const amrex::Real > &base_state, const amrex::Array4< const amrex::Real > &u, const amrex::Array4< const amrex::Real > &v, const amrex::Array4< const amrex::Real > &w, const amrex::Array4< amrex::Real > &rhs, const amrex::Array4< amrex::Real > &xflux, const amrex::Array4< amrex::Real > &yflux, const amrex::Array4< amrex::Real > &zflux, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &dx_inv, const erf_wall_thermodynamics::Boundary &walls, const amrex::Real alpha_T, const amrex::Real alpha_C, const amrex::Real rdOcp, const bool cloudy=false, const erf_wall_thermodynamics::SidewallBandViews &bands={})
 
bool has_velocity_dependent_scalar_wall (const erf_wall_thermodynamics::Boundary &walls) noexcept
 
AMREX_FORCE_INLINE amrex::Real wall_dt_from_max_rate (amrex::Real max_rate, amrex::Real wall_cfl=amrex::Real(0.5)) noexcept
 

Enumeration Type Documentation

◆ OwnedChannel

Enumerator
OwnNone 
OwnMomentum 
OwnHeat 
OwnVapor 
OwnCloudWater 
25  : unsigned char {
26  OwnNone = 0,
27  OwnMomentum = 1 << 0,
28  OwnHeat = 1 << 1,
29  OwnVapor = 1 << 2,
30  OwnCloudWater = 1 << 3
31 };
@ OwnVapor
Definition: ERF_CloudChamberWallFlux.H:29
@ OwnNone
Definition: ERF_CloudChamberWallFlux.H:26
@ OwnHeat
Definition: ERF_CloudChamberWallFlux.H:28
@ OwnCloudWater
Definition: ERF_CloudChamberWallFlux.H:30
@ OwnMomentum
Definition: ERF_CloudChamberWallFlux.H:27

◆ ScalarChannel

enum erf_cloud_chamber_wall_flux::ScalarChannel : unsigned char
strong
Enumerator
None 
Heat 
Vapor 
CloudWater 
55  : unsigned char {
56  None,
57  Heat,
58  Vapor,
60 };
@ None
Definition: ERF_LSM_Types.H:6

Function Documentation

◆ apply()

void erf_cloud_chamber_wall_flux::apply ( const amrex::Box &  bx,
const amrex::Box &  domain,
const int  quantity,
const int  flux_comp,
const amrex::Array4< const amrex::Real > &  state,
const amrex::Array4< const amrex::Real > &  prim,
const amrex::Array4< const amrex::Real > &  base_state,
const amrex::Array4< const amrex::Real > &  u,
const amrex::Array4< const amrex::Real > &  v,
const amrex::Array4< const amrex::Real > &  w,
const amrex::Array4< amrex::Real > &  rhs,
const amrex::Array4< amrex::Real > &  xflux,
const amrex::Array4< amrex::Real > &  yflux,
const amrex::Array4< amrex::Real > &  zflux,
const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &  dx_inv,
const erf_wall_thermodynamics::Boundary &  walls,
const amrex::Real  alpha_T,
const amrex::Real  alpha_C,
const amrex::Real  rdOcp,
const bool  cloudy = false,
const erf_wall_thermodynamics::SidewallBandViews &  bands = {} 
)
inline
1295  {})
1296 {
1297  apply_face<0,false>(bx,domain,quantity,flux_comp,state,prim,base_state,u,v,w,rhs,xflux,yflux,zflux,dx_inv,walls,alpha_T,alpha_C,rdOcp,cloudy,bands[0]);
1298  apply_face<0,true >(bx,domain,quantity,flux_comp,state,prim,base_state,u,v,w,rhs,xflux,yflux,zflux,dx_inv,walls,alpha_T,alpha_C,rdOcp,cloudy,bands[1]);
1299  apply_face<1,false>(bx,domain,quantity,flux_comp,state,prim,base_state,u,v,w,rhs,xflux,yflux,zflux,dx_inv,walls,alpha_T,alpha_C,rdOcp,cloudy,bands[2]);
1300  apply_face<1,true >(bx,domain,quantity,flux_comp,state,prim,base_state,u,v,w,rhs,xflux,yflux,zflux,dx_inv,walls,alpha_T,alpha_C,rdOcp,cloudy,bands[3]);
1301  apply_face<2,false>(bx,domain,quantity,flux_comp,state,prim,base_state,u,v,w,rhs,xflux,yflux,zflux,dx_inv,walls,alpha_T,alpha_C,rdOcp,cloudy);
1302  apply_face<2,true >(bx,domain,quantity,flux_comp,state,prim,base_state,u,v,w,rhs,xflux,yflux,zflux,dx_inv,walls,alpha_T,alpha_C,rdOcp,cloudy);
1303 }
const Real rdOcp
Definition: ERF_InitCustomPert_ABL.H:128

Referenced by erf_resolved_wall_flux::apply(), TurbulentPerturbation::apply_tpi(), erf_slow_rhs_post(), and erf_slow_rhs_pre().

Here is the caller graph for this function:

◆ apply_face()

template<int DIR, bool HIGH>
AMREX_FORCE_INLINE void erf_cloud_chamber_wall_flux::apply_face ( const amrex::Box &  bx,
const amrex::Box &  domain,
const int  quantity,
const int  flux_comp,
const amrex::Array4< const amrex::Real > &  state,
const amrex::Array4< const amrex::Real > &  prim,
const amrex::Array4< const amrex::Real > &  base_state,
const amrex::Array4< const amrex::Real > &  u,
const amrex::Array4< const amrex::Real > &  v,
const amrex::Array4< const amrex::Real > &  w,
const amrex::Array4< amrex::Real > &  rhs,
const amrex::Array4< amrex::Real > &  xflux,
const amrex::Array4< amrex::Real > &  yflux,
const amrex::Array4< amrex::Real > &  zflux,
const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &  dx_inv,
const erf_wall_thermodynamics::Boundary &  walls,
const amrex::Real  alpha_T,
const amrex::Real  alpha_C,
const amrex::Real  rdOcp,
const bool  cloudy,
const erf_wall_thermodynamics::TemperatureBandView  bands = {} 
)
1211  {})
1212 {
1213  // A tile may belong to an interior BoxArray box. Do not relocate that
1214  // tile to a global boundary: its Array4 views do not own data there.
1215  if constexpr (HIGH) {
1216  if (bx.bigEnd(DIR) != domain.bigEnd(DIR)) { return; }
1217  } else {
1218  if (bx.smallEnd(DIR) != domain.smallEnd(DIR)) { return; }
1219  }
1220 
1221  const ScalarChannel channel =
1222  scalar_channel_from_quantity(quantity);
1223  if (channel == ScalarChannel::None) { return; }
1224 
1225  const auto wall = walls[2*DIR + (HIGH ? 1 : 0)];
1226  if (!wall_owns_scalar_channel(wall, channel)) { return; }
1227 
1228  const int prim_comp = primitive_component(channel);
1229  AMREX_ALWAYS_ASSERT(prim_comp >= 0);
1230 
1231  const int cell_face = HIGH ? domain.bigEnd(DIR) : domain.smallEnd(DIR);
1232  amrex::Box face_cells = bx;
1233  face_cells.setSmall(DIR, cell_face);
1234  face_cells.setBig(DIR, cell_face);
1235  face_cells &= domain;
1236  if (face_cells.isEmpty()) { return; }
1237  AMREX_ALWAYS_ASSERT(bx.contains(face_cells));
1238 
1239  const bool needs_speed = requires_tangential_speed(wall, channel);
1240  const auto& flux =
1241  (DIR == 0) ? xflux : ((DIR == 1) ? yflux : zflux);
1242 
1243  amrex::ParallelFor(face_cells,
1244  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
1245  {
1246  const int fi = HIGH && DIR == 0 ? i + 1 : i;
1247  const int fj = HIGH && DIR == 1 ? j + 1 : j;
1248  const int fk = HIGH && DIR == 2 ? k + 1 : k;
1249 
1250  const amrex::Real old_flux = flux(fi,fj,fk,flux_comp);
1251  const ScalarWallSample sample{
1252  state(i,j,k,Rho_comp),
1253  prim(i,j,k,prim_comp),
1254  base_state(i,j,k,BaseState::p0_comp),
1255  needs_speed ?
1256  tangential_speed(DIR, i, j, k, u, v, w, wall) :
1257  amrex::Real(0.0),
1258  alpha_T,
1259  alpha_C,
1260  dx_inv[DIR],
1261  rdOcp,
1262  amrex::Real(0.5) / dx_inv[DIR],
1263  prim(i,j,k,PrimTheta_comp),
1264  cloudy ? prim(i,j,k,PrimQ1_comp) : amrex::Real(0.0),
1265  DIR == 2 ? (HIGH ? -1 : 1) : 0
1266  };
1267 
1268  // Ownership was checked for this face/channel before the launch.
1269  const auto inward = evaluate_face_scalar_flux_in(wall, channel, sample, bands, k);
1270  const ScalarFluxReplacement update =
1271  scalar_flux_replacement<DIR,HIGH>(old_flux, inward, dx_inv[DIR]);
1272 
1273  flux(fi,fj,fk,flux_comp) = update.coordinate_flux;
1274  rhs(i,j,k,quantity) += update.rhs_delta;
1275  });
1276 }
#define PrimQ1_comp
Definition: ERF_IndexDefines.H:94
#define Rho_comp
Definition: ERF_IndexDefines.H:61
#define PrimTheta_comp
Definition: ERF_IndexDefines.H:91
AMREX_ALWAYS_ASSERT(bx.length()[2]==khi+1)
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);})
@ p0_comp
Definition: ERF_IndexDefines.H:110
@ fi
Definition: ERF_AdvanceMorrison.cpp:109
Definition: ERF_ConsoleIO.cpp:17
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real evaluate_face_scalar_flux_in(const erf_wall_thermodynamics::FaceWall &wall, ScalarChannel channel, const ScalarWallSample &sample, const erf_wall_thermodynamics::TemperatureBandView &bands, int k) noexcept
Definition: ERF_CloudChamberWallFlux.H:1149
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool requires_tangential_speed(const erf_wall_thermodynamics::FaceWall &wall, ScalarChannel channel) noexcept
Definition: ERF_CloudChamberWallFlux.H:653
ScalarChannel
Definition: ERF_CloudChamberWallFlux.H:55
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE ScalarChannel scalar_channel_from_quantity(int quantity) noexcept
Definition: ERF_CloudChamberWallFlux.H:143
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool wall_owns_scalar_channel(const erf_wall_thermodynamics::FaceWall &wall, ScalarChannel channel) noexcept
Definition: ERF_CloudChamberWallFlux.H:172
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int primitive_component(ScalarChannel channel) noexcept
Definition: ERF_CloudChamberWallFlux.H:154
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real tangential_speed(int dir, int i, int j, int k, const amrex::Array4< const amrex::Real > &u, const amrex::Array4< const amrex::Real > &v, const amrex::Array4< const amrex::Real > &w, const erf_wall_thermodynamics::FaceWall &wall) noexcept
Definition: ERF_CloudChamberWallFlux.H:834

◆ bulk_theta_flux_in()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_cloud_chamber_wall_flux::bulk_theta_flux_in ( amrex::Real  rho,
amrex::Real  C_H,
amrex::Real  U_t,
amrex::Real  wall_temperature_K,
amrex::Real  theta_air,
amrex::Real  p_hse,
amrex::Real  rdOcp,
amrex::Real  molecular_speed = amrex::Real(0) 
)
noexcept
780 {
781  const amrex::Real theta_wall =
782  wall_temperature_K * std::pow(p_0 / p_hse, rdOcp);
783  return (rho * C_H * U_t + rho * molecular_speed) * (theta_wall - theta_air);
784 }
constexpr amrex::Real p_0
Definition: ERF_Constants.H:69
@ rho
Definition: ERF_Kessler.H:25

Referenced by evaluate_scalar_flux_in().

Here is the caller graph for this function:

◆ bulk_vapor_flux_in()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_cloud_chamber_wall_flux::bulk_vapor_flux_in ( amrex::Real  rho,
amrex::Real  C_E,
amrex::Real  U_t,
const erf_wall_thermodynamics::FaceWall &  wall,
amrex::Real  qv_air,
amrex::Real  p_hse,
amrex::Real  molecular_speed = amrex::Real(0) 
)
noexcept
796 {
797  const amrex::Real qv_wall = wet_wall_qv(wall, p_hse);
798  return (rho * C_E * U_t + rho * molecular_speed) * (qv_wall - qv_air);
799 }
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real wet_wall_qv(const erf_wall_thermodynamics::FaceWall &wall, amrex::Real p_hse) noexcept
Definition: ERF_CloudChamberWallFlux.H:462

Referenced by evaluate_scalar_flux_in().

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

◆ evaluate_face_scalar_flux_in()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_cloud_chamber_wall_flux::evaluate_face_scalar_flux_in ( const erf_wall_thermodynamics::FaceWall &  wall,
ScalarChannel  channel,
const ScalarWallSample &  sample,
const erf_wall_thermodynamics::TemperatureBandView &  bands,
int  k 
)
noexcept
1153 {
1154  const bool uses_temperature = (channel == ScalarChannel::Heat && wall.heat_is_conductive()) ||
1155  (channel == ScalarChannel::Vapor && wall.vapor_is_wet());
1156  if (!bands.offsets || !uses_temperature) {
1157  return scalar_flux_in(evaluate_scalar_flux_in(wall, channel, sample), channel);
1158  }
1159  const int row = k - bands.k_lo;
1160  auto panel_wall = wall;
1161  amrex::Real inward = 0;
1162  for (int n = bands.offsets[row]; n < bands.offsets[row+1]; ++n) {
1163  const auto panel = bands.panels[n];
1164  panel_wall.thermal.temperature_K = panel.temperature_K;
1165  inward += panel.fraction * scalar_flux_in(evaluate_scalar_flux_in(panel_wall, channel, sample), channel);
1166  }
1167  return inward;
1168 }
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE WallFlux evaluate_scalar_flux_in(const erf_wall_thermodynamics::FaceWall &wall, ScalarChannel channel, const ScalarWallSample &sample) noexcept
Definition: ERF_CloudChamberWallFlux.H:994
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real scalar_flux_in(const WallFlux &flux, ScalarChannel channel) noexcept
Definition: ERF_CloudChamberWallFlux.H:1130
constexpr AMREX_GPU_HOST_DEVICE bool heat_is_conductive() const noexcept
Definition: ERF_WallThermodynamics.H:96
constexpr AMREX_GPU_HOST_DEVICE bool vapor_is_wet() const noexcept
Definition: ERF_WallThermodynamics.H:99
const TemperaturePanel * panels
Definition: ERF_WallThermodynamics.H:59
const int * offsets
Definition: ERF_WallThermodynamics.H:58
int k_lo
Definition: ERF_WallThermodynamics.H:60
amrex::Real temperature_K
Definition: ERF_WallThermodynamics.H:53
Here is the call graph for this function:

◆ evaluate_momentum_traction()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE WallFlux erf_cloud_chamber_wall_flux::evaluate_momentum_traction ( const erf_wall_thermodynamics::FaceWall &  wall,
const MomentumWallSample &  sample 
)
noexcept
954 {
955  using namespace erf_wall_thermodynamics;
956 
957  WallFlux result{};
958  switch (wall.momentum.model) {
960  return result;
962  result.owned_channels = OwnMomentum;
963  const auto neutral = neutral_log_momentum_state(
964  sample.U_t, sample.wall_distance, wall.momentum.z0_m);
965  result.traction_on_fluid =
966  neutral_log_traction_on_fluid(sample, neutral);
967  return result;
968  }
970  result.owned_channels = OwnMomentum;
971  if (sample.U_t == amrex::Real(0.0)) { return result; }
972  amrex::Real C_D = wall.momentum.C_D;
974  const auto runtime = most_wall_coefficients(
975  wall, sample.theta_air, sample.qv_air, sample.p_hse,
976  sample.rdOcp, sample.U_t, sample.wall_distance,
977  sample.gravity_sign);
978  AMREX_ALWAYS_ASSERT(runtime.valid != 0);
979  C_D = runtime.C_D;
980  }
981  const amrex::Real factor = -sample.rho * C_D * sample.U_t - sample.rho * wall.momentum.molecular_speed;
982  result.traction_on_fluid = {
983  factor * sample.u_t[0], factor * sample.u_t[1], factor * sample.u_t[2]};
984  return result;
985  }
986  }
987  AMREX_ALWAYS_ASSERT(false);
988  return result;
989 }
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE NeutralLogMomentumState neutral_log_momentum_state(amrex::Real U_t, amrex::Real wall_distance, amrex::Real z0_m) noexcept
Definition: ERF_CloudChamberWallFlux.H:221
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE FaceRuntimeCoefficients most_wall_coefficients(const erf_wall_thermodynamics::FaceWall &wall, amrex::Real theta_air, amrex::Real qv_air, amrex::Real p_hse, amrex::Real rdOcp, amrex::Real U_t, amrex::Real wall_distance, int gravity_sign) noexcept
Definition: ERF_CloudChamberWallFlux.H:473
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > neutral_log_traction_on_fluid(const MomentumWallSample &sample, const NeutralLogMomentumState &neutral) noexcept
Definition: ERF_CloudChamberWallFlux.H:560
Definition: ERF_WallThermodynamics.H:10
MomentumTransfer momentum
Definition: ERF_WallThermodynamics.H:90
amrex::Real z0_m
Definition: ERF_WallThermodynamics.H:70
CoefficientProvider provider
Definition: ERF_WallThermodynamics.H:68
amrex::Real C_D
Definition: ERF_WallThermodynamics.H:69
MomentumModel model
Definition: ERF_WallThermodynamics.H:67
amrex::Real molecular_speed
Definition: ERF_WallThermodynamics.H:71

Referenced by erf_cloud_chamber_wall_stress::wall_traction_at_cell().

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

◆ evaluate_scalar_flux_in()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE WallFlux erf_cloud_chamber_wall_flux::evaluate_scalar_flux_in ( const erf_wall_thermodynamics::FaceWall &  wall,
ScalarChannel  channel,
const ScalarWallSample &  sample 
)
noexcept
998 {
999  using namespace erf_wall_thermodynamics;
1000 
1001  WallFlux result{};
1002  if (!wall_owns_scalar_channel(wall, channel)) {
1003  return result;
1004  }
1005 
1006  result.owned_channels = scalar_channel_mask(channel);
1007 
1008  switch (channel) {
1009  case ScalarChannel::Heat:
1010  // An owned zero replaces ordinary diffusion and removes its RHS contribution.
1011  if (!wall.heat_is_conductive()) { return result; }
1012  if (sample.U_t == amrex::Real(0.0) &&
1014  return result;
1015  }
1016  switch (wall.heat.model) {
1018  result.rhoTheta_in = resolved_theta_flux_in(
1019  sample.rho,
1020  sample.alpha_T,
1021  wall.thermal.temperature_K,
1022  sample.scalar_air,
1023  sample.p_hse,
1024  sample.dx_inv,
1025  sample.rdOcp);
1026  return result;
1027 
1028  case ScalarModel::BulkAero: {
1029  amrex::Real C_H = wall.heat.coefficient;
1030  if (wall.heat.provider == CoefficientProvider::MOST) {
1031  const auto runtime = most_wall_coefficients(
1032  wall, sample.theta_air, sample.qv_air, sample.p_hse,
1033  sample.rdOcp, sample.U_t, sample.wall_distance,
1034  sample.gravity_sign);
1035  AMREX_ALWAYS_ASSERT(runtime.valid != 0);
1036  C_H = runtime.C_H;
1037  }
1038  result.rhoTheta_in = bulk_theta_flux_in(
1039  sample.rho,
1040  C_H,
1041  sample.U_t,
1042  wall.thermal.temperature_K,
1043  sample.scalar_air,
1044  sample.p_hse,
1045  sample.rdOcp, wall.heat.molecular_speed);
1046  return result;
1047  }
1049  result.rhoTheta_in = bulk_theta_flux_in(
1050  sample.rho,
1052  sample.wall_distance,
1053  wall.momentum.z0_m,
1054  wall.heat.z0),
1055  sample.U_t,
1056  wall.thermal.temperature_K,
1057  sample.scalar_air,
1058  sample.p_hse,
1059  sample.rdOcp);
1060  return result;
1061  }
1062  AMREX_ALWAYS_ASSERT(false);
1063  return result;
1064 
1065  case ScalarChannel::Vapor:
1066  if (!wall.vapor_is_wet()) { return result; }
1067  if (sample.U_t == amrex::Real(0.0) &&
1069  return result;
1070  }
1071  switch (wall.vapor.model) {
1073  result.rhoQv_in = resolved_vapor_flux_in(
1074  sample.rho,
1075  sample.alpha_C,
1076  wall,
1077  sample.scalar_air,
1078  sample.p_hse,
1079  sample.dx_inv);
1080  return result;
1081 
1082  case ScalarModel::BulkAero: {
1083  amrex::Real C_E = wall.vapor.coefficient;
1085  const auto runtime = most_wall_coefficients(
1086  wall, sample.theta_air, sample.qv_air, sample.p_hse,
1087  sample.rdOcp, sample.U_t, sample.wall_distance,
1088  sample.gravity_sign);
1089  AMREX_ALWAYS_ASSERT(runtime.valid != 0);
1090  C_E = runtime.C_E;
1091  }
1092  result.rhoQv_in = bulk_vapor_flux_in(
1093  sample.rho,
1094  C_E,
1095  sample.U_t,
1096  wall,
1097  sample.scalar_air,
1098  sample.p_hse, wall.vapor.molecular_speed);
1099  return result;
1100  }
1102  result.rhoQv_in = bulk_vapor_flux_in(
1103  sample.rho,
1105  sample.wall_distance,
1106  wall.momentum.z0_m,
1107  wall.vapor.z0),
1108  sample.U_t,
1109  wall,
1110  sample.scalar_air,
1111  sample.p_hse);
1112  return result;
1113  }
1114  AMREX_ALWAYS_ASSERT(false);
1115  return result;
1116 
1117  case ScalarChannel::CloudWater:
1118  return result;
1119 
1120  case ScalarChannel::None:
1121  return result;
1122  }
1123 
1124  return result;
1125 }
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real bulk_vapor_flux_in(amrex::Real rho, amrex::Real C_E, amrex::Real U_t, const erf_wall_thermodynamics::FaceWall &wall, amrex::Real qv_air, amrex::Real p_hse, amrex::Real molecular_speed=amrex::Real(0)) noexcept
Definition: ERF_CloudChamberWallFlux.H:789
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real resolved_vapor_flux_in(amrex::Real rho, amrex::Real alpha_C, const erf_wall_thermodynamics::FaceWall &wall, amrex::Real qv_air, amrex::Real p_hse, amrex::Real dx_inv) noexcept
Definition: ERF_CloudChamberWallFlux.H:935
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real neutral_log_scalar_coefficient(amrex::Real wall_distance, amrex::Real z0_m, amrex::Real z0_scalar) noexcept
Definition: ERF_CloudChamberWallFlux.H:233
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real resolved_theta_flux_in(amrex::Real rho, amrex::Real alpha_T, amrex::Real wall_temperature_K, amrex::Real theta_air, amrex::Real p_hse, amrex::Real dx_inv, amrex::Real rdOcp) noexcept
Definition: ERF_CloudChamberWallFlux.H:917
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE unsigned char scalar_channel_mask(ScalarChannel channel) noexcept
Definition: ERF_CloudChamberWallFlux.H:194
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real bulk_theta_flux_in(amrex::Real rho, amrex::Real C_H, amrex::Real U_t, amrex::Real wall_temperature_K, amrex::Real theta_air, amrex::Real p_hse, amrex::Real rdOcp, amrex::Real molecular_speed=amrex::Real(0)) noexcept
Definition: ERF_CloudChamberWallFlux.H:772
ScalarTransfer vapor
Definition: ERF_WallThermodynamics.H:92
ScalarTransfer heat
Definition: ERF_WallThermodynamics.H:91
ThermalBoundary thermal
Definition: ERF_WallThermodynamics.H:87
amrex::Real coefficient
Definition: ERF_WallThermodynamics.H:78
CoefficientProvider provider
Definition: ERF_WallThermodynamics.H:77
amrex::Real z0
Definition: ERF_WallThermodynamics.H:79
amrex::Real molecular_speed
Definition: ERF_WallThermodynamics.H:81
ScalarModel model
Definition: ERF_WallThermodynamics.H:76
amrex::Real temperature_K
Definition: ERF_WallThermodynamics.H:46

Referenced by evaluate_face_scalar_flux_in().

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

◆ has_velocity_dependent_scalar_wall()

bool erf_cloud_chamber_wall_flux::has_velocity_dependent_scalar_wall ( const erf_wall_thermodynamics::Boundary &  walls)
inlinenoexcept
1307 {
1308  for (const auto& wall : walls) {
1309  if (requires_tangential_speed(wall, ScalarChannel::Heat) ||
1310  requires_tangential_speed(wall, ScalarChannel::Vapor)) {
1311  return true;
1312  }
1313  }
1314  return false;
1315 }

Referenced by erf_resolved_wall_flux::apply().

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

◆ momentum_infinity_row_sum_factor()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_cloud_chamber_wall_flux::momentum_infinity_row_sum_factor ( )
noexcept
585 {
586  // For a fixed C_D, the maximum absolute row sum of the two-component
587  // tangential Jacobian of C_D |u_t| u_t is (3 + sqrt(2))/2 * C_D |u_t|.
588  // Cloud Chamber MOST applies this factor to its frozen current C_D.
589  return (amrex::Real(3.0) + std::sqrt(amrex::Real(2.0))) / amrex::Real(2.0);
590 }

◆ momentum_rate_for_face()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_cloud_chamber_wall_flux::momentum_rate_for_face ( const erf_wall_thermodynamics::FaceWall &  wall,
amrex::Real  U_t,
amrex::Real  dx_inv,
const FaceRuntimeCoefficients &  runtime = FaceRuntimeCoefficients{} 
)
noexcept
627  {}) noexcept
628 {
629  using namespace erf_wall_thermodynamics;
630  amrex::Real C_D = amrex::Real(0.0);
631  const amrex::Real wall_distance = amrex::Real(0.5) / dx_inv;
632  if (wall.momentum.model !=
636  U_t, wall_distance, wall.momentum.z0_m).C_D;
637  } else if (wall.momentum.model == MomentumModel::BulkAero) {
639  AMREX_ALWAYS_ASSERT(runtime.valid != 0);
640  C_D = runtime.C_D;
641  } else {
642  C_D = wall.momentum.C_D;
643  }
644  }
645  }
646  return momentum_infinity_row_sum_factor() * C_D * U_t * dx_inv +
647  wall.momentum.molecular_speed * dx_inv;
648 }
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real momentum_infinity_row_sum_factor() noexcept
Definition: ERF_CloudChamberWallFlux.H:584
amrex::Real C_D
Definition: ERF_CloudChamberWallFlux.H:80

Referenced by wall_rate_for_cell().

Here is the caller graph for this function:

◆ momentum_row_sum_rate()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_cloud_chamber_wall_flux::momentum_row_sum_rate ( int  component,
const amrex::GpuArray< DirectionalMomentumRate, AMREX_SPACEDIM > &  rates 
)
noexcept
604 {
605  // Only walls tangential to this component enter its row. A combined momentum
606  // wall activates ordinary no-slip shear on that same row, not on all three.
607  // Otherwise keep the modeled-only sum; never add a second stress to the RHS.
608  amrex::Real modeled = 0, resolved = 0;
609  bool combined = false;
610  for (int dir = 0; dir < AMREX_SPACEDIM; ++dir) {
611  if (dir != component) {
612  modeled += rates[dir].modeled;
613  resolved += rates[dir].resolved;
614  combined |= rates[dir].combined;
615  }
616  }
617  return combined ? modeled + resolved : modeled;
618 }

Referenced by wall_rate_for_cell().

Here is the caller graph for this function:

◆ most_stability_coordinate()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE MostStabilityResult erf_cloud_chamber_wall_flux::most_stability_coordinate ( amrex::Real  Ri,
amrex::Real  D_m,
amrex::Real  D_s 
)
noexcept
265 {
266  similarity_funs sfuns;
267  constexpr amrex::Real tolerance = amrex::Real(1.0e-3);
268  if (Ri > amrex::Real(0.0)) {
269  int iterations = 0;
270  const auto state =
271  [=] AMREX_GPU_HOST_DEVICE(
272  amrex::Real z) noexcept -> amrex::GpuArray<amrex::Real, 3> {
273  const amrex::Real psi_m = sfuns.calc_psi_m2(z);
274  const amrex::Real psi_s = sfuns.calc_psi_h2(z);
275  const amrex::Real A_m = amrex::max(D_m - psi_m, amrex::Real(1.0));
276  const amrex::Real A_s = amrex::max(D_s - psi_s, amrex::Real(1.0));
277  const amrex::Real rhs = Ri * A_m * A_m / A_s;
279  amrex::Math::isfinite(static_cast<double>(psi_m)) &&
280  amrex::Math::isfinite(static_cast<double>(psi_s)) &&
281  amrex::Math::isfinite(static_cast<double>(A_m)) &&
282  amrex::Math::isfinite(static_cast<double>(A_s)) &&
283  amrex::Math::isfinite(static_cast<double>(rhs)) &&
284  amrex::Math::isfinite(static_cast<double>(z - rhs)),
285  "Cloud Chamber MOST produced a nonfinite stable residual");
286  return {A_m, A_s, z - rhs};
287  };
289  amrex::Math::isfinite(static_cast<double>(Ri)) &&
290  amrex::Math::isfinite(static_cast<double>(D_m)) &&
291  amrex::Math::isfinite(static_cast<double>(D_s)) &&
292  D_m > amrex::Real(0.0) && D_s > amrex::Real(0.0),
293  "Cloud Chamber MOST requires finite positive stable resistances");
294 
295  const auto interpolate = [=] AMREX_GPU_HOST_DEVICE(
296  amrex::Real a, amrex::Real b,
297  amrex::Real fa, amrex::Real fb) noexcept {
299  b > a && b - a <= tolerance && fa <= amrex::Real(0.0) &&
300  fb >= amrex::Real(0.0) && fb > fa &&
301  amrex::Math::isfinite(static_cast<double>(fb - fa)),
302  "Cloud Chamber MOST requires a certified stable root bracket");
303  const amrex::Real z = a + (b - a) * (-fa / (fb - fa));
305  amrex::Math::isfinite(static_cast<double>(z)) && z >= a &&
306  z <= b,
307  "Cloud Chamber MOST produced an invalid bracket interpolation");
308  return z;
309  };
310 
311  amrex::Real seed = amrex::Real(0.0);
312  for (int iter = 0; iter < 100; ++iter) {
313  const auto value = state(seed);
314  ++iterations;
315  if (value[2] == amrex::Real(0.0)) {
316  return {seed, iterations};
317  }
318  const amrex::Real next = seed - amrex::Real(0.5) * value[2];
320  amrex::Math::isfinite(static_cast<double>(next)),
321  "Cloud Chamber MOST produced a nonfinite stability coordinate");
322  const bool small_update =
323  std::abs(next - seed) <= amrex::Real(0.125) * tolerance;
324  seed = next;
325  if (small_update) {
326  break;
327  }
328  }
329 
330  // Keep the iteration's branch only if a root really lies nearby.
331  amrex::Real a = amrex::max(amrex::Real(0.0), seed - tolerance);
332  amrex::Real b = seed + tolerance;
333  auto va = state(a);
334  auto vb = state(b);
335  if (va[2] <= amrex::Real(0.0) && vb[2] >= amrex::Real(0.0)) {
336  for (int iter = 0; iter < 64; ++iter) {
337  ++iterations;
338  if (va[2] == amrex::Real(0.0)) {
339  return {a, iterations};
340  }
341  if (vb[2] == amrex::Real(0.0)) {
342  return {b, iterations};
343  }
344  const amrex::Real mid = a + amrex::Real(0.5) * (b - a);
345  if (b - a <= tolerance) {
346  return {interpolate(a, b, va[2], vb[2]), iterations};
347  }
349  mid > a && mid < b,
350  "Cloud Chamber MOST exhausted stable root precision");
351  const auto vm = state(mid);
352  if (vm[2] < amrex::Real(0.0)) {
353  a = mid;
354  va = vm;
355  } else {
356  b = mid;
357  vb = vm;
358  }
359  }
360  }
361 
362  // Search from neutral in order: endpoint signs alone can miss a
363  // narrow first-root pair. Stable A_m and A_s increase with z, giving
364  // F(z) <= b - Ri*A_m(a)^2/A_s(b) throughout [a,b].
365  constexpr int max_depth = 64;
366  amrex::GpuArray<amrex::Real, max_depth> pending{};
367  int depth = 0;
368  amrex::Real unresolved = amrex::Real(-1.0);
369  a = amrex::Real(0.0);
370  b = amrex::max(amrex::Real(1.0), seed);
371  va = state(a);
372  vb = state(b);
373  for (int search = 0; search < 8192; ++search) {
374  ++iterations;
376  amrex::Math::isfinite(static_cast<double>(a)) &&
377  amrex::Math::isfinite(static_cast<double>(b)) && b > a &&
378  va[2] <= amrex::Real(0.0),
379  "Cloud Chamber MOST exhausted stable bracket range");
380  if (unresolved >= amrex::Real(0.0)) {
381  const amrex::Real limit = unresolved + tolerance;
383  a < limit,
384  "Cloud Chamber MOST cannot resolve the stable root branch");
385  if (b > limit) {
386  b = limit;
387  vb = state(b);
388  }
389  }
390  if (va[2] == amrex::Real(0.0)) {
391  return {a, iterations};
392  }
393  const amrex::Real mid = a + amrex::Real(0.5) * (b - a);
394  if (vb[2] >= amrex::Real(0.0) && b - a <= tolerance) {
395  return {interpolate(a, b, va[2], vb[2]), iterations};
396  }
397  const amrex::Real lower_rhs = Ri * va[0] * va[0] / vb[1];
398  const amrex::Real roundoff =
399  amrex::Real(16.0) *
401  amrex::max(b, lower_rhs);
402  if (vb[2] < amrex::Real(0.0) && b - lower_rhs < -roundoff) {
403  a = b;
404  va = vb;
405  b = depth > 0 ? pending[--depth] : amrex::Real(2.0) * b;
406  } else if (depth < max_depth && mid > a && mid < b) {
407  pending[depth++] = b;
408  b = mid;
409  } else {
410  // Retain a rounding-ambiguous interval in the location error
411  // bound; never step past it to a distant root.
413  b - a <= tolerance && vb[2] < amrex::Real(0.0),
414  "Cloud Chamber MOST exhausted stable root precision");
415  if (unresolved < amrex::Real(0.0)) {
416  unresolved = a;
417  }
418  a = b;
419  va = vb;
420  b = depth > 0 ? pending[--depth] : amrex::Real(2.0) * b;
421  }
423  amrex::Math::isfinite(static_cast<double>(b)) && b > a,
424  "Cloud Chamber MOST exhausted stable bracket range");
425  vb = state(b);
426  }
428  false, "Cloud Chamber MOST exhausted stable root search budget");
429  return {std::numeric_limits<amrex::Real>::quiet_NaN(), -iterations};
430  }
431 
432  amrex::Real zeta = amrex::Real(0.0);
433  bool converged = false;
434  int iterations = 0;
435  constexpr int max_iters = 100;
436  for (int iter = 0; iter < max_iters; ++iter) {
437  const amrex::Real zeta_old = zeta;
438  const amrex::Real psi_m = sfuns.calc_psi_m2(zeta_old);
439  const amrex::Real psi_s = sfuns.calc_psi_h2(zeta_old);
440  const amrex::Real A_m = amrex::max(D_m - psi_m, amrex::Real(1.0));
441  const amrex::Real A_s = amrex::max(D_s - psi_s, amrex::Real(1.0));
442  const amrex::Real zeta_new = amrex::Real(0.5) * zeta_old +
443  amrex::Real(0.5) * Ri * A_m * A_m / A_s;
445  amrex::Math::isfinite(static_cast<double>(zeta_new)),
446  "Cloud Chamber MOST produced a nonfinite stability coordinate");
447  zeta = zeta_new;
448  iterations = iter + 1;
449  if (std::abs(zeta - zeta_old) <= amrex::Real(1.0e-3)) {
450  converged = true;
451  break;
452  }
453  }
455  converged, "Cloud Chamber MOST fixed-point iteration did not converge");
456  return {zeta, iterations};
457 }
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void most_stability_require(bool condition, const char *message) noexcept
Definition: ERF_CloudChamberWallFlux.H:245
real(c_double), parameter epsilon
Definition: ERF_module_model_constants.F90:12
Definition: ERF_MOSTUtils.H:84
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real calc_psi_h2(amrex::Real zeta) const
Definition: ERF_MOSTUtils.H:121
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real calc_psi_m2(amrex::Real zeta) const
Definition: ERF_MOSTUtils.H:96

Referenced by most_wall_coefficients().

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

◆ most_stability_require()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void erf_cloud_chamber_wall_flux::most_stability_require ( bool  condition,
const char *  message 
)
noexcept
246 {
247  if (!condition) {
248  // AMReX device assertions and Abort can be disabled by NDEBUG.
249  AMREX_IF_ON_DEVICE((AMREX_DEVICE_PRINTF("%s\n", message);))
250 #if defined(AMREX_USE_CUDA)
251  AMREX_IF_ON_DEVICE((__trap();))
252 #else
253  AMREX_IF_ON_DEVICE((__builtin_trap();))
254 #endif
255  AMREX_IF_ON_HOST((amrex::Abort(message); std::abort();))
256  }
257 }
std::string message
Definition: ERF_InputPreflight.cpp:25

Referenced by most_stability_coordinate(), and most_wall_coefficients().

Here is the caller graph for this function:

◆ most_wall_coefficients()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE FaceRuntimeCoefficients erf_cloud_chamber_wall_flux::most_wall_coefficients ( const erf_wall_thermodynamics::FaceWall &  wall,
amrex::Real  theta_air,
amrex::Real  qv_air,
amrex::Real  p_hse,
amrex::Real  rdOcp,
amrex::Real  U_t,
amrex::Real  wall_distance,
int  gravity_sign 
)
noexcept
482 {
483  using namespace erf_wall_thermodynamics;
484  FaceRuntimeCoefficients result{};
485  const bool most_momentum = wall.momentum_uses_most();
486  const bool most_heat = wall_uses_most_heat(wall);
487  const bool most_vapor = wall_uses_most_vapor(wall);
488  if (!(most_momentum || most_heat || most_vapor)) {
489  result.valid = 1;
490  return result;
491  }
492 
493  amrex::Real qv_wall = qv_air;
494  if (wall.vapor_is_wet()) {
495  qv_wall = wet_wall_qv(wall, p_hse);
496  }
497  const bool adiabatic = wall.thermal.mode == ThermalMode::Adiabatic;
498  amrex::Real delta_theta_v;
499  if (adiabatic) {
500  // theta_wall = theta_air: only wet-wall saturation can drive buoyancy.
501  // Difference the mixing ratios first so equal humidities are exactly neutral.
502  delta_theta_v = theta_air * epsv * (qv_air - qv_wall);
503  } else {
504  const amrex::Real theta_wall = wall.thermal.temperature_K *
505  std::pow(p_0 / p_hse, rdOcp);
506  const amrex::Real theta_v_air = theta_air * (amrex::Real(1.0) + epsv * qv_air);
507  const amrex::Real theta_v_wall = theta_wall * (amrex::Real(1.0) + epsv * qv_wall);
508  delta_theta_v = theta_v_air - theta_v_wall;
509  }
510  const amrex::Real U_most = amrex::max(U_t, amrex::Real(0.01));
511  const amrex::Real Ri_b = gravity_sign == 0 ? amrex::Real(0.0) :
512  amrex::Real(gravity_sign) * CONST_GRAV * wall_distance / theta_air *
513  delta_theta_v / (U_most * U_most);
514  const amrex::Real Ri = amrex::max(amrex::Real(-4.0),
515  amrex::min(amrex::Real(4.0), Ri_b));
516 
517  const amrex::Real z0_m = wall.momentum.z0_m;
518  const amrex::Real z0_q = wall.vapor.z0 > amrex::Real(0.0) ?
519  wall.vapor.z0 : z0_m;
520  const amrex::Real D_m = std::log(wall_distance / z0_m);
521  // Keep returning all coefficients, but never sample an adiabatic heat roughness.
522  const amrex::Real D_h = wall.heat_is_conductive() && wall.heat.z0 > amrex::Real(0.0) ?
523  std::log(wall_distance / wall.heat.z0) : D_m;
524  const amrex::Real D_q = std::log(wall_distance / z0_q);
525 
526  // A coupled MOST heat/vapor face is host-constrained to have equal scalar
527  // roughness. For a single active scalar channel, that channel supplies
528  // the scalar resistance used by the bulk-Richardson fixed point.
529  const amrex::Real D_stability = most_heat ? D_h : (most_vapor ? D_q : D_m);
530  const auto stability = most_stability_coordinate(Ri, D_m, D_stability);
531  const amrex::Real zeta = stability.zeta;
533  stability.iterations > 0 &&
534  amrex::Math::isfinite(static_cast<double>(zeta)),
535  "Cloud Chamber MOST returned an uncertified stability coordinate");
536 
537  similarity_funs sfuns;
538  const amrex::Real psi_m = sfuns.calc_psi_m2(zeta);
539  const amrex::Real psi_h = sfuns.calc_psi_h2(zeta);
540  const amrex::Real A_m = amrex::max(D_m - psi_m, amrex::Real(1.0));
541  const amrex::Real A_h = amrex::max(D_h - psi_h, amrex::Real(1.0));
542  const amrex::Real A_q = amrex::max(D_q - psi_h, amrex::Real(1.0));
543  result.C_D = (KAPPA / A_m) * (KAPPA / A_m);
544  result.C_H = KAPPA * KAPPA / (A_m * A_h);
545  result.C_E = KAPPA * KAPPA / (A_m * A_q);
546  result.u_star = KAPPA * U_most / A_m;
547  result.zeta = zeta;
548  result.valid = 1;
550  amrex::Math::isfinite(static_cast<double>(result.C_D)) &&
551  amrex::Math::isfinite(static_cast<double>(result.C_H)) &&
552  amrex::Math::isfinite(static_cast<double>(result.C_E)),
553  "Cloud Chamber MOST produced nonfinite transfer coefficients");
554  return result;
555 }
constexpr amrex::Real epsv
Definition: ERF_Constants.H:56
constexpr amrex::Real KAPPA
Definition: ERF_Constants.H:71
constexpr amrex::Real CONST_GRAV
Definition: ERF_Constants.H:72
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE MostStabilityResult most_stability_coordinate(amrex::Real Ri, amrex::Real D_m, amrex::Real D_s) noexcept
Definition: ERF_CloudChamberWallFlux.H:262
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool wall_uses_most_heat(const erf_wall_thermodynamics::FaceWall &wall) noexcept
Definition: ERF_CloudChamberWallFlux.H:119
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool wall_uses_most_vapor(const erf_wall_thermodynamics::FaceWall &wall) noexcept
Definition: ERF_CloudChamberWallFlux.H:127
Definition: ERF_MOSTStress.H:20
constexpr AMREX_GPU_HOST_DEVICE bool momentum_uses_most() const noexcept
Definition: ERF_WallThermodynamics.H:102
ThermalMode mode
Definition: ERF_WallThermodynamics.H:45

Referenced by evaluate_momentum_traction(), evaluate_scalar_flux_in(), and wall_rate_for_cell().

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

◆ neutral_log_momentum_state()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE NeutralLogMomentumState erf_cloud_chamber_wall_flux::neutral_log_momentum_state ( amrex::Real  U_t,
amrex::Real  wall_distance,
amrex::Real  z0_m 
)
noexcept
224 {
225  const amrex::Real log_m = std::log(wall_distance / z0_m);
226  const amrex::Real k_over_log = KAPPA / log_m;
227  return {log_m, k_over_log * k_over_log, k_over_log * U_t};
228 }

Referenced by evaluate_momentum_traction().

Here is the caller graph for this function:

◆ neutral_log_scalar_coefficient()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_cloud_chamber_wall_flux::neutral_log_scalar_coefficient ( amrex::Real  wall_distance,
amrex::Real  z0_m,
amrex::Real  z0_scalar 
)
noexcept
236 {
237  const amrex::Real log_m = std::log(wall_distance / z0_m);
238  const amrex::Real log_s = std::log(wall_distance / z0_scalar);
239  return (KAPPA * KAPPA) / (log_m * log_s);
240 }

Referenced by erf_cloud_chamber_wall_flux::CellScalarWallRate::add(), and evaluate_scalar_flux_in().

Here is the caller graph for this function:

◆ neutral_log_traction_on_fluid()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> erf_cloud_chamber_wall_flux::neutral_log_traction_on_fluid ( const MomentumWallSample &  sample,
const NeutralLogMomentumState &  neutral 
)
noexcept
562 {
563  const amrex::Real factor =
564  -sample.rho * neutral.C_D * sample.U_t;
565  return {factor * sample.u_t[0],
566  factor * sample.u_t[1],
567  factor * sample.u_t[2]};
568 }

Referenced by evaluate_momentum_traction().

Here is the caller graph for this function:

◆ neutral_scalar_rate()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_cloud_chamber_wall_flux::neutral_scalar_rate ( amrex::Real  coefficient,
amrex::Real  U_t,
amrex::Real  dx_inv 
)
noexcept
576 {
577  return coefficient * U_t * dx_inv;
578 }

Referenced by erf_cloud_chamber_wall_flux::CellScalarWallRate::add().

Here is the caller graph for this function:

◆ owns()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool erf_cloud_chamber_wall_flux::owns ( const WallFlux &  flux,
ScalarChannel  channel 
)
noexcept
214 {
215  return (flux.owned_channels & scalar_channel_mask(channel)) != 0;
216 }
Here is the call graph for this function:

◆ primitive_component()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int erf_cloud_chamber_wall_flux::primitive_component ( ScalarChannel  channel)
noexcept
155 {
156  switch (channel) {
157  case ScalarChannel::Heat:
158  return PrimTheta_comp;
159  case ScalarChannel::Vapor:
160  return PrimQ1_comp;
161  case ScalarChannel::CloudWater:
162  return PrimQ2_comp;
163  case ScalarChannel::None:
164  break;
165  }
166  return -1;
167 }
#define PrimQ2_comp
Definition: ERF_IndexDefines.H:95

◆ relative_tangential_velocity_cell_centered()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> erf_cloud_chamber_wall_flux::relative_tangential_velocity_cell_centered ( int  dir,
int  i,
int  j,
int  k,
const amrex::Array4< const amrex::Real > &  u,
const amrex::Array4< const amrex::Real > &  v,
const amrex::Array4< const amrex::Real > &  w,
const erf_wall_thermodynamics::FaceWall &  wall 
)
noexcept
810 {
811  const amrex::Real uc =
812  amrex::Real(0.5) * (u(i,j,k) + u(i+1,j,k)) - wall.wall_velocity[0];
813  const amrex::Real vc =
814  amrex::Real(0.5) * (v(i,j,k) + v(i,j+1,k)) - wall.wall_velocity[1];
815  const amrex::Real wc =
816  amrex::Real(0.5) * (w(i,j,k) + w(i,j,k+1)) - wall.wall_velocity[2];
817  amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> result{uc, vc, wc};
818  result[dir] = amrex::Real(0.0);
819  return result;
820 }
amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > wall_velocity
Definition: ERF_WallThermodynamics.H:93

Referenced by tangential_speed(), and erf_cloud_chamber_wall_stress::wall_traction_at_cell().

Here is the caller graph for this function:

◆ requires_tangential_momentum()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool erf_cloud_chamber_wall_flux::requires_tangential_momentum ( const erf_wall_thermodynamics::FaceWall &  wall)
noexcept
675 {
676  return wall.momentum_requires_speed();
677 }
constexpr AMREX_GPU_HOST_DEVICE bool momentum_requires_speed() const noexcept
Definition: ERF_WallThermodynamics.H:120

Referenced by erf_cloud_chamber_wall_stress::apply_face(), erf_cloud_chamber_wall_stress::has_momentum_wall(), and wall_rate_for_cell().

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

◆ requires_tangential_speed()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool erf_cloud_chamber_wall_flux::requires_tangential_speed ( const erf_wall_thermodynamics::FaceWall &  wall,
ScalarChannel  channel 
)
noexcept
656 {
657  switch (channel) {
658  case ScalarChannel::Heat:
659  return wall.heat_requires_speed();
660  case ScalarChannel::Vapor:
661  return wall.vapor_requires_speed();
662  case ScalarChannel::CloudWater:
663  case ScalarChannel::None:
664  return false;
665  }
666 
667  return false;
668 }
constexpr AMREX_GPU_HOST_DEVICE bool vapor_requires_speed() const noexcept
Definition: ERF_WallThermodynamics.H:126
constexpr AMREX_GPU_HOST_DEVICE bool heat_requires_speed() const noexcept
Definition: ERF_WallThermodynamics.H:123

Referenced by has_velocity_dependent_scalar_wall().

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

◆ resolved_theta_flux_in()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_cloud_chamber_wall_flux::resolved_theta_flux_in ( amrex::Real  rho,
amrex::Real  alpha_T,
amrex::Real  wall_temperature_K,
amrex::Real  theta_air,
amrex::Real  p_hse,
amrex::Real  dx_inv,
amrex::Real  rdOcp 
)
noexcept
925 {
926  const amrex::Real theta_wall =
927  wall_temperature_K * std::pow(p_0 / p_hse, rdOcp);
928  return rho * alpha_T * (theta_wall - theta_air) *
929  amrex::Real(2.0) * dx_inv;
930 }

Referenced by evaluate_scalar_flux_in().

Here is the caller graph for this function:

◆ resolved_vapor_flux_in()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_cloud_chamber_wall_flux::resolved_vapor_flux_in ( amrex::Real  rho,
amrex::Real  alpha_C,
const erf_wall_thermodynamics::FaceWall &  wall,
amrex::Real  qv_air,
amrex::Real  p_hse,
amrex::Real  dx_inv 
)
noexcept
942 {
943  const amrex::Real qv_wall = wet_wall_qv(wall, p_hse);
944  return rho * alpha_C * (qv_wall - qv_air) *
945  amrex::Real(2.0) * dx_inv;
946 }

Referenced by evaluate_scalar_flux_in().

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

◆ scalar_channel_from_quantity()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE ScalarChannel erf_cloud_chamber_wall_flux::scalar_channel_from_quantity ( int  quantity)
noexcept
144 {
145  if (quantity == RhoTheta_comp) { return ScalarChannel::Heat; }
146  if (quantity == RhoQ1_comp) { return ScalarChannel::Vapor; }
147  if (quantity == RhoQ2_comp) { return ScalarChannel::CloudWater; }
148  return ScalarChannel::None;
149 }
#define RhoTheta_comp
Definition: ERF_IndexDefines.H:62
#define RhoQ2_comp
Definition: ERF_IndexDefines.H:79
#define RhoQ1_comp
Definition: ERF_IndexDefines.H:78

◆ scalar_channel_mask()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE unsigned char erf_cloud_chamber_wall_flux::scalar_channel_mask ( ScalarChannel  channel)
noexcept
195 {
196  switch (channel) {
197  case ScalarChannel::Heat:
198  return OwnHeat;
199  case ScalarChannel::Vapor:
200  return OwnVapor;
201  case ScalarChannel::CloudWater:
202  return OwnCloudWater;
203  case ScalarChannel::None:
204  return OwnNone;
205  }
206 
207  return OwnNone;
208 }

Referenced by evaluate_scalar_flux_in(), and owns().

Here is the caller graph for this function:

◆ scalar_flux_in()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_cloud_chamber_wall_flux::scalar_flux_in ( const WallFlux &  flux,
ScalarChannel  channel 
)
noexcept
1131 {
1132  switch (channel) {
1133  case ScalarChannel::Heat:
1134  return flux.rhoTheta_in;
1135  case ScalarChannel::Vapor:
1136  return flux.rhoQv_in;
1137  case ScalarChannel::CloudWater:
1138  return flux.rhoQc_in;
1139  case ScalarChannel::None:
1140  return amrex::Real(0.0);
1141  }
1142 
1143  return amrex::Real(0.0);
1144 }

Referenced by evaluate_face_scalar_flux_in().

Here is the caller graph for this function:

◆ scalar_flux_replacement()

template<int DIR, bool HIGH>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE ScalarFluxReplacement erf_cloud_chamber_wall_flux::scalar_flux_replacement ( amrex::Real  old_flux,
amrex::Real  inward_flux,
amrex::Real  dx_inv 
)
noexcept
1178 {
1179  const amrex::Real new_flux =
1180  to_coordinate_flux<DIR,HIGH>(inward_flux);
1181  const amrex::Real correction =
1182  (new_flux - old_flux) * dx_inv;
1183  return {
1184  new_flux,
1185  HIGH ? -correction : correction
1186  };
1187 }

◆ tangential_magnitude()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_cloud_chamber_wall_flux::tangential_magnitude ( const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &  u_t)
noexcept
827 {
828  return std::sqrt(u_t[0]*u_t[0] + u_t[1]*u_t[1] + u_t[2]*u_t[2]);
829 }

Referenced by tangential_speed(), and erf_cloud_chamber_wall_stress::wall_traction_at_cell().

Here is the caller graph for this function:

◆ tangential_speed()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_cloud_chamber_wall_flux::tangential_speed ( int  dir,
int  i,
int  j,
int  k,
const amrex::Array4< const amrex::Real > &  u,
const amrex::Array4< const amrex::Real > &  v,
const amrex::Array4< const amrex::Real > &  w,
const erf_wall_thermodynamics::FaceWall &  wall 
)
noexcept
840 {
841  return tangential_magnitude(
842  relative_tangential_velocity_cell_centered(dir, i, j, k, u, v, w, wall));
843 }
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real tangential_magnitude(const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &u_t) noexcept
Definition: ERF_CloudChamberWallFlux.H:825
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > relative_tangential_velocity_cell_centered(int dir, int i, int j, int k, const amrex::Array4< const amrex::Real > &u, const amrex::Array4< const amrex::Real > &v, const amrex::Array4< const amrex::Real > &w, const erf_wall_thermodynamics::FaceWall &wall) noexcept
Definition: ERF_CloudChamberWallFlux.H:804
Here is the call graph for this function:

◆ tangential_speed_cell_centered()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_cloud_chamber_wall_flux::tangential_speed_cell_centered ( int  dir,
int  i,
int  j,
int  k,
const amrex::Array4< const amrex::Real > &  velocity,
const erf_wall_thermodynamics::FaceWall &  wall 
)
noexcept
852 {
853  const amrex::Real uc = velocity(i,j,k,0) - wall.wall_velocity[0];
854  const amrex::Real vc = velocity(i,j,k,1) - wall.wall_velocity[1];
855  const amrex::Real wc = velocity(i,j,k,2) - wall.wall_velocity[2];
856  const amrex::Real normal = (dir == 0) ? uc : ((dir == 1) ? vc : wc);
857  const amrex::Real t0 = uc - ((dir == 0) ? normal : amrex::Real(0.0));
858  const amrex::Real t1 = vc - ((dir == 1) ? normal : amrex::Real(0.0));
859  const amrex::Real t2 = wc - ((dir == 2) ? normal : amrex::Real(0.0));
860  return std::sqrt(t0*t0 + t1*t1 + t2*t2);
861 }
real(c_double), parameter t0
Definition: ERF_module_model_constants.F90:39

Referenced by wall_rate_for_cell().

Here is the caller graph for this function:

◆ to_coordinate_flux()

template<int DIR, bool HIGH>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_cloud_chamber_wall_flux::to_coordinate_flux ( amrex::Real  inward)
noexcept
737 {
738  // Wall evaluators are inward-positive. ERF stores coordinate-positive
739  // face fluxes, so this is the one low/high sign adapter for every scalar.
740  amrex::ignore_unused(DIR);
741  return HIGH ? -inward : inward;
742 }

◆ traction_from_local_inward()

template<int DIR, bool HIGH>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> erf_cloud_chamber_wall_flux::traction_from_local_inward ( amrex::Real  normal_in,
amrex::Real  tangent_a,
amrex::Real  tangent_b 
)
noexcept
751 {
752  // Physical traction result/orientation support. The stress adapter maps
753  // this pure result into ERF tau_ij arrays for active wall models.
754  amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> result{};
755  result[DIR] = to_coordinate_flux<DIR,HIGH>(normal_in);
756  if constexpr (DIR == 0) {
757  result[1] = tangent_a;
758  result[2] = tangent_b;
759  } else if constexpr (DIR == 1) {
760  result[0] = tangent_a;
761  result[2] = tangent_b;
762  } else {
763  result[0] = tangent_a;
764  result[1] = tangent_b;
765  }
766  return result;
767 }

◆ wall_dt_from_max_rate()

AMREX_FORCE_INLINE amrex::Real erf_cloud_chamber_wall_flux::wall_dt_from_max_rate ( amrex::Real  max_rate,
amrex::Real  wall_cfl = amrex::Real(0.5) 
)
noexcept
1321 {
1322  return max_rate > amrex::Real(0.0) ?
1323  wall_cfl / max_rate : amrex::Real(1.0e30);
1324 }

Referenced by ERF::estTimeStep().

Here is the caller graph for this function:

◆ wall_owns_scalar_channel()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool erf_cloud_chamber_wall_flux::wall_owns_scalar_channel ( const erf_wall_thermodynamics::FaceWall &  wall,
ScalarChannel  channel 
)
noexcept
175 {
176  using namespace erf_wall_thermodynamics;
177 
178  switch (channel) {
179  case ScalarChannel::Heat:
181  case ScalarChannel::Vapor:
182  case ScalarChannel::CloudWater:
184  case ScalarChannel::None:
185  return false;
186  }
187 
188  return false;
189 }
MoistureMode moisture
Definition: ERF_WallThermodynamics.H:88

Referenced by evaluate_scalar_flux_in().

Here is the caller graph for this function:

◆ wall_rate_for_cell()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_cloud_chamber_wall_flux::wall_rate_for_cell ( int  i,
int  j,
int  k,
const amrex::Box &  domain,
const erf_wall_thermodynamics::Boundary &  walls,
const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &  dx_inv,
const amrex::Array4< const amrex::Real > &  velocity 
)
noexcept
872 {
873  using namespace erf_wall_thermodynamics;
874  const amrex::IntVect cell(i,j,k);
875  amrex::GpuArray<DirectionalMomentumRate, AMREX_SPACEDIM> momentum{};
876  CellScalarWallRate heat{}, vapor{};
877  for (int dir = 0; dir < AMREX_SPACEDIM; ++dir) {
878  for (int side = 0; side < 2; ++side) {
879  if (cell[dir] != (side ? domain.bigEnd(dir) : domain.smallEnd(dir))) { continue; }
880  const auto& wall = walls[2*dir+side];
881  const auto inv = dx_inv[dir];
882  amrex::Real U_t = 0;
883  FaceRuntimeCoefficients runtime{};
885  U_t = tangential_speed_cell_centered(dir, i, j, k, velocity, wall);
886  if (wall_uses_most(wall)) {
887  runtime = most_wall_coefficients(
888  wall, velocity(i,j,k,3), velocity(i,j,k,4), velocity(i,j,k,5),
889  velocity(i,j,k,6), U_t, amrex::Real(0.5) / inv, dir == 2 ? 1-2*side : 0);
890  AMREX_ALWAYS_ASSERT(runtime.valid != 0);
891  }
892  }
893  if (requires_tangential_momentum(wall)) {
894  momentum[dir].modeled += momentum_rate_for_face(wall, U_t, inv, runtime);
895  momentum[dir].combined |= wall.momentum.molecular_speed > 0;
896  } else {
897  momentum[dir].resolved += wall.momentum.resolved_row_rate;
898  }
899  if (wall.heat_is_conductive()) {
900  heat.add(wall.heat, U_t, inv, wall.momentum.z0_m, runtime.C_H);
901  }
902  if (wall.vapor_is_wet()) {
903  vapor.add(wall.vapor, U_t, inv, wall.momentum.z0_m, runtime.C_E);
904  }
905  }
906  }
907  auto rate = amrex::max(heat.max_rate(), vapor.max_rate());
908  for (int component = 0; component < AMREX_SPACEDIM; ++component) {
909  rate = amrex::max(rate, momentum_row_sum_rate(component, momentum));
910  }
911  return rate;
912 }
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real tangential_speed_cell_centered(int dir, int i, int j, int k, const amrex::Array4< const amrex::Real > &velocity, const erf_wall_thermodynamics::FaceWall &wall) noexcept
Definition: ERF_CloudChamberWallFlux.H:848
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real momentum_row_sum_rate(int component, const amrex::GpuArray< DirectionalMomentumRate, AMREX_SPACEDIM > &rates) noexcept
Definition: ERF_CloudChamberWallFlux.H:602
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool wall_rate_requires_tangential_speed(const erf_wall_thermodynamics::FaceWall &wall) noexcept
Definition: ERF_CloudChamberWallFlux.H:682
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real momentum_rate_for_face(const erf_wall_thermodynamics::FaceWall &wall, amrex::Real U_t, amrex::Real dx_inv, const FaceRuntimeCoefficients &runtime=FaceRuntimeCoefficients{}) noexcept
Definition: ERF_CloudChamberWallFlux.H:623
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool requires_tangential_momentum(const erf_wall_thermodynamics::FaceWall &wall) noexcept
Definition: ERF_CloudChamberWallFlux.H:673
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool wall_uses_most(const erf_wall_thermodynamics::FaceWall &wall) noexcept
Definition: ERF_CloudChamberWallFlux.H:135

Referenced by ERF::estTimeStep().

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

◆ wall_rate_requires_tangential_speed()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool erf_cloud_chamber_wall_flux::wall_rate_requires_tangential_speed ( const erf_wall_thermodynamics::FaceWall &  wall)
noexcept
684 {
685  return wall.has_wall_rate_channel();
686 }
constexpr AMREX_GPU_HOST_DEVICE bool has_wall_rate_channel() const noexcept
Definition: ERF_WallThermodynamics.H:129

Referenced by wall_rate_for_cell().

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

◆ wall_uses_most()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool erf_cloud_chamber_wall_flux::wall_uses_most ( const erf_wall_thermodynamics::FaceWall &  wall)
noexcept
136 {
137  return wall.momentum_uses_most() || wall.heat_uses_most() || wall.vapor_uses_most();
138 }
constexpr AMREX_GPU_HOST_DEVICE bool heat_uses_most() const noexcept
Definition: ERF_WallThermodynamics.H:108
constexpr AMREX_GPU_HOST_DEVICE bool vapor_uses_most() const noexcept
Definition: ERF_WallThermodynamics.H:114

Referenced by wall_rate_for_cell().

Here is the caller graph for this function:

◆ wall_uses_most_heat()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool erf_cloud_chamber_wall_flux::wall_uses_most_heat ( const erf_wall_thermodynamics::FaceWall &  wall)
noexcept
120 {
121  return wall.heat_uses_most();
122 }

Referenced by most_wall_coefficients().

Here is the caller graph for this function:

◆ wall_uses_most_vapor()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool erf_cloud_chamber_wall_flux::wall_uses_most_vapor ( const erf_wall_thermodynamics::FaceWall &  wall)
noexcept
128 {
129  return wall.vapor_uses_most();
130 }

Referenced by most_wall_coefficients().

Here is the caller graph for this function:

◆ wet_wall_qv()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_cloud_chamber_wall_flux::wet_wall_qv ( const erf_wall_thermodynamics::FaceWall &  wall,
amrex::Real  p_hse 
)
noexcept
463 {
464  // Apply RH to vapor pressure (hPa) before the capped mixing-ratio conversion.
465  // At RH=1 this is the same calculation as erf_qsatw.
466  const amrex::Real e = wall.wetness * erf_esatw(wall.thermal.temperature_K);
467  return erf_qsat_from_esat(e, p_hse * amrex::Real(0.01));
468 }
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_qsat_from_esat(amrex::Real esat, amrex::Real p)
Definition: ERF_MicrophysicsUtils.H:234
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_esatw(amrex::Real t, bool use_empirical=false)
Definition: ERF_MicrophysicsUtils.H:160
amrex::Real wetness
Definition: ERF_WallThermodynamics.H:89

Referenced by bulk_vapor_flux_in(), most_wall_coefficients(), and resolved_vapor_flux_in().

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