ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_CloudChamberWallFlux.H
Go to the documentation of this file.
1 #ifndef ERF_CLOUD_CHAMBER_WALL_FLUX_H_
2 #define ERF_CLOUD_CHAMBER_WALL_FLUX_H_
3 
4 #include <AMReX_Array4.H>
5 #include <AMReX_Box.H>
6 #include <AMReX_GpuContainers.H>
7 #include <AMReX_Math.H>
8 #include <AMReX_MultiFab.H>
9 
10 #include "ERF_Constants.H"
11 #include "ERF_DataStruct.H"
12 #include "ERF_EOS.H"
13 #include "ERF_IndexDefines.H"
14 #include "ERF_MicrophysicsUtils.H"
17 
18 #include <cmath>
19 #include <cstdlib>
20 #include <limits>
21 #include <type_traits>
22 
24 
25 enum OwnedChannel : unsigned char {
26  OwnNone = 0,
27  OwnMomentum = 1 << 0,
28  OwnHeat = 1 << 1,
29  OwnVapor = 1 << 2,
30  OwnCloudWater = 1 << 3
31 };
32 
33 struct WallFlux {
34  amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> traction_on_fluid{};
35  amrex::Real rhoTheta_in = amrex::Real(0.0);
36  amrex::Real rhoQv_in = amrex::Real(0.0);
37  amrex::Real rhoQc_in = amrex::Real(0.0);
38  unsigned char owned_channels = OwnNone;
39 };
40 
42  amrex::Real C_D = amrex::Real(0.0);
43  amrex::Real C_H = amrex::Real(0.0);
44  amrex::Real C_E = amrex::Real(0.0);
45  amrex::Real u_star = amrex::Real(0.0);
46  amrex::Real zeta = amrex::Real(0.0);
47  unsigned char valid = 0;
48 };
49 
51  amrex::Real zeta = amrex::Real(0.0);
52  int iterations = 0;
53 };
54 
55 enum class ScalarChannel : unsigned char {
56  None,
57  Heat,
58  Vapor,
60 };
61 
63  amrex::Real rho = amrex::Real(0.0);
64  amrex::Real scalar_air = amrex::Real(0.0);
65  amrex::Real p_hse = amrex::Real(0.0);
66  amrex::Real U_t = amrex::Real(0.0);
67  amrex::Real alpha_T = amrex::Real(0.0);
68  amrex::Real alpha_C = amrex::Real(0.0);
69  amrex::Real dx_inv = amrex::Real(0.0);
70  amrex::Real rdOcp = amrex::Real(0.0);
71  // Explicit distance of this scalar sample from the physical wall.
72  amrex::Real wall_distance = amrex::Real(0.0);
73  amrex::Real theta_air = amrex::Real(0.0);
74  amrex::Real qv_air = amrex::Real(0.0);
75  int gravity_sign = 0;
76 };
77 
79  amrex::Real log_m = amrex::Real(0.0);
80  amrex::Real C_D = amrex::Real(0.0);
81  amrex::Real u_star = amrex::Real(0.0);
82 };
83 
85  amrex::Real rho = amrex::Real(0.0);
86  amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> u_t{};
87  amrex::Real U_t = amrex::Real(0.0);
88  amrex::Real wall_distance = amrex::Real(0.0);
89  amrex::Real theta_air = amrex::Real(0.0);
90  amrex::Real qv_air = amrex::Real(0.0);
91  amrex::Real p_hse = amrex::Real(0.0);
92  amrex::Real rdOcp = amrex::Real(0.0);
93  int gravity_sign = 0;
94 };
95 
97  amrex::Real coordinate_flux = amrex::Real(0.0);
98  amrex::Real rhs_delta = amrex::Real(0.0);
99 };
100 
101 static_assert(std::is_trivially_copyable_v<WallFlux>);
102 static_assert(std::is_standard_layout_v<WallFlux>);
103 static_assert(std::is_trivially_copyable_v<FaceRuntimeCoefficients>);
104 static_assert(std::is_standard_layout_v<FaceRuntimeCoefficients>);
105 static_assert(std::is_trivially_copyable_v<MostStabilityResult>);
106 static_assert(std::is_standard_layout_v<MostStabilityResult>);
107 static_assert(std::is_trivially_copyable_v<ScalarWallSample>);
108 static_assert(std::is_standard_layout_v<ScalarWallSample>);
109 static_assert(std::is_trivially_copyable_v<NeutralLogMomentumState>);
110 static_assert(std::is_standard_layout_v<NeutralLogMomentumState>);
111 static_assert(std::is_trivially_copyable_v<MomentumWallSample>);
112 static_assert(std::is_standard_layout_v<MomentumWallSample>);
113 static_assert(std::is_trivially_copyable_v<ScalarFluxReplacement>);
114 static_assert(std::is_standard_layout_v<ScalarFluxReplacement>);
115 
116 AMREX_GPU_HOST_DEVICE
117 AMREX_FORCE_INLINE
118 bool
120 {
121  return wall.heat_uses_most();
122 }
123 
124 AMREX_GPU_HOST_DEVICE
125 AMREX_FORCE_INLINE
126 bool
128 {
129  return wall.vapor_uses_most();
130 }
131 
132 AMREX_GPU_HOST_DEVICE
133 AMREX_FORCE_INLINE
134 bool
136 {
137  return wall.momentum_uses_most() || wall.heat_uses_most() || wall.vapor_uses_most();
138 }
139 
140 AMREX_GPU_HOST_DEVICE
141 AMREX_FORCE_INLINE
143 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 }
150 
151 AMREX_GPU_HOST_DEVICE
152 AMREX_FORCE_INLINE
153 int
155 {
156  switch (channel) {
157  case ScalarChannel::Heat:
158  return PrimTheta_comp;
160  return PrimQ1_comp;
162  return PrimQ2_comp;
163  case ScalarChannel::None:
164  break;
165  }
166  return -1;
167 }
168 
169 AMREX_GPU_HOST_DEVICE
170 AMREX_FORCE_INLINE
171 bool
174  ScalarChannel channel) noexcept
175 {
176  using namespace erf_wall_thermodynamics;
177 
178  switch (channel) {
179  case ScalarChannel::Heat:
180  return wall.thermal.mode != ThermalMode::LegacyNumerical;
183  return wall.moisture != MoistureMode::LegacyNumerical;
184  case ScalarChannel::None:
185  return false;
186  }
187 
188  return false;
189 }
190 
191 AMREX_GPU_HOST_DEVICE
192 AMREX_FORCE_INLINE
193 unsigned char
195 {
196  switch (channel) {
197  case ScalarChannel::Heat:
198  return OwnHeat;
200  return OwnVapor;
202  return OwnCloudWater;
203  case ScalarChannel::None:
204  return OwnNone;
205  }
206 
207  return OwnNone;
208 }
209 
210 AMREX_GPU_HOST_DEVICE
211 AMREX_FORCE_INLINE
212 bool
213 owns (const WallFlux& flux, ScalarChannel channel) noexcept
214 {
215  return (flux.owned_channels & scalar_channel_mask(channel)) != 0;
216 }
217 
218 AMREX_GPU_HOST_DEVICE
219 AMREX_FORCE_INLINE
220 NeutralLogMomentumState
221 neutral_log_momentum_state (amrex::Real U_t,
222  amrex::Real wall_distance,
223  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 }
229 
230 AMREX_GPU_HOST_DEVICE
231 AMREX_FORCE_INLINE
232 amrex::Real
233 neutral_log_scalar_coefficient (amrex::Real wall_distance,
234  amrex::Real z0_m,
235  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 }
241 
242 AMREX_GPU_HOST_DEVICE
243 AMREX_FORCE_INLINE
244 void
245 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 }
258 
259 AMREX_GPU_HOST_DEVICE
260 AMREX_FORCE_INLINE
261 MostStabilityResult
263  amrex::Real D_m,
264  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 }
458 
459 AMREX_GPU_HOST_DEVICE
460 AMREX_FORCE_INLINE
461 amrex::Real
462 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 }
469 
470 AMREX_GPU_HOST_DEVICE
471 AMREX_FORCE_INLINE
472 FaceRuntimeCoefficients
475  amrex::Real theta_air,
476  amrex::Real qv_air,
477  amrex::Real p_hse,
478  amrex::Real rdOcp,
479  amrex::Real U_t,
480  amrex::Real wall_distance,
481  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 }
556 
557 AMREX_GPU_HOST_DEVICE
558 AMREX_FORCE_INLINE
559 amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>
561  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 }
569 
570 AMREX_GPU_HOST_DEVICE
571 AMREX_FORCE_INLINE
572 amrex::Real
573 neutral_scalar_rate (amrex::Real coefficient,
574  amrex::Real U_t,
575  amrex::Real dx_inv) noexcept
576 {
577  return coefficient * U_t * dx_inv;
578 }
579 
580 
581 AMREX_GPU_HOST_DEVICE
582 AMREX_FORCE_INLINE
583 amrex::Real
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 }
591 
592 // Totals for incident faces with the same normal (both sides for a one-cell direction).
594  amrex::Real modeled = 0;
595  amrex::Real resolved = 0;
596  bool combined = false;
597 };
598 
599 AMREX_GPU_HOST_DEVICE
600 AMREX_FORCE_INLINE
601 amrex::Real
602 momentum_row_sum_rate (int component, const amrex::GpuArray<DirectionalMomentumRate,
603  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 }
619 
620 AMREX_GPU_HOST_DEVICE
621 AMREX_FORCE_INLINE
622 amrex::Real
625  amrex::Real U_t,
626  amrex::Real dx_inv,
627  const FaceRuntimeCoefficients& runtime = FaceRuntimeCoefficients{}) 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 !=
633  MomentumModel::ResolvedNoSlip) {
634  if (wall.momentum.model == MomentumModel::NeutralRoughnessLog) {
636  U_t, wall_distance, wall.momentum.z0_m).C_D;
637  } else if (wall.momentum.model == MomentumModel::BulkAero) {
638  if (wall.momentum.provider == CoefficientProvider::MOST) {
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 }
649 
650 AMREX_GPU_HOST_DEVICE
651 AMREX_FORCE_INLINE
652 bool
655  ScalarChannel channel) noexcept
656 {
657  switch (channel) {
658  case ScalarChannel::Heat:
659  return wall.heat_requires_speed();
661  return wall.vapor_requires_speed();
663  case ScalarChannel::None:
664  return false;
665  }
666 
667  return false;
668 }
669 
670 AMREX_GPU_HOST_DEVICE
671 AMREX_FORCE_INLINE
672 bool
674  const erf_wall_thermodynamics::FaceWall& wall) noexcept
675 {
676  return wall.momentum_requires_speed();
677 }
678 
679 AMREX_GPU_HOST_DEVICE
680 AMREX_FORCE_INLINE
681 bool
683  const erf_wall_thermodynamics::FaceWall& wall) noexcept
684 {
685  return wall.has_wall_rate_channel();
686 }
687 
688 // One scalar row at one cell. A resolved wall contributes 2*alpha/dx^2 to
689 // the row, but is not itself a wall-law timestep constraint. Only an active
690 // combined bulk face selects the sum in place of the legacy face maximum.
692  amrex::Real max_wall_law = 0;
693  amrex::Real sum = 0;
694  bool combined = false;
695 
696  AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
698  amrex::Real U_t, amrex::Real dx_inv, amrex::Real z0_m,
699  amrex::Real most_coefficient) noexcept
700  {
701  using namespace erf_wall_thermodynamics;
702  amrex::Real rate = 0;
703  switch (scalar.model) {
704  case ScalarModel::ResolvedMolecular:
705  sum += scalar.resolved_speed * dx_inv;
706  return;
707  case ScalarModel::BulkAero: {
708  const auto C = scalar.provider == CoefficientProvider::MOST ?
709  most_coefficient : scalar.coefficient;
710  rate = neutral_scalar_rate(C, U_t, dx_inv) + scalar.molecular_speed * dx_inv;
711  // Setup requires positive diffusivity for bulk_aero_plus_molecular;
712  // plain bulk has zero molecular speed.
713  combined |= scalar.molecular_speed > 0;
714  break;
715  }
716  case ScalarModel::NeutralRoughnessLog:
718  amrex::Real(0.5) / dx_inv, z0_m, scalar.z0), U_t, dx_inv);
719  break;
720  }
721  sum += rate;
722  max_wall_law = amrex::max(max_wall_law, rate);
723  }
724 
725  AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
726  amrex::Real max_rate () const noexcept
727  {
728  return combined ? sum : max_wall_law;
729  }
730 };
731 
732 template <int DIR, bool HIGH>
733 AMREX_GPU_HOST_DEVICE
734 AMREX_FORCE_INLINE
735 amrex::Real
736 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 }
743 
744 template <int DIR, bool HIGH>
745 AMREX_GPU_HOST_DEVICE
746 AMREX_FORCE_INLINE
747 amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>
748 traction_from_local_inward (amrex::Real normal_in,
749  amrex::Real tangent_a,
750  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 }
768 
769 AMREX_GPU_HOST_DEVICE
770 AMREX_FORCE_INLINE
771 amrex::Real
772 bulk_theta_flux_in (amrex::Real rho,
773  amrex::Real C_H,
774  amrex::Real U_t,
775  amrex::Real wall_temperature_K,
776  amrex::Real theta_air,
777  amrex::Real p_hse,
778  amrex::Real rdOcp,
779  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 }
785 
786 AMREX_GPU_HOST_DEVICE
787 AMREX_FORCE_INLINE
788 amrex::Real
789 bulk_vapor_flux_in (amrex::Real rho,
790  amrex::Real C_E,
791  amrex::Real U_t,
793  amrex::Real qv_air,
794  amrex::Real p_hse,
795  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 }
800 
801 AMREX_GPU_HOST_DEVICE
802 AMREX_FORCE_INLINE
803 amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>
805  int dir, int i, int j, int k,
806  const amrex::Array4<const amrex::Real>& u,
807  const amrex::Array4<const amrex::Real>& v,
808  const amrex::Array4<const amrex::Real>& w,
809  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 }
821 
822 AMREX_GPU_HOST_DEVICE
823 AMREX_FORCE_INLINE
824 amrex::Real
826  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 }
830 
831 AMREX_GPU_HOST_DEVICE
832 AMREX_FORCE_INLINE
833 amrex::Real
835  int i, int j, int k,
836  const amrex::Array4<const amrex::Real>& u,
837  const amrex::Array4<const amrex::Real>& v,
838  const amrex::Array4<const amrex::Real>& w,
839  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 }
844 
845 AMREX_GPU_HOST_DEVICE
846 AMREX_FORCE_INLINE
847 amrex::Real
849  int i, int j, int k,
850  const amrex::Array4<const amrex::Real>& velocity,
851  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 }
862 
863 // Use both incident faces of a one-cell direction. For a MOST face freeze
864 // its current coefficients once for all channels (not a nonlinear Jacobian).
865 AMREX_GPU_HOST_DEVICE
866 AMREX_FORCE_INLINE
867 amrex::Real
868 wall_rate_for_cell (int i, int j, int k, const amrex::Box& domain,
870  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& dx_inv,
871  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 }
913 
914 AMREX_GPU_HOST_DEVICE
915 AMREX_FORCE_INLINE
916 amrex::Real
918  amrex::Real rho,
919  amrex::Real alpha_T,
920  amrex::Real wall_temperature_K,
921  amrex::Real theta_air,
922  amrex::Real p_hse,
923  amrex::Real dx_inv,
924  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 }
931 
932 AMREX_GPU_HOST_DEVICE
933 AMREX_FORCE_INLINE
934 amrex::Real
936  amrex::Real rho,
937  amrex::Real alpha_C,
939  amrex::Real qv_air,
940  amrex::Real p_hse,
941  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 }
947 
948 AMREX_GPU_HOST_DEVICE
949 AMREX_FORCE_INLINE
950 WallFlux
953  const MomentumWallSample& sample) noexcept
954 {
955  using namespace erf_wall_thermodynamics;
956 
957  WallFlux result{};
958  switch (wall.momentum.model) {
959  case MomentumModel::ResolvedNoSlip:
960  return result;
961  case MomentumModel::NeutralRoughnessLog: {
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  }
969  case MomentumModel::BulkAero: {
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;
973  if (wall.momentum.provider == CoefficientProvider::MOST) {
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 }
990 
991 AMREX_GPU_HOST_DEVICE
992 AMREX_FORCE_INLINE
993 WallFlux
996  ScalarChannel channel,
997  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) &&
1013  wall.heat.model != ScalarModel::ResolvedMolecular && wall.heat.molecular_speed == 0) {
1014  return result;
1015  }
1016  switch (wall.heat.model) {
1017  case ScalarModel::ResolvedMolecular:
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  }
1048  case ScalarModel::NeutralRoughnessLog:
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) &&
1068  wall.vapor.model != ScalarModel::ResolvedMolecular && wall.vapor.molecular_speed == 0) {
1069  return result;
1070  }
1071  switch (wall.vapor.model) {
1072  case ScalarModel::ResolvedMolecular:
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;
1084  if (wall.vapor.provider == CoefficientProvider::MOST) {
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  }
1101  case ScalarModel::NeutralRoughnessLog:
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 
1118  return result;
1119 
1120  case ScalarChannel::None:
1121  return result;
1122  }
1123 
1124  return result;
1125 }
1126 
1127 AMREX_GPU_HOST_DEVICE
1128 AMREX_FORCE_INLINE
1129 amrex::Real
1130 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;
1138  return flux.rhoQc_in;
1139  case ScalarChannel::None:
1140  return amrex::Real(0.0);
1141  }
1142 
1143  return amrex::Real(0.0);
1144 }
1145 
1146 // Each panel sees the same adjacent air and pressure. In particular evaluate
1147 // wet-wall saturation per panel, not at an area-averaged temperature.
1148 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
1150  const erf_wall_thermodynamics::FaceWall& wall, ScalarChannel channel,
1152  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 }
1169 
1170 template <int DIR, bool HIGH>
1171 AMREX_GPU_HOST_DEVICE
1172 AMREX_FORCE_INLINE
1173 ScalarFluxReplacement
1175  amrex::Real old_flux,
1176  amrex::Real inward_flux,
1177  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 }
1188 
1189 template <int DIR, bool HIGH>
1190 AMREX_FORCE_INLINE
1191 void apply_face (const amrex::Box& bx,
1192  const amrex::Box& domain,
1193  const int quantity,
1194  const int flux_comp,
1195  const amrex::Array4<const amrex::Real>& state,
1196  const amrex::Array4<const amrex::Real>& prim,
1197  const amrex::Array4<const amrex::Real>& base_state,
1198  const amrex::Array4<const amrex::Real>& u,
1199  const amrex::Array4<const amrex::Real>& v,
1200  const amrex::Array4<const amrex::Real>& w,
1201  const amrex::Array4<amrex::Real>& rhs,
1202  const amrex::Array4<amrex::Real>& xflux,
1203  const amrex::Array4<amrex::Real>& yflux,
1204  const amrex::Array4<amrex::Real>& zflux,
1205  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& dx_inv,
1206  const erf_wall_thermodynamics::Boundary& walls,
1207  const amrex::Real alpha_T,
1208  const amrex::Real alpha_C,
1209  const amrex::Real rdOcp,
1210  const bool cloudy,
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 }
1277 
1278 inline void apply (const amrex::Box& bx, const amrex::Box& domain,
1279  const int quantity, const int flux_comp,
1280  const amrex::Array4<const amrex::Real>& state,
1281  const amrex::Array4<const amrex::Real>& prim,
1282  const amrex::Array4<const amrex::Real>& base_state,
1283  const amrex::Array4<const amrex::Real>& u,
1284  const amrex::Array4<const amrex::Real>& v,
1285  const amrex::Array4<const amrex::Real>& w,
1286  const amrex::Array4<amrex::Real>& rhs,
1287  const amrex::Array4<amrex::Real>& xflux,
1288  const amrex::Array4<amrex::Real>& yflux,
1289  const amrex::Array4<amrex::Real>& zflux,
1290  const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& dx_inv,
1291  const erf_wall_thermodynamics::Boundary& walls,
1292  const amrex::Real alpha_T, const amrex::Real alpha_C,
1293  const amrex::Real rdOcp,
1294  const bool cloudy = false,
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 }
1304 
1306  const erf_wall_thermodynamics::Boundary& walls) noexcept
1307 {
1308  for (const auto& wall : walls) {
1311  return true;
1312  }
1313  }
1314  return false;
1315 }
1316 
1317 AMREX_FORCE_INLINE
1318 amrex::Real
1319 wall_dt_from_max_rate (amrex::Real max_rate,
1320  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 }
1325 
1326 } // namespace erf_cloud_chamber_wall_flux
1327 
1328 #endif
constexpr amrex::Real epsv
Definition: ERF_Constants.H:56
constexpr amrex::Real KAPPA
Definition: ERF_Constants.H:71
constexpr amrex::Real p_0
Definition: ERF_Constants.H:69
constexpr amrex::Real CONST_GRAV
Definition: ERF_Constants.H:72
#define PrimQ1_comp
Definition: ERF_IndexDefines.H:94
#define PrimQ2_comp
Definition: ERF_IndexDefines.H:95
#define Rho_comp
Definition: ERF_IndexDefines.H:61
#define RhoTheta_comp
Definition: ERF_IndexDefines.H:62
#define RhoQ2_comp
Definition: ERF_IndexDefines.H:79
#define PrimTheta_comp
Definition: ERF_IndexDefines.H:91
#define RhoQ1_comp
Definition: ERF_IndexDefines.H:78
const Real rdOcp
Definition: ERF_InitCustomPert_ABL.H:128
AMREX_ALWAYS_ASSERT(bx.length()[2]==khi+1)
std::string message
Definition: ERF_InputPreflight.cpp:25
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
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
@ rho
Definition: ERF_Kessler.H:25
Definition: ERF_ConsoleIO.cpp:17
Definition: ERF_CloudChamberWallFlux.H:23
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool owns(const WallFlux &flux, ScalarChannel channel) noexcept
Definition: ERF_CloudChamberWallFlux.H:213
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::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 WallFlux evaluate_momentum_traction(const erf_wall_thermodynamics::FaceWall &wall, const MomentumWallSample &sample) noexcept
Definition: ERF_CloudChamberWallFlux.H:951
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
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 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 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
bool has_velocity_dependent_scalar_wall(const erf_wall_thermodynamics::Boundary &walls) noexcept
Definition: ERF_CloudChamberWallFlux.H:1305
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 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 NeutralLogMomentumState neutral_log_momentum_state(amrex::Real U_t, amrex::Real wall_distance, amrex::Real z0_m) noexcept
Definition: ERF_CloudChamberWallFlux.H:221
AMREX_FORCE_INLINE amrex::Real wall_dt_from_max_rate(amrex::Real max_rate, amrex::Real wall_cfl=amrex::Real(0.5)) noexcept
Definition: ERF_CloudChamberWallFlux.H:1319
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void most_stability_require(bool condition, const char *message) noexcept
Definition: ERF_CloudChamberWallFlux.H:245
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 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::GpuArray< amrex::Real, AMREX_SPACEDIM > traction_from_local_inward(amrex::Real normal_in, amrex::Real tangent_a, amrex::Real tangent_b) noexcept
Definition: ERF_CloudChamberWallFlux.H:748
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real to_coordinate_flux(amrex::Real inward) noexcept
Definition: ERF_CloudChamberWallFlux.H:736
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
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 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
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 ScalarChannel scalar_channel_from_quantity(int quantity) noexcept
Definition: ERF_CloudChamberWallFlux.H:143
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real scalar_flux_in(const WallFlux &flux, ScalarChannel channel) noexcept
Definition: ERF_CloudChamberWallFlux.H:1130
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE unsigned char scalar_channel_mask(ScalarChannel channel) noexcept
Definition: ERF_CloudChamberWallFlux.H:194
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={})
Definition: ERF_CloudChamberWallFlux.H:1278
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 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
Definition: ERF_CloudChamberWallFlux.H:868
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 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 bool wall_uses_most_vapor(const erf_wall_thermodynamics::FaceWall &wall) noexcept
Definition: ERF_CloudChamberWallFlux.H:127
OwnedChannel
Definition: ERF_CloudChamberWallFlux.H:25
@ 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
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real neutral_scalar_rate(amrex::Real coefficient, amrex::Real U_t, amrex::Real dx_inv) noexcept
Definition: ERF_CloudChamberWallFlux.H:573
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={})
Definition: ERF_CloudChamberWallFlux.H:1191
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 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
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 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
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE ScalarFluxReplacement scalar_flux_replacement(amrex::Real old_flux, amrex::Real inward_flux, amrex::Real dx_inv) noexcept
Definition: ERF_CloudChamberWallFlux.H:1174
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real momentum_infinity_row_sum_factor() noexcept
Definition: ERF_CloudChamberWallFlux.H:584
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool wall_uses_most(const erf_wall_thermodynamics::FaceWall &wall) noexcept
Definition: ERF_CloudChamberWallFlux.H:135
Definition: ERF_WallThermodynamics.H:10
amrex::GpuArray< TemperatureBandView, 4 > SidewallBandViews
Definition: ERF_WallThermodynamics.H:63
amrex::GpuArray< FaceWall, 2 *AMREX_SPACEDIM > Boundary
Definition: ERF_WallThermodynamics.H:133
real(c_double), parameter t0
Definition: ERF_module_model_constants.F90:39
real(c_double), parameter epsilon
Definition: ERF_module_model_constants.F90:12
Definition: ERF_MOSTStress.H:20
Definition: ERF_CloudChamberWallFlux.H:691
amrex::Real sum
Definition: ERF_CloudChamberWallFlux.H:693
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void add(const erf_wall_thermodynamics::ScalarTransfer &scalar, amrex::Real U_t, amrex::Real dx_inv, amrex::Real z0_m, amrex::Real most_coefficient) noexcept
Definition: ERF_CloudChamberWallFlux.H:697
bool combined
Definition: ERF_CloudChamberWallFlux.H:694
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real max_rate() const noexcept
Definition: ERF_CloudChamberWallFlux.H:726
amrex::Real max_wall_law
Definition: ERF_CloudChamberWallFlux.H:692
Definition: ERF_CloudChamberWallFlux.H:593
amrex::Real resolved
Definition: ERF_CloudChamberWallFlux.H:595
bool combined
Definition: ERF_CloudChamberWallFlux.H:596
amrex::Real modeled
Definition: ERF_CloudChamberWallFlux.H:594
Definition: ERF_CloudChamberWallFlux.H:41
amrex::Real C_E
Definition: ERF_CloudChamberWallFlux.H:44
amrex::Real C_H
Definition: ERF_CloudChamberWallFlux.H:43
unsigned char valid
Definition: ERF_CloudChamberWallFlux.H:47
amrex::Real C_D
Definition: ERF_CloudChamberWallFlux.H:42
amrex::Real zeta
Definition: ERF_CloudChamberWallFlux.H:46
amrex::Real u_star
Definition: ERF_CloudChamberWallFlux.H:45
Definition: ERF_CloudChamberWallFlux.H:84
amrex::Real rho
Definition: ERF_CloudChamberWallFlux.H:85
amrex::Real U_t
Definition: ERF_CloudChamberWallFlux.H:87
int gravity_sign
Definition: ERF_CloudChamberWallFlux.H:93
amrex::Real wall_distance
Definition: ERF_CloudChamberWallFlux.H:88
amrex::Real p_hse
Definition: ERF_CloudChamberWallFlux.H:91
amrex::Real theta_air
Definition: ERF_CloudChamberWallFlux.H:89
amrex::Real rdOcp
Definition: ERF_CloudChamberWallFlux.H:92
amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > u_t
Definition: ERF_CloudChamberWallFlux.H:86
amrex::Real qv_air
Definition: ERF_CloudChamberWallFlux.H:90
Definition: ERF_CloudChamberWallFlux.H:50
int iterations
Definition: ERF_CloudChamberWallFlux.H:52
amrex::Real zeta
Definition: ERF_CloudChamberWallFlux.H:51
Definition: ERF_CloudChamberWallFlux.H:78
amrex::Real C_D
Definition: ERF_CloudChamberWallFlux.H:80
amrex::Real u_star
Definition: ERF_CloudChamberWallFlux.H:81
amrex::Real log_m
Definition: ERF_CloudChamberWallFlux.H:79
Definition: ERF_CloudChamberWallFlux.H:96
amrex::Real coordinate_flux
Definition: ERF_CloudChamberWallFlux.H:97
amrex::Real rhs_delta
Definition: ERF_CloudChamberWallFlux.H:98
Definition: ERF_CloudChamberWallFlux.H:62
amrex::Real rdOcp
Definition: ERF_CloudChamberWallFlux.H:70
int gravity_sign
Definition: ERF_CloudChamberWallFlux.H:75
amrex::Real scalar_air
Definition: ERF_CloudChamberWallFlux.H:64
amrex::Real qv_air
Definition: ERF_CloudChamberWallFlux.H:74
amrex::Real rho
Definition: ERF_CloudChamberWallFlux.H:63
amrex::Real dx_inv
Definition: ERF_CloudChamberWallFlux.H:69
amrex::Real theta_air
Definition: ERF_CloudChamberWallFlux.H:73
amrex::Real wall_distance
Definition: ERF_CloudChamberWallFlux.H:72
amrex::Real alpha_T
Definition: ERF_CloudChamberWallFlux.H:67
amrex::Real p_hse
Definition: ERF_CloudChamberWallFlux.H:65
amrex::Real alpha_C
Definition: ERF_CloudChamberWallFlux.H:68
amrex::Real U_t
Definition: ERF_CloudChamberWallFlux.H:66
Definition: ERF_CloudChamberWallFlux.H:33
amrex::Real rhoTheta_in
Definition: ERF_CloudChamberWallFlux.H:35
amrex::Real rhoQv_in
Definition: ERF_CloudChamberWallFlux.H:36
unsigned char owned_channels
Definition: ERF_CloudChamberWallFlux.H:38
amrex::Real rhoQc_in
Definition: ERF_CloudChamberWallFlux.H:37
amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > traction_on_fluid
Definition: ERF_CloudChamberWallFlux.H:34
Definition: ERF_WallThermodynamics.H:86
constexpr AMREX_GPU_HOST_DEVICE bool heat_is_conductive() const noexcept
Definition: ERF_WallThermodynamics.H:96
amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > wall_velocity
Definition: ERF_WallThermodynamics.H:93
ScalarTransfer vapor
Definition: ERF_WallThermodynamics.H:92
ScalarTransfer heat
Definition: ERF_WallThermodynamics.H:91
constexpr AMREX_GPU_HOST_DEVICE bool has_wall_rate_channel() const noexcept
Definition: ERF_WallThermodynamics.H:129
constexpr AMREX_GPU_HOST_DEVICE bool vapor_is_wet() const noexcept
Definition: ERF_WallThermodynamics.H:99
MomentumTransfer momentum
Definition: ERF_WallThermodynamics.H:90
ThermalBoundary thermal
Definition: ERF_WallThermodynamics.H:87
constexpr AMREX_GPU_HOST_DEVICE bool vapor_requires_speed() const noexcept
Definition: ERF_WallThermodynamics.H:126
constexpr AMREX_GPU_HOST_DEVICE bool momentum_requires_speed() const noexcept
Definition: ERF_WallThermodynamics.H:120
constexpr AMREX_GPU_HOST_DEVICE bool heat_requires_speed() const noexcept
Definition: ERF_WallThermodynamics.H:123
amrex::Real resolved_row_rate
Definition: ERF_WallThermodynamics.H:72
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
Definition: ERF_WallThermodynamics.H:75
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
Definition: ERF_WallThermodynamics.H:57
amrex::Real temperature_K
Definition: ERF_WallThermodynamics.H:46
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