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 /**
10  * LSM cache value from a conservative face stress.
11  *
12  * @param[in] conservative_stress conservative face stress
13  * @param[in] rho density used to convert to kinematic stress
14  */
15 AMREX_GPU_HOST_DEVICE
16 AMREX_FORCE_INLINE
19  amrex::Real conservative_stress, amrex::Real rho)
20 {
21  return conservative_stress / rho;
22 }
23 
24 /**
25  * Test one LSM side without coupling validity to another component's handle.
26  *
27  * @param[in] has_flux whether the LSM flux array exists
28  * @param[in] is_land whether the side is classified as land
29  * @param[in] flux flux value to test against the undefined sentinel
30  * @param[in] undefined sentinel value marking undefined LSM fluxes
31  */
32 AMREX_GPU_HOST_DEVICE
33 AMREX_FORCE_INLINE
34 bool
36  bool has_flux, bool is_land, amrex::Real flux, amrex::Real undefined)
37 {
38  return has_flux && is_land && flux < undefined;
39 }
40 
42 {
46 };
47 
48 /**
49  * Combine cell-centered kinematic LSM stresses with a conservative MOST
50  * fallback stress at one face. The returned cache values are always
51  * kinematic, while face_stress is always conservative.
52  *
53  * @param[in] rho_low density on the low-side cell
54  * @param[in] rho_high density on the high-side cell
55  * @param[in] kinematic_low low-side LSM kinematic stress
56  * @param[in] kinematic_high high-side LSM kinematic stress
57  * @param[in] low_valid whether the low-side LSM stress is valid
58  * @param[in] high_valid whether the high-side LSM stress is valid
59  * @param[in] most_face_stress conservative MOST fallback stress at the face
60  */
61 AMREX_GPU_HOST_DEVICE
62 AMREX_FORCE_INLINE
65  amrex::Real rho_low,
66  amrex::Real rho_high,
67  amrex::Real kinematic_low,
68  amrex::Real kinematic_high,
69  bool low_valid,
70  bool high_valid,
71  amrex::Real most_face_stress)
72 {
73  const amrex::Real half = amrex::Real(0.5);
74  FaceStressResult result{
75  amrex::Real(0.0),
76  low_valid ? kinematic_low
77  : conservative_to_kinematic_stress(most_face_stress, rho_low),
78  high_valid ? kinematic_high
79  : conservative_to_kinematic_stress(most_face_stress, rho_high)};
80 
81  if (low_valid && high_valid) {
82  result.face_stress =
83  half * rho_low * kinematic_low + half * rho_high * kinematic_high;
84  } else if (low_valid) {
85  result.face_stress =
86  half * rho_low * kinematic_low + half * most_face_stress;
87  } else if (high_valid) {
88  result.face_stress =
89  half * rho_high * kinematic_high + half * most_face_stress;
90  } else {
91  result.face_stress = most_face_stress;
92  }
93 
94  return result;
95 }
96 
97 } // namespace surface_layer_stress
98 
99 #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:18
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:35
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:64
Definition: ERF_SurfaceLayerStress.H:42
amrex::Real face_stress
Definition: ERF_SurfaceLayerStress.H:43
amrex::Real low_kinematic_cache
Definition: ERF_SurfaceLayerStress.H:44
amrex::Real high_kinematic_cache
Definition: ERF_SurfaceLayerStress.H:45