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
17 amrex::Real
19  amrex::Real conservative_stress, amrex::Real rho)
20 {
21  return conservative_stress / rho;
22 }
23 
25 {
26  amrex::Real face_stress;
27  amrex::Real low_kinematic_cache;
28  amrex::Real high_kinematic_cache;
29 };
30 
31 /**
32  * Combine cell-centered kinematic LSM stresses with a conservative MOST
33  * fallback stress at one face. The returned cache values are always
34  * kinematic, while face_stress is always conservative.
35  *
36  * @param[in] rho_low density on the low-side cell
37  * @param[in] rho_high density on the high-side cell
38  * @param[in] kinematic_low low-side LSM kinematic stress
39  * @param[in] kinematic_high high-side LSM kinematic stress
40  * @param[in] low_valid whether the low-side LSM stress is valid
41  * @param[in] high_valid whether the high-side LSM stress is valid
42  * @param[in] most_face_stress conservative MOST fallback stress at the face
43  */
44 AMREX_GPU_HOST_DEVICE
45 AMREX_FORCE_INLINE
48  amrex::Real rho_low,
49  amrex::Real rho_high,
50  amrex::Real kinematic_low,
51  amrex::Real kinematic_high,
52  bool low_valid,
53  bool high_valid,
54  amrex::Real most_face_stress)
55 {
56  const amrex::Real half = amrex::Real(0.5);
57  FaceStressResult result{
58  amrex::Real(0.0),
59  low_valid ? kinematic_low
60  : conservative_to_kinematic_stress(most_face_stress, rho_low),
61  high_valid ? kinematic_high
62  : conservative_to_kinematic_stress(most_face_stress, rho_high)};
63 
64  if (low_valid && high_valid) {
65  result.face_stress =
66  half * rho_low * kinematic_low + half * rho_high * kinematic_high;
67  } else if (low_valid) {
68  result.face_stress =
69  half * rho_low * kinematic_low + half * most_face_stress;
70  } else if (high_valid) {
71  result.face_stress =
72  half * rho_high * kinematic_high + half * most_face_stress;
73  } else {
74  result.face_stress = most_face_stress;
75  }
76 
77  return result;
78 }
79 
80 } // namespace surface_layer_stress
81 
82 #endif
@ rho
Definition: ERF_Kessler.H:25
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 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:47
Definition: ERF_SurfaceLayerStress.H:25
amrex::Real face_stress
Definition: ERF_SurfaceLayerStress.H:26
amrex::Real low_kinematic_cache
Definition: ERF_SurfaceLayerStress.H:27
amrex::Real high_kinematic_cache
Definition: ERF_SurfaceLayerStress.H:28