ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_init_from_input_sounding.cpp File Reference
#include <ERF.H>
#include <EOS.H>
#include <ERF_Constants.H>
#include <Utils.H>
#include <prob_common.H>
Include dependency graph for ERF_init_from_input_sounding.cpp:

Functions

void init_bx_scalars_from_input_sounding (const Box &bx, Array4< Real > const &state, GeometryData const &geomdata, Array4< const Real > const &z_cc_arr, const bool &l_moist, InputSoundingData const &inputSoundingData)
 
void init_bx_scalars_from_input_sounding_hse (const Box &bx, Array4< Real > const &state, Array4< Real > const &r_hse_arr, Array4< Real > const &p_hse_arr, Array4< Real > const &pi_hse_arr, GeometryData const &geomdata, Array4< const Real > const &z_cc_arr, const Real &l_gravity, const Real &l_rdOcp, const bool &l_moist, InputSoundingData const &inputSoundingData)
 
void init_bx_velocities_from_input_sounding (const Box &bx, Array4< Real > const &x_vel, Array4< Real > const &y_vel, Array4< Real > const &z_vel, GeometryData const &geomdata, Array4< const Real > const &z_nd_arr, InputSoundingData const &inputSoundingData)
 

Function Documentation

◆ init_bx_scalars_from_input_sounding()

void init_bx_scalars_from_input_sounding ( const Box &  bx,
Array4< Real > const &  state,
GeometryData const &  geomdata,
Array4< const Real > const &  z_cc_arr,
const bool &  l_moist,
InputSoundingData const &  inputSoundingData 
)

Box level wrapper for initializing scalar data from input sounding data.

Parameters
bxBox specifying the indices we are initializing
stateArray4 specifying the state data we are to initialize
geomdataGeometryData object specifying the domain geometry
inputSoundingDataInputSoundingData object we are to initialize from
138 {
139  const Real* z_inp_sound = inputSoundingData.z_inp_sound_d.dataPtr();
140  const Real* theta_inp_sound = inputSoundingData.theta_inp_sound_d.dataPtr();
141  const Real* qv_inp_sound = inputSoundingData.qv_inp_sound_d.dataPtr();
142  const int inp_sound_size = inputSoundingData.size();
143 
144  // Geometry
145  const Real* prob_lo = geomdata.ProbLo();
146  const Real* dx = geomdata.CellSize();
147  const Real z_lo = prob_lo[2];
148  const Real dz = dx[2];
149 
150  // We want to set the lateral BC values, too
151  Box gbx = bx; // Copy constructor
152  gbx.grow(0,1); gbx.grow(1,1); // Grow by one in the lateral directions
153 
154  ParallelFor(gbx, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept {
155  const Real z = (z_cc_arr) ? z_cc_arr(i,j,k)
156  : z_lo + (k + 0.5) * dz;
157 
158  Real rho_0 = 1.0;
159 
160  // Set the density
161  state(i, j, k, Rho_comp) = rho_0;
162 
163  // Initial Rho0*Theta0
164  state(i, j, k, RhoTheta_comp) = rho_0 * interpolate_1d(z_inp_sound, theta_inp_sound, z, inp_sound_size);
165 
166  // Set scalar = A_0*exp(-10r^2), where r is distance from center of domain
167  state(i, j, k, RhoScalar_comp) = 0;
168 
169  // total nonprecipitating water (Q1) == water vapor (Qv), i.e., there is no cloud water or cloud ice
170  if (l_moist)
171  state(i, j, k, RhoQ1_comp) = rho_0 * interpolate_1d(z_inp_sound, qv_inp_sound, z, inp_sound_size);
172 
173  });
174 }
#define RhoScalar_comp
Definition: IndexDefines.H:16
#define Rho_comp
Definition: IndexDefines.H:12
#define RhoTheta_comp
Definition: IndexDefines.H:13
#define RhoQ1_comp
Definition: IndexDefines.H:17
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real interpolate_1d(const amrex::Real *alpha, const amrex::Real *beta, const amrex::Real alpha_interp, const int alpha_size)
Definition: Interpolation_1D.H:12

Referenced by ERF::init_from_input_sounding().

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

◆ init_bx_scalars_from_input_sounding_hse()

void init_bx_scalars_from_input_sounding_hse ( const Box &  bx,
Array4< Real > const &  state,
Array4< Real > const &  r_hse_arr,
Array4< Real > const &  p_hse_arr,
Array4< Real > const &  pi_hse_arr,
GeometryData const &  geomdata,
Array4< const Real > const &  z_cc_arr,
const Real &  l_gravity,
const Real &  l_rdOcp,
const bool &  l_moist,
InputSoundingData const &  inputSoundingData 
)

Box level wrapper for initializing scalar and hydrostatic base state data from input sounding data.

Parameters
bxBox specifying the indices we are initializing
stateArray4 specifying the state data we are to initialize
r_hse_arrArray4 specifying the density HSE base state data we are to initialize
p_hse_arrArray4 specifying the pressure HSE base state data we are to initialize
pi_hse_arrArray4 specifying the Exner pressure HSE base state data we are to initialize
geomdataGeometryData object specifying the domain geometry
l_gravityReal number specifying the gravitational acceleration constant
l_rdOcpReal number specifying the Rhydberg constant ($R_d$) divided by specific heat at constant pressure ($c_p$)
inputSoundingDataInputSoundingData object we are to initialize from
202 {
203  const Real* z_inp_sound = inputSoundingData.z_inp_sound_d.dataPtr();
204  const Real* rho_inp_sound = inputSoundingData.rho_inp_sound_d.dataPtr();
205  const Real* theta_inp_sound = inputSoundingData.theta_inp_sound_d.dataPtr();
206  const Real* qv_inp_sound = inputSoundingData.qv_inp_sound_d.dataPtr();
207  const int inp_sound_size = inputSoundingData.size();
208 
209  // Geometry
210  int ktop = bx.bigEnd(2);
211  const Real* prob_lo = geomdata.ProbLo();
212  const Real* dx = geomdata.CellSize();
213  const Real z_lo = prob_lo[2];
214  const Real dz = dx[2];
215 
216  // We want to set the lateral BC values, too
217  Box gbx = bx; // Copy constructor
218  gbx.grow(0,1); gbx.grow(1,1); // Grow by one in the lateral directions
219 
220  ParallelFor(gbx, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept {
221  const Real z = (z_cc_arr) ? z_cc_arr(i,j,k)
222  : z_lo + (k + 0.5) * dz;
223 
224  Real rho_k, qv_k, rhoTh_k;
225 
226  // Set the density
227  rho_k = interpolate_1d(z_inp_sound, rho_inp_sound, z, inp_sound_size);
228  state(i, j, k, Rho_comp) = rho_k;
229 
230  // Initial Rho0*Theta0
231  rhoTh_k = rho_k * interpolate_1d(z_inp_sound, theta_inp_sound, z, inp_sound_size);
232  state(i, j, k, RhoTheta_comp) = rhoTh_k;
233 
234  // Set scalar = A_0*exp(-10r^2), where r is distance from center of domain
235  state(i, j, k, RhoScalar_comp) = 0;
236 
237  // Update hse quantities with values calculated from InputSoundingData.calc_rho_p()
238  qv_k = (l_moist) ? interpolate_1d(z_inp_sound, qv_inp_sound, z, inp_sound_size) : 0.0;
239  r_hse_arr (i, j, k) = rho_k * (1.0 + qv_k);
240  p_hse_arr (i, j, k) = getPgivenRTh(rhoTh_k, qv_k);
241  pi_hse_arr(i, j, k) = getExnergivenRTh(rhoTh_k, l_rdOcp);
242 
243  // Boundary treatment
244  if (k==0)
245  {
246  // set the ghost cell with dz and rho at boundary
247  Real rho_surf =
248  interpolate_1d(z_inp_sound, rho_inp_sound, 0.0, inp_sound_size);
249  p_hse_arr (i, j, k-1) = p_hse_arr(i,j,k) + dz * rho_surf * l_gravity;
250  pi_hse_arr(i, j, k-1) = getExnergivenP(p_hse_arr(i, j, k-1), l_rdOcp);
251  }
252  else if (k==ktop)
253  {
254  // set the ghost cell with dz and rho at boundary
255  Real rho_top =
256  interpolate_1d(z_inp_sound, rho_inp_sound, z+dz/2, inp_sound_size);
257  p_hse_arr (i, j, k+1) = p_hse_arr(i,j,k) - dz * rho_top * l_gravity;
258  pi_hse_arr(i, j, k+1) = getExnergivenP(p_hse_arr(i, j, k+1), l_rdOcp);
259  }
260 
261  // total nonprecipitating water (Q1) == water vapor (Qv), i.e., there
262  // is no cloud water or cloud ice
263  if (l_moist)
264  state(i, j, k, RhoQ1_comp) = rho_k * qv_k;
265  });
266 }
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real getPgivenRTh(const amrex::Real rhotheta, const amrex::Real qv=0.)
Definition: EOS.H:62
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real getExnergivenRTh(const amrex::Real rhotheta, const amrex::Real rdOcp, const amrex::Real qv=0.0)
Definition: EOS.H:116
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real getExnergivenP(const amrex::Real P, const amrex::Real rdOcp)
Definition: EOS.H:103

Referenced by ERF::init_from_input_sounding().

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

◆ init_bx_velocities_from_input_sounding()

void init_bx_velocities_from_input_sounding ( const Box &  bx,
Array4< Real > const &  x_vel,
Array4< Real > const &  y_vel,
Array4< Real > const &  z_vel,
GeometryData const &  geomdata,
Array4< const Real > const &  z_nd_arr,
InputSoundingData const &  inputSoundingData 
)

Box level wrapper for initializing velocities from input sounding data.

Parameters
bxBox specifying the indices we are initializing
x_velArray4 specifying the x-velocity data we are to initialize
y_velArray4 specifying the y-velocity data we are to initialize
z_velArray4 specifying the z-velocity data we are to initialize
geomdataGeometryData object specifying the domain geometry
inputSoundingDataInputSoundingData object we are to initialize from
286 {
287  const Real* z_inp_sound = inputSoundingData.z_inp_sound_d.dataPtr();
288  const Real* U_inp_sound = inputSoundingData.U_inp_sound_d.dataPtr();
289  const Real* V_inp_sound = inputSoundingData.V_inp_sound_d.dataPtr();
290  const int inp_sound_size = inputSoundingData.size();
291 
292  // Geometry
293  const Real* prob_lo = geomdata.ProbLo();
294  const Real* dx = geomdata.CellSize();
295  const Real z_lo = prob_lo[2];
296  const Real dz = dx[2];
297 
298  // We want to set the lateral BC values, too
299  Box gbx = bx; // Copy constructor
300  gbx.grow(0,1); gbx.grow(1,1); // Grow by one in the lateral directions
301 
302  // Construct a box that is on x-faces
303  const Box& xbx = surroundingNodes(gbx,0);
304  // Construct a box that is on y-faces
305  const Box& ybx = surroundingNodes(gbx,1);
306  // Construct a box that is on z-faces
307  const Box& zbx = surroundingNodes(gbx,2);
308 
309  // Set the x,y,z-velocities
310  ParallelFor(xbx, ybx, zbx,
311  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept {
312  // Note that this is called on a box of x-faces
313  const Real z = (z_nd_arr) ? 0.25*( z_nd_arr(i,j ,k )
314  + z_nd_arr(i,j+1,k )
315  + z_nd_arr(i,j ,k+1)
316  + z_nd_arr(i,j+1,k+1))
317  : z_lo + (k + 0.5) * dz;
318 
319  // Set the x-velocity
320  x_vel(i, j, k) = interpolate_1d(z_inp_sound, U_inp_sound, z, inp_sound_size);
321  },
322  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept {
323  // Note that this is called on a box of y-faces
324  const Real z = (z_nd_arr) ? 0.25*( z_nd_arr(i ,j,k )
325  + z_nd_arr(i+1,j,k )
326  + z_nd_arr(i ,j,k+1)
327  + z_nd_arr(i+1,j,k+1))
328  : z_lo + (k + 0.5) * dz;
329 
330  // Set the y-velocity
331  y_vel(i, j, k) = interpolate_1d(z_inp_sound, V_inp_sound, z, inp_sound_size);
332  },
333  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept {
334  // Note that this is called on a box of z-faces
335  // Set the z-velocity
336  z_vel(i, j, k) = 0.0;
337  });
338 }

Referenced by ERF::init_from_input_sounding().

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