ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_SurfaceLayerStress.H
Go to the documentation of this file.
1 #ifndef ERF_SURFACE_LAYER_STRESS_H_
2 #define ERF_SURFACE_LAYER_STRESS_H_
3 
4 #include "AMReX_GpuQualifiers.H"
5 #include "AMReX_REAL.H"
6 
8 
9 /** LSM cache value from a conservative face stress. */
10 AMREX_GPU_HOST_DEVICE
11 AMREX_FORCE_INLINE
14  amrex::Real conservative_stress, amrex::Real rho)
15 {
16  return conservative_stress / rho;
17 }
18 
19 /** Test one LSM side without coupling validity to another component's handle.
20  */
21 AMREX_GPU_HOST_DEVICE
22 AMREX_FORCE_INLINE
23 bool
25  bool has_flux, bool is_land, amrex::Real flux, amrex::Real undefined)
26 {
27  return has_flux && is_land && flux < undefined;
28 }
29 
31 {
35 };
36 
37 /**
38  * Combine cell-centered kinematic LSM stresses with a conservative MOST
39  * fallback stress at one face. The returned cache values are always
40  * kinematic, while face_stress is always conservative.
41  */
42 AMREX_GPU_HOST_DEVICE
43 AMREX_FORCE_INLINE
46  amrex::Real rho_low,
47  amrex::Real rho_high,
48  amrex::Real kinematic_low,
49  amrex::Real kinematic_high,
50  bool low_valid,
51  bool high_valid,
52  amrex::Real most_face_stress)
53 {
54  const amrex::Real half = amrex::Real(0.5);
55  FaceStressResult result{
56  amrex::Real(0.0),
57  low_valid ? kinematic_low
58  : conservative_to_kinematic_stress(most_face_stress, rho_low),
59  high_valid ? kinematic_high
60  : conservative_to_kinematic_stress(most_face_stress, rho_high)};
61 
62  if (low_valid && high_valid) {
63  result.face_stress =
64  half * rho_low * kinematic_low + half * rho_high * kinematic_high;
65  } else if (low_valid) {
66  result.face_stress =
67  half * rho_low * kinematic_low + half * most_face_stress;
68  } else if (high_valid) {
69  result.face_stress =
70  half * rho_high * kinematic_high + half * most_face_stress;
71  } else {
72  result.face_stress = most_face_stress;
73  }
74 
75  return result;
76 }
77 
78 } // namespace surface_layer_stress
79 
80 #endif
rho
Definition: ERF_InitCustomPert_Bubble.H:107
amrex::Real Real
Definition: ERF_ShocInterface.H:19
Definition: ERF_SurfaceLayerStress.H:7
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real conservative_to_kinematic_stress(amrex::Real conservative_stress, amrex::Real rho)
Definition: ERF_SurfaceLayerStress.H:13
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool lsm_flux_is_valid(bool has_flux, bool is_land, amrex::Real flux, amrex::Real undefined)
Definition: ERF_SurfaceLayerStress.H:24
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE FaceStressResult combine_lsm_and_most_stress(amrex::Real rho_low, amrex::Real rho_high, amrex::Real kinematic_low, amrex::Real kinematic_high, bool low_valid, bool high_valid, amrex::Real most_face_stress)
Definition: ERF_SurfaceLayerStress.H:45
Definition: ERF_SurfaceLayerStress.H:31
amrex::Real face_stress
Definition: ERF_SurfaceLayerStress.H:32
amrex::Real low_kinematic_cache
Definition: ERF_SurfaceLayerStress.H:33
amrex::Real high_kinematic_cache
Definition: ERF_SurfaceLayerStress.H:34