ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
erf_mass_source Namespace Reference

Functions

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool in_source (int i, int j, int k, amrex::Array4< amrex::Real const > const &z, amrex::Array4< amrex::Real const > const &zg, int kg, amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > const &problo, amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > const &dx, amrex::GpuArray< amrex::Real, 2 > const &period, amrex::Real x0, amrex::Real y0, amrex::Real r2, amrex::Real hmax) noexcept
 
amrex::GpuArray< amrex::Real, 2 > periodic_lengths (const amrex::Geometry &geom)
 The domain length in x and y where geom is periodic, 0 where it is not. More...
 

Detailed Description

A localized source of gas inside the domain (erf.mass_source.*), e.g. the release from a ruptured pipeline.

The gas is injected at a total rate mdot(t) [kg/s], spread uniformly over the cells whose centers lie within erf.mass_source.radius of (center_x, center_y) horizontally and less than erf.mass_source.height above the local ground. The same source is added to

  • rho, so the mass enters the continuity equation (FullyCompressible only: the anelastic projection would remove it, and pseudo-incompressible levels do not support it either),
  • rho*theta, at erf.mass_source.theta if given and otherwise at the cell's own theta, so the injection by itself does not change the potential temperature, and
  • the first passive scalar (rho*s, plotted as rhoadv_0) when erf.mass_source.tracer is true, so that s is the mass fraction of the released gas. No momentum is added: the gas enters at rest. The gas has the properties of dry air (in a moist run it carries no water, so it dilutes the mixing ratios of the cells it enters). The cell volumes include the terrain metric and the map factors. In a periodic direction the region wraps around the domain. The rate table is in the time since the start of the run. Unknown erf.mass_source keys stop the run.

With mesh refinement every level adds the same source density S = mdot / V to its own cells in the region, where V is the volume of the region on the composite grid: the cells of each level that the next finer level does not cover. The composite rate is then mdot however the levels cut the region, and a level without source cells adds nothing. V, and the height of the ground under each column, are recomputed only when the grids change.

Inputs: erf.mass_source.center = x y [m] erf.mass_source.radius = r [m] erf.mass_source.height = h [m above the local ground] erf.mass_source.rate = mdot [kg/s >= 0] constant, or erf.mass_source.rate_file = file two columns "t mdot" [s, kg/s >= 0], '#' comments; linear in between, zero outside the table erf.mass_source.theta = theta [K > 0] optional erf.mass_source.tracer = true optional

Function Documentation

◆ in_source()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool erf_mass_source::in_source ( int  i,
int  j,
int  k,
amrex::Array4< amrex::Real const > const &  z,
amrex::Array4< amrex::Real const > const &  zg,
int  kg,
amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > const &  problo,
amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > const &  dx,
amrex::GpuArray< amrex::Real, 2 > const &  period,
amrex::Real  x0,
amrex::Real  y0,
amrex::Real  r2,
amrex::Real  hmax 
)
noexcept

Is the center of cell (i,j,k) inside the source region? z is the nodal height z_phys_nd and zg the nodal height of the ground under the column (2D, at k = kg). period holds the domain length in x and y where the domain is periodic and 0 where it is not: there the distance is to the nearest periodic image of the center, so the region wraps around

73 {
74  amrex::Real ddx = problo[0] + (i + amrex::Real(0.5)) * dx[0] - x0;
75  amrex::Real ddy = problo[1] + (j + amrex::Real(0.5)) * dx[1] - y0;
76  if (period[0] > 0) { ddx -= period[0] * std::floor(ddx / period[0] + amrex::Real(0.5)); }
77  if (period[1] > 0) { ddy -= period[1] * std::floor(ddy / period[1] + amrex::Real(0.5)); }
78  if (ddx * ddx + ddy * ddy > r2) { return false; }
79  const amrex::Real g = amrex::Real(0.25) * (zg(i,j,kg) + zg(i+1,j,kg) + zg(i,j+1,kg) + zg(i+1,j+1,kg));
80  const amrex::Real zc = amrex::Real(0.125) * (z(i,j,k ) + z(i+1,j,k ) + z(i,j+1,k ) + z(i+1,j+1,k ) +
81  z(i,j,k+1) + z(i+1,j,k+1) + z(i,j+1,k+1) + z(i+1,j+1,k+1));
82  return zc - g < hmax;
83 }
GpuArray< Real, AMREX_SPACEDIM > period
Definition: ERF_ActuatorSpreading.cpp:131
GpuArray< Real, AMREX_SPACEDIM > dx
Definition: ERF_ActuatorSpreading.cpp:131
auto problo
Definition: ERF_InitCustomPertVels_ABL.H:36
const Real zc
Definition: ERF_InitCustomPert_ABL.H:112
real(c_double), parameter g
Definition: ERF_module_model_constants.F90:19

Referenced by MassSource::add_sources(), and MassSource::update_geometry().

Here is the caller graph for this function:

◆ periodic_lengths()

amrex::GpuArray<amrex::Real,2> erf_mass_source::periodic_lengths ( const amrex::Geometry &  geom)
inline

The domain length in x and y where geom is periodic, 0 where it is not.

88 {
89  return {geom.isPeriodic(0) ? geom.ProbLength(0) : amrex::Real(0),
90  geom.isPeriodic(1) ? geom.ProbLength(1) : amrex::Real(0)};
91 }

Referenced by MassSource::add_sources(), and MassSource::update_geometry().

Here is the caller graph for this function: