ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_BuoyancyUtils.H File Reference
#include <ERF_EOS.H>
#include <ERF_Constants.H>
Include dependency graph for ERF_BuoyancyUtils.H:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real buoyancy_dry_anelastic (int &i, int &j, int &k, const amrex::Real &grav_gpu, const amrex::Array4< const amrex::Real > &r0_arr, const amrex::Array4< const amrex::Real > &th0_arr, const amrex::Array4< const amrex::Real > &cell_data)
 
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real buoyancy_dry_anelastic_eb (int &i, int &j, int &k, const amrex::Real &grav_gpu, const amrex::Array4< const amrex::Real > &r0_arr, const amrex::Array4< const amrex::Real > &th0_arr, const amrex::Array4< const amrex::Real > &cell_data, amrex::Array4< amrex::EBCellFlag const > const &flag)
 
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real buoyancy_moist_anelastic (int &i, int &j, int &k, const amrex::Real &grav_gpu, const amrex::Array4< const amrex::Real > &r0_arr, const amrex::Array4< const amrex::Real > &th0_arr, const amrex::Array4< const amrex::Real > &qv0_arr, const amrex::Array4< const amrex::Real > &cell_data, const amrex::Array4< const amrex::Real > &qt_arr)
 
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real buoyancy_rhopert (int &i, int &j, int &k, const amrex::Real &grav_gpu, const amrex::Array4< const amrex::Real > &r0_arr, const amrex::Array4< const amrex::Real > &qv0_arr, const amrex::Array4< const amrex::Real > &cell_data, const amrex::Array4< const amrex::Real > &qt_arr)
 
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real buoyancy_rhopert_eb (int &i, int &j, int &k, const amrex::Real &grav_gpu, const amrex::Array4< const amrex::Real > &r0_arr, const amrex::Array4< const amrex::Real > &qv0_arr, const amrex::Array4< const amrex::Real > &cell_data, const amrex::Array4< const amrex::Real > &qt_arr, amrex::Array4< amrex::EBCellFlag const > const &flag)
 
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real buoyancy_dry_Tpert (int &i, int &j, int &k, const amrex::Real &grav_gpu, const amrex::Real &, const amrex::Array4< const amrex::Real > &r0_arr, const amrex::Array4< const amrex::Real > &p0_arr, const amrex::Array4< const amrex::Real > &th0_arr, const amrex::Array4< const amrex::Real > &cell_data)
 
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real buoyancy_dry_Thpert (int &i, int &j, int &k, const amrex::Real &grav_gpu, const amrex::Array4< const amrex::Real > &r0_arr, const amrex::Array4< const amrex::Real > &th0_arr, const amrex::Array4< const amrex::Real > &cell_prim)
 
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real buoyancy_moist_Tpert (int &i, int &j, int &k, const int &n_qstate, const amrex::Real &grav_gpu, const amrex::Real &, const amrex::Array4< const amrex::Real > &r0_arr, const amrex::Array4< const amrex::Real > &th0_arr, const amrex::Array4< const amrex::Real > &qv0_arr, const amrex::Array4< const amrex::Real > &p0_arr, const amrex::Array4< const amrex::Real > &cell_prim, const amrex::Array4< const amrex::Real > &cell_data, const amrex::Array4< const amrex::Real > &qt_arr)
 
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real buoyancy_moist_Thpert (int &i, int &j, int &k, const int &n_qstate, const amrex::Real &grav_gpu, const amrex::Array4< const amrex::Real > &r0_arr, const amrex::Array4< const amrex::Real > &th0_arr, const amrex::Array4< const amrex::Real > &qv0_arr, const amrex::Array4< const amrex::Real > &cell_prim, const amrex::Array4< const amrex::Real > &qt_arr)
 
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real buoyancy_dry_anelastic_T (int &i, int &j, int &k, const amrex::Real &grav_gpu, const amrex::Real &, const amrex::Array4< const amrex::Real > &r0_arr, const amrex::Array4< const amrex::Real > &p0_arr, const amrex::Array4< const amrex::Real > &cell_data)
 

Function Documentation

◆ buoyancy_dry_anelastic()

AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real buoyancy_dry_anelastic ( int &  i,
int &  j,
int &  k,
const amrex::Real grav_gpu,
const amrex::Array4< const amrex::Real > &  r0_arr,
const amrex::Array4< const amrex::Real > &  th0_arr,
const amrex::Array4< const amrex::Real > &  cell_data 
)

Compute dry anelastic buoyancy.

Parameters
[in]ix-index
[in]jy-index
[in]kz-index
[in]grav_gpuGravity
[in]r0_arrReference density field
[in]th0_arrReference potential temperature field
[in]cell_dataState data FAB
Returns
Dry anelastic buoyancy value
27 {
28  // Note: this is the same term as the moist anelastic buoyancy when qv = qc = qt = 0
29  amrex::Real theta_d_hi = cell_data(i,j,k ,RhoTheta_comp)/cell_data(i,j,k ,Rho_comp);
30  amrex::Real theta_d_lo = cell_data(i,j,k-1,RhoTheta_comp)/cell_data(i,j,k-1,Rho_comp);
31 
32  amrex::Real theta_d_wface = myhalf * (theta_d_lo + theta_d_hi);
33  amrex::Real theta_d0_wface = myhalf * (th0_arr(i,j,k) + th0_arr(i,j,k-1));
34  amrex::Real rho0_wface = myhalf * (r0_arr(i,j,k) + r0_arr(i,j,k-1));
35 
36  return (-rho0_wface * grav_gpu * (theta_d_wface - theta_d0_wface) / theta_d0_wface);
37 }
constexpr amrex::Real myhalf
Definition: ERF_Constants.H:13
#define Rho_comp
Definition: ERF_IndexDefines.H:39
#define RhoTheta_comp
Definition: ERF_IndexDefines.H:40
amrex::Real Real
Definition: ERF_ShocInterface.H:19

Referenced by make_buoyancy().

Here is the caller graph for this function:

◆ buoyancy_dry_anelastic_eb()

AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real buoyancy_dry_anelastic_eb ( int &  i,
int &  j,
int &  k,
const amrex::Real grav_gpu,
const amrex::Array4< const amrex::Real > &  r0_arr,
const amrex::Array4< const amrex::Real > &  th0_arr,
const amrex::Array4< const amrex::Real > &  cell_data,
amrex::Array4< amrex::EBCellFlag const > const &  flag 
)

Compute dry anelastic buoyancy with embedded boundary handling.

Parameters
[in]ix-index
[in]jy-index
[in]kz-index
[in]grav_gpuGravity
[in]r0_arrReference density field
[in]th0_arrReference potential temperature field
[in]cell_dataState data FAB
[in]flagEB cell flags
Returns
Dry anelastic buoyancy value
61 {
62  amrex::Real buoyancy = zero;
63  if (flag(i,j,k).isRegular()) {
64  amrex::Real theta_d_hi = cell_data(i,j,k ,RhoTheta_comp)/cell_data(i,j,k ,Rho_comp);
65  amrex::Real theta_d_lo = cell_data(i,j,k-1,RhoTheta_comp)/cell_data(i,j,k-1,Rho_comp);
66  amrex::Real theta_d_wface = myhalf * (theta_d_lo + theta_d_hi);
67  amrex::Real theta_d0_wface = myhalf * (th0_arr(i,j,k) + th0_arr(i,j,k-1));
68  amrex::Real rho0_wface = myhalf * (r0_arr(i,j,k) + r0_arr(i,j,k-1));
69  buoyancy = -rho0_wface * grav_gpu * (theta_d_wface - theta_d0_wface) / theta_d0_wface;
70  } else if (flag(i,j,k).isSingleValued()) {
71  if (flag(i,j,k-1).isCovered()) {
72  amrex::Real theta_d_hihi = cell_data(i,j,k+1,RhoTheta_comp)/cell_data(i,j,k+1,Rho_comp);
73  amrex::Real theta_d_hi = cell_data(i,j,k ,RhoTheta_comp)/cell_data(i,j,k ,Rho_comp);
74  amrex::Real theta_d_wface = myhalf * (three*theta_d_hi - theta_d_hihi);
75  amrex::Real theta_d0_wface = myhalf * (three*th0_arr(i,j,k) - th0_arr(i,j,k+1));
76  amrex::Real rho0_wface = myhalf * (three*r0_arr(i,j,k) - r0_arr(i,j,k+1));
77  buoyancy = -rho0_wface * grav_gpu * (theta_d_wface - theta_d0_wface) / theta_d0_wface;
78  } else if (flag(i,j,k).isCovered()) {
79  amrex::Real theta_d_lo = cell_data(i,j,k-1,RhoTheta_comp)/cell_data(i,j,k-1,Rho_comp);
80  amrex::Real theta_d_lolo = cell_data(i,j,k-2,RhoTheta_comp)/cell_data(i,j,k-2,Rho_comp);
81  amrex::Real theta_d_wface = myhalf * (three*theta_d_lo - theta_d_lolo);
82  amrex::Real theta_d0_wface = myhalf * (three*th0_arr(i,j,k-1) - th0_arr(i,j,k-2));
83  amrex::Real rho0_wface = myhalf * (three*r0_arr(i,j,k-1) - r0_arr(i,j,k-2));
84  buoyancy = -rho0_wface * grav_gpu * (theta_d_wface - theta_d0_wface) / theta_d0_wface;
85  } else {
86  amrex::Real theta_d_hi = cell_data(i,j,k ,RhoTheta_comp)/cell_data(i,j,k ,Rho_comp);
87  amrex::Real theta_d_lo = cell_data(i,j,k-1,RhoTheta_comp)/cell_data(i,j,k-1,Rho_comp);
88  amrex::Real theta_d_wface = myhalf * (theta_d_lo + theta_d_hi);
89  amrex::Real theta_d0_wface = myhalf * (th0_arr(i,j,k) + th0_arr(i,j,k-1));
90  amrex::Real rho0_wface = myhalf * (r0_arr(i,j,k) + r0_arr(i,j,k-1));
91  buoyancy = -rho0_wface * grav_gpu * (theta_d_wface - theta_d0_wface) / theta_d0_wface;
92  }
93  }
94  return buoyancy;
95 }
constexpr amrex::Real three
Definition: ERF_Constants.H:11
constexpr amrex::Real zero
Definition: ERF_Constants.H:8

Referenced by make_buoyancy().

Here is the caller graph for this function:

◆ buoyancy_dry_anelastic_T()

AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real buoyancy_dry_anelastic_T ( int &  i,
int &  j,
int &  k,
const amrex::Real grav_gpu,
const amrex::Real ,
const amrex::Array4< const amrex::Real > &  r0_arr,
const amrex::Array4< const amrex::Real > &  p0_arr,
const amrex::Array4< const amrex::Real > &  cell_data 
)

Compute dry anelastic buoyancy using temperature.

Parameters
[in]ix-index
[in]jy-index
[in]kz-index
[in]grav_gpuGravity
[in]RdoCpGas constant ratio (unused)
[in]r0_arrReference density field
[in]p0_arrReference pressure field
[in]cell_dataState data FAB
Returns
Dry anelastic buoyancy value
440 {
441  amrex::Real rt0_hi = getRhoThetagivenP(p0_arr(i,j,k));
442  amrex::Real t0_hi = getTgivenPandTh(p0_arr(i,j,k), rt0_hi/r0_arr(i,j,k), RdoCp);
443  amrex::Real t_hi = getTgivenPandTh(p0_arr(i,j,k), cell_data(i,j,k,RhoTheta_comp)/r0_arr(i,j,k), RdoCp);
444  amrex::Real q_hi = (t_hi-t0_hi)/t0_hi;
445 
446  amrex::Real rt0_lo = getRhoThetagivenP(p0_arr(i,j,k-1));
447  amrex::Real t0_lo = getTgivenPandTh(p0_arr(i,j,k-1), rt0_lo/r0_arr(i,j,k-1), RdoCp);
448  amrex::Real t_lo = getTgivenPandTh(p0_arr(i,j,k-1), cell_data(i,j,k-1,RhoTheta_comp)/r0_arr(i,j,k-1), RdoCp);
449  amrex::Real q_lo = (t_lo-t0_lo)/t0_lo;
450 
451  amrex::Real r0_q_avg = myhalf * (r0_arr(i,j,k) * q_hi + r0_arr(i,j,k-1) * q_lo);
452  return (-r0_q_avg * grav_gpu);
453 }
constexpr amrex::Real RdoCp
Definition: ERF_Constants.H:54
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real getRhoThetagivenP(const amrex::Real p, const amrex::Real qv=amrex::Real(0))
Definition: ERF_EOS.H:172
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real getTgivenPandTh(const amrex::Real P, const amrex::Real th, const amrex::Real rdOcp)
Definition: ERF_EOS.H:32
Here is the call graph for this function:

◆ buoyancy_dry_Thpert()

AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real buoyancy_dry_Thpert ( int &  i,
int &  j,
int &  k,
const amrex::Real grav_gpu,
const amrex::Array4< const amrex::Real > &  r0_arr,
const amrex::Array4< const amrex::Real > &  th0_arr,
const amrex::Array4< const amrex::Real > &  cell_prim 
)

Compute dry buoyancy based on potential temperature perturbations.

Parameters
[in]ix-index
[in]jy-index
[in]kz-index
[in]grav_gpuGravity
[in]r0_arrReference density field
[in]th0_arrReference potential temperature field
[in]cell_primPrimitive variable FAB
Returns
Dry buoyancy value
300 {
301  amrex::Real thetaprime_hi = (cell_prim(i,j,k ,PrimTheta_comp) - th0_arr(i,j,k )) / th0_arr(i,j,k );
302  amrex::Real thetaprime_lo = (cell_prim(i,j,k-1,PrimTheta_comp) - th0_arr(i,j,k-1)) / th0_arr(i,j,k-1);
303 
304  amrex::Real thp_avg = myhalf * (thetaprime_hi + thetaprime_lo);
305  amrex::Real r0_avg = myhalf * (r0_arr(i,j,k) + r0_arr(i,j,k-1));
306 
307  return ( -r0_avg * grav_gpu * thp_avg);
308 }
#define PrimTheta_comp
Definition: ERF_IndexDefines.H:58

Referenced by make_buoyancy().

Here is the caller graph for this function:

◆ buoyancy_dry_Tpert()

AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real buoyancy_dry_Tpert ( int &  i,
int &  j,
int &  k,
const amrex::Real grav_gpu,
const amrex::Real ,
const amrex::Array4< const amrex::Real > &  r0_arr,
const amrex::Array4< const amrex::Real > &  p0_arr,
const amrex::Array4< const amrex::Real > &  th0_arr,
const amrex::Array4< const amrex::Real > &  cell_data 
)

Compute dry buoyancy based on temperature perturbations.

Parameters
[in]ix-index
[in]jy-index
[in]kz-index
[in]grav_gpuGravity
[in]lRdoCpGas constant ratio (unused)
[in]r0_arrReference density field
[in]p0_arrReference pressure field
[in]th0_arrReference potential temperature field
[in]cell_dataState data FAB
Returns
Dry buoyancy value
264 {
265  amrex::Real t0_hi = getTgivenPandTh(p0_arr(i,j,k), th0_arr(i,j,k), RdoCp);
266  amrex::Real t_hi = getTgivenRandRTh(cell_data(i,j,k ,Rho_comp), cell_data(i,j,k ,RhoTheta_comp));
267 
268  amrex::Real t0_lo = getTgivenPandTh(p0_arr(i,j,k-1), th0_arr(i,j,k-1), RdoCp);
269  amrex::Real t_lo = getTgivenRandRTh(cell_data(i,j,k-1,Rho_comp), cell_data(i,j,k-1,RhoTheta_comp));
270 
271  amrex::Real tprime_hi = (t_hi-t0_hi)/t0_hi;
272  amrex::Real tprime_lo = (t_lo-t0_lo)/t0_lo;
273 
274  amrex::Real tp_avg = myhalf * (tprime_hi + tprime_lo);
275  amrex::Real r0_avg = myhalf * (r0_arr(i,j,k) + r0_arr(i,j,k-1));
276 
277  return ( -r0_avg * grav_gpu * tp_avg);
278 }
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real getTgivenRandRTh(const amrex::Real rho, const amrex::Real rhotheta, const amrex::Real qv=amrex::Real(0))
Definition: ERF_EOS.H:46

Referenced by make_buoyancy().

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

◆ buoyancy_moist_anelastic()

AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real buoyancy_moist_anelastic ( int &  i,
int &  j,
int &  k,
const amrex::Real grav_gpu,
const amrex::Array4< const amrex::Real > &  r0_arr,
const amrex::Array4< const amrex::Real > &  th0_arr,
const amrex::Array4< const amrex::Real > &  qv0_arr,
const amrex::Array4< const amrex::Real > &  cell_data,
const amrex::Array4< const amrex::Real > &  qt_arr 
)

Compute moist anelastic buoyancy.

Parameters
[in]ix-index
[in]jy-index
[in]kz-index
[in]grav_gpuGravity
[in]r0_arrReference density field
[in]th0_arrReference potential temperature field
[in]qv0_arrReference water vapor mixing ratio field
[in]cell_dataState data FAB
[in]qt_arrTotal water mixing ratio field
Returns
Moist anelastic buoyancy value
121 {
122  amrex::Real Fact = (one - RvoRd); // ~= -amrex::Real(0.61)
123 
124  amrex::Real th_d_hi = cell_data(i,j,k ,RhoTheta_comp)/cell_data(i,j,k ,Rho_comp);
125  amrex::Real th_d_lo = cell_data(i,j,k-1,RhoTheta_comp)/cell_data(i,j,k-1,Rho_comp);
126 
127  amrex::Real qv_hi = cell_data(i,j,k ,RhoQ1_comp) /cell_data(i,j,k ,Rho_comp);
128  amrex::Real qv_lo = cell_data(i,j,k-1,RhoQ1_comp) /cell_data(i,j,k-1,Rho_comp);
129 
130  amrex::Real qt_hi = qt_arr(i,j,k ) - qv_hi;
131  amrex::Real th_v_hi = th_d_hi * (one - Fact*qt_hi - RvoRd*qt_hi);
132 
133  amrex::Real qt_lo = qt_arr(i,j,k-1) - qv_lo;
134  amrex::Real th_v_lo = th_d_lo * (one - Fact*qt_lo - RvoRd*qt_lo);
135 
136  amrex::Real th_v0_hi = th0_arr(i,j,k ) * (one - Fact*qv0_arr(i,j,k ));
137  amrex::Real th_v0_lo = th0_arr(i,j,k-1) * (one - Fact*qv0_arr(i,j,k-1));
138 
139  amrex::Real qv0_hi = qv0_arr(i,j,k );
140  amrex::Real qv0_lo = qv0_arr(i,j,k-1);
141 
142  amrex::Real q_hi = (qv_hi-qv0_hi) - qt_hi + (th_v_hi - th_v0_hi) / th_v0_hi;
143  amrex::Real q_lo = (qv_lo-qv0_lo) - qt_lo + (th_v_lo - th_v0_lo) / th_v0_lo;
144 
145  amrex::Real qavg = myhalf * (q_hi + q_lo);
146 
147  amrex::Real r0avg = myhalf * (r0_arr(i,j,k) + r0_arr(i,j,k-1));
148 
149  return (-r0avg * grav_gpu * qavg);
150 }
constexpr amrex::Real one
Definition: ERF_Constants.H:9
constexpr amrex::Real RvoRd
Definition: ERF_Constants.H:56
#define RhoQ1_comp
Definition: ERF_IndexDefines.H:45

◆ buoyancy_moist_Thpert()

AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real buoyancy_moist_Thpert ( int &  i,
int &  j,
int &  k,
const int &  n_qstate,
const amrex::Real grav_gpu,
const amrex::Array4< const amrex::Real > &  r0_arr,
const amrex::Array4< const amrex::Real > &  th0_arr,
const amrex::Array4< const amrex::Real > &  qv0_arr,
const amrex::Array4< const amrex::Real > &  cell_prim,
const amrex::Array4< const amrex::Real > &  qt_arr 
)

Compute moist buoyancy based on potential temperature perturbations.

Parameters
[in]ix-index
[in]jy-index
[in]kz-index
[in]n_qstateNumber of moisture species
[in]grav_gpuGravity
[in]r0_arrReference density field
[in]th0_arrReference potential temperature field
[in]qv0_arrReference water vapor mixing ratio field
[in]cell_primPrimitive variable FAB
[in]qt_arrTotal water mixing ratio field
Returns
Moist buoyancy value
391 {
392  amrex::Real qv_hi = (n_qstate >= 1) ? cell_prim(i,j,k ,PrimQ1_comp) : zero;
393  amrex::Real qv_lo = (n_qstate >= 1) ? cell_prim(i,j,k-1,PrimQ1_comp) : zero;
394 
395  amrex::Real qt_hi = qt_arr(i,j,k ) - qv_hi;
396  amrex::Real qt_lo = qt_arr(i,j,k-1) - qv_lo;
397 
398  amrex::Real dth_hi = cell_prim(i,j,k ,PrimTheta_comp) - th0_arr(i,j,k );
399  amrex::Real dth_lo = cell_prim(i,j,k-1,PrimTheta_comp) - th0_arr(i,j,k-1);
400 
401  amrex::Real qv0_hi = qv0_arr(i,j,k );
402  amrex::Real qv0_lo = qv0_arr(i,j,k-1);
403 
404  amrex::Real q_hi = epsv * (qv_hi-qv0_hi) - qt_hi + dth_hi/th0_arr(i,j,k );
405  amrex::Real q_lo = epsv * (qv_lo-qv0_lo) - qt_lo + dth_lo/th0_arr(i,j,k-1);
406 
407  amrex::Real qavg = myhalf * (q_hi + q_lo);
408 
409  amrex::Real r0avg = myhalf * (r0_arr(i,j,k) + r0_arr(i,j,k-1));
410 
411  return ( -r0avg * grav_gpu * qavg);
412 }
constexpr amrex::Real epsv
Definition: ERF_Constants.H:53
#define PrimQ1_comp
Definition: ERF_IndexDefines.H:61

Referenced by make_buoyancy().

Here is the caller graph for this function:

◆ buoyancy_moist_Tpert()

AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real buoyancy_moist_Tpert ( int &  i,
int &  j,
int &  k,
const int &  n_qstate,
const amrex::Real grav_gpu,
const amrex::Real ,
const amrex::Array4< const amrex::Real > &  r0_arr,
const amrex::Array4< const amrex::Real > &  th0_arr,
const amrex::Array4< const amrex::Real > &  qv0_arr,
const amrex::Array4< const amrex::Real > &  p0_arr,
const amrex::Array4< const amrex::Real > &  cell_prim,
const amrex::Array4< const amrex::Real > &  cell_data,
const amrex::Array4< const amrex::Real > &  qt_arr 
)

Compute moist buoyancy based on temperature perturbations.

Parameters
[in]ix-index
[in]jy-index
[in]kz-index
[in]n_qstateNumber of moisture species
[in]grav_gpuGravity
[in]lRdoCpGas constant ratio (unused)
[in]r0_arrReference density field
[in]th0_arrReference potential temperature field
[in]qv0_arrReference water vapor mixing ratio field
[in]p0_arrReference pressure field
[in]cell_primPrimitive variable FAB
[in]cell_dataState data FAB
[in]qt_arrTotal water mixing ratio field
Returns
Moist buoyancy value
342 {
343  amrex::Real qv_hi = (n_qstate >= 1) ? cell_prim(i,j,k ,PrimQ1_comp) : zero;
344  amrex::Real qv_lo = (n_qstate >= 1) ? cell_prim(i,j,k-1,PrimQ1_comp) : zero;
345 
346  amrex::Real t0_hi = getTgivenPandTh(p0_arr(i,j,k ), th0_arr(i,j,k ), RdoCp);
347  amrex::Real t0_lo = getTgivenPandTh(p0_arr(i,j,k-1), th0_arr(i,j,k-1), RdoCp);
348 
349  amrex::Real dt_hi = getTgivenRandRTh(cell_data(i,j,k ,Rho_comp), cell_data(i,j,k ,RhoTheta_comp), qv_hi) - t0_hi;
350  amrex::Real dt_lo = getTgivenRandRTh(cell_data(i,j,k-1,Rho_comp), cell_data(i,j,k-1,RhoTheta_comp), qv_lo) - t0_lo;
351 
352  amrex::Real qv0_hi = qv0_arr(i,j,k );
353  amrex::Real qv0_lo = qv0_arr(i,j,k-1);
354 
355  amrex::Real q_hi = epsv * (qv_hi-qv0_hi) - (qt_arr(i,j,k )-qv_hi) + dt_hi/t0_hi;
356  amrex::Real q_lo = epsv * (qv_lo-qv0_lo) - (qt_arr(i,j,k-1)-qv_lo) + dt_lo/t0_lo;
357 
358  amrex::Real qavg = myhalf * (q_hi + q_lo);
359 
360  amrex::Real r0avg = myhalf * (r0_arr(i,j,k) + r0_arr(i,j,k-1));
361 
362  return ( -r0avg * grav_gpu * qavg);
363 }

Referenced by make_buoyancy().

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

◆ buoyancy_rhopert()

AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real buoyancy_rhopert ( int &  i,
int &  j,
int &  k,
const amrex::Real grav_gpu,
const amrex::Array4< const amrex::Real > &  r0_arr,
const amrex::Array4< const amrex::Real > &  qv0_arr,
const amrex::Array4< const amrex::Real > &  cell_data,
const amrex::Array4< const amrex::Real > &  qt_arr 
)

Compute buoyancy based on density perturbations.

Parameters
[in]ix-index
[in]jy-index
[in]kz-index
[in]grav_gpuGravity
[in]r0_arrReference density field
[in]qv0_arrReference water vapor mixing ratio field
[in]cell_dataState data FAB
[in]qt_arrTotal water mixing ratio field
Returns
Buoyancy value
174 {
175  amrex::Real rhop_hi = cell_data(i,j,k ,Rho_comp) * (one + qt_arr(i,j,k )) -
176  r0_arr(i,j,k ) * (one + qv0_arr(i,j,k ));
177  amrex::Real rhop_lo = cell_data(i,j,k-1,Rho_comp) * (one + qt_arr(i,j,k-1)) -
178  r0_arr(i,j,k-1 ) * (one + qv0_arr(i,j,k-1));
179  return( grav_gpu * myhalf * ( rhop_hi + rhop_lo ) );
180 }

Referenced by make_buoyancy().

Here is the caller graph for this function:

◆ buoyancy_rhopert_eb()

AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real buoyancy_rhopert_eb ( int &  i,
int &  j,
int &  k,
const amrex::Real grav_gpu,
const amrex::Array4< const amrex::Real > &  r0_arr,
const amrex::Array4< const amrex::Real > &  qv0_arr,
const amrex::Array4< const amrex::Real > &  cell_data,
const amrex::Array4< const amrex::Real > &  qt_arr,
amrex::Array4< amrex::EBCellFlag const > const &  flag 
)

Compute buoyancy based on density perturbations with embedded boundary handling.

Parameters
[in]ix-index
[in]jy-index
[in]kz-index
[in]grav_gpuGravity
[in]r0_arrReference density field
[in]qv0_arrReference water vapor mixing ratio field
[in]cell_dataState data FAB
[in]qt_arrTotal water mixing ratio field
[in]flagEB cell flags
Returns
Buoyancy value
206 {
207  amrex::Real buoyancy = zero;
208  if (flag(i,j,k).isRegular()) {
209  amrex::Real rhop_hi = cell_data(i,j,k ,Rho_comp) * (one + qt_arr(i,j,k )) -
210  r0_arr(i,j,k ) * (one + qv0_arr(i,j,k ));
211  amrex::Real rhop_lo = cell_data(i,j,k-1,Rho_comp) * (one + qt_arr(i,j,k-1)) -
212  r0_arr(i,j,k-1 ) * (one + qv0_arr(i,j,k-1));
213  buoyancy = grav_gpu * myhalf * ( rhop_hi + rhop_lo );
214  } else if (flag(i,j,k).isSingleValued()) {
215  if (flag(i,j,k-1).isCovered()) {
216  amrex::Real rhop_hihi = cell_data(i,j,k+1,Rho_comp) * (one + qt_arr(i,j,k+1)) -
217  r0_arr(i,j,k+1 ) * (one + qv0_arr(i,j,k+1));
218  amrex::Real rhop_hi = cell_data(i,j,k ,Rho_comp) * (one + qt_arr(i,j,k )) -
219  r0_arr(i,j,k ) * (one + qv0_arr(i,j,k ));
220  buoyancy = grav_gpu * myhalf * ( three * rhop_hi - rhop_hihi );
221  // buoyancy = grav_gpu * rhop_hi;
222  } else if (flag(i,j,k).isCovered()) {
223  amrex::Real rhop_lo = cell_data(i,j,k-1,Rho_comp) * (one + qt_arr(i,j,k-1)) -
224  r0_arr(i,j,k-1 ) * (one + qv0_arr(i,j,k-1));
225  amrex::Real rhop_lolo = cell_data(i,j,k-2,Rho_comp) * (one + qt_arr(i,j,k-2)) -
226  r0_arr(i,j,k-2 ) * (one + qv0_arr(i,j,k-2));
227  buoyancy = grav_gpu * myhalf * ( three * rhop_lo - rhop_lolo );
228  // buoyancy = grav_gpu * rhop_lo;
229  } else {
230  amrex::Real rhop_hi = cell_data(i,j,k ,Rho_comp) * (one + qt_arr(i,j,k )) -
231  r0_arr(i,j,k ) * (one + qv0_arr(i,j,k ));
232  amrex::Real rhop_lo = cell_data(i,j,k-1,Rho_comp) * (one + qt_arr(i,j,k-1)) -
233  r0_arr(i,j,k-1 ) * (one + qv0_arr(i,j,k-1));
234  buoyancy = grav_gpu * myhalf * ( rhop_hi + rhop_lo );
235  }
236  }
237  return buoyancy;
238 }

Referenced by make_buoyancy().

Here is the caller graph for this function: