ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ProblemBase Class Referenceabstract

#include <prob_common.H>

Collaboration diagram for ProblemBase:

Public Member Functions

virtual ~ProblemBase ()=default
 
virtual void erf_init_dens_hse (amrex::MultiFab &, std::unique_ptr< amrex::MultiFab > &, std::unique_ptr< amrex::MultiFab > &, amrex::Geometry const &)
 
virtual void erf_init_dens_hse_moist (amrex::MultiFab &, std::unique_ptr< amrex::MultiFab > &, amrex::Geometry const &)
 
virtual void init_custom_pert (const amrex::Box &, const amrex::Box &, const amrex::Box &, const amrex::Box &, amrex::Array4< amrex::Real const > const &, amrex::Array4< amrex::Real > const &, amrex::Array4< amrex::Real > const &, amrex::Array4< amrex::Real > const &, amrex::Array4< amrex::Real > const &, amrex::Array4< amrex::Real > const &, amrex::Array4< amrex::Real > const &, amrex::Array4< amrex::Real const > const &, amrex::Array4< amrex::Real const > const &, amrex::GeometryData const &, amrex::Array4< amrex::Real const > const &, amrex::Array4< amrex::Real const > const &, amrex::Array4< amrex::Real const > const &, const SolverChoice &)
 
virtual void update_rhotheta_sources (const amrex::Real &, amrex::Vector< amrex::Real > &src, amrex::Gpu::DeviceVector< amrex::Real > &d_src, const amrex::Geometry &geom, std::unique_ptr< amrex::MultiFab > &z_phys_cc)
 
virtual void update_rhoqt_sources (const amrex::Real &, amrex::Vector< amrex::Real > &qsrc, amrex::Gpu::DeviceVector< amrex::Real > &d_qsrc, const amrex::Geometry &geom, std::unique_ptr< amrex::MultiFab > &z_phys_cc)
 
virtual void update_w_subsidence (const amrex::Real &, amrex::Vector< amrex::Real > &wbar, amrex::Gpu::DeviceVector< amrex::Real > &d_wbar, const amrex::Geometry &geom, std::unique_ptr< amrex::MultiFab > &z_phys_cc)
 
virtual void update_geostrophic_profile (const amrex::Real &, amrex::Vector< amrex::Real > &u_geos, amrex::Gpu::DeviceVector< amrex::Real > &d_u_geos, amrex::Vector< amrex::Real > &v_geos, amrex::Gpu::DeviceVector< amrex::Real > &d_v_geos, const amrex::Geometry &geom, std::unique_ptr< amrex::MultiFab > &z_phys_cc)
 
virtual void init_custom_terrain (const amrex::Geometry &, amrex::MultiFab &z_phys_nd, const amrex::Real &)
 
virtual void init_custom_terrain (const amrex::Geometry &, amrex::FArrayBox &z_phys_nd, const amrex::Real &)
 
virtual void erf_init_rayleigh (amrex::Vector< amrex::Vector< amrex::Real > > &, amrex::Geometry const &, std::unique_ptr< amrex::MultiFab > &)
 
void init_uniform (const amrex::Box &bx, amrex::Array4< amrex::Real > const &state)
 

Protected Member Functions

void init_base_parms (amrex::Real rho_0, amrex::Real T_0)
 
virtual std::string name ()=0
 

Protected Attributes

ProbParmDefaults base_parms
 

Detailed Description

Class to hold problem-specific routines

Constructor & Destructor Documentation

◆ ~ProblemBase()

virtual ProblemBase::~ProblemBase ( )
virtualdefault

Virtual destructor to avoid data leakage with derived class

Member Function Documentation

◆ erf_init_dens_hse()

virtual void ProblemBase::erf_init_dens_hse ( amrex::MultiFab &  ,
std::unique_ptr< amrex::MultiFab > &  ,
std::unique_ptr< amrex::MultiFab > &  ,
amrex::Geometry const &   
)
inlinevirtual

Function to initialize the hydrostatic reference density

Parameters
[out]rho_hsehydrostatic reference density
[in]z_phys_ndheight coordinate at nodes
[in]z_phys_ccheight coordinate at cell centers
[in]geomcontainer for geometric information
44  {
45  amrex::Print() << "Hydrostatically balanced density was NOT set"
46  << " -- an appropriate init_type should probably have been specified"
47  << " (e.g., input_sounding, ideal, real, or metgrid)"
48  << std::endl;
49  amrex::Error("Should never call erf_init_dens_hse for "+name()+" problem");
50  }
virtual std::string name()=0
Here is the call graph for this function:

◆ erf_init_dens_hse_moist()

virtual void ProblemBase::erf_init_dens_hse_moist ( amrex::MultiFab &  ,
std::unique_ptr< amrex::MultiFab > &  ,
amrex::Geometry const &   
)
inlinevirtual
56  {
57 
58  }

◆ erf_init_rayleigh()

virtual void ProblemBase::erf_init_rayleigh ( amrex::Vector< amrex::Vector< amrex::Real > > &  ,
amrex::Geometry const &  ,
std::unique_ptr< amrex::MultiFab > &   
)
inlinevirtual

Function to define the quantities needed to impose Rayleigh damping

Parameters
[out]rayleigh_ptrs= {strength of Rayleigh damping, reference values for xvel/yvel/zvel/theta used to define Rayleigh damping}
[in]geomcontainer for geometric information
[in]z_phys_ccheight coordinate at cell centers
344  {
345  amrex::Error("Should never call erf_init_rayleigh for "+name()+" problem");
346  }
Here is the call graph for this function:

◆ init_base_parms()

void ProblemBase::init_base_parms ( amrex::Real  rho_0,
amrex::Real  T_0 
)
inlineprotected

Function to update default base parameters, currently only used for init_type=='uniform'

376  {
377  base_parms.rho_0 = rho_0;
378  base_parms.T_0 = T_0;
379  }
ProbParmDefaults base_parms
Definition: prob_common.H:370
amrex::Real T_0
Definition: prob_common.H:16
amrex::Real rho_0
Definition: prob_common.H:15

◆ init_custom_pert()

virtual void ProblemBase::init_custom_pert ( const amrex::Box &  ,
const amrex::Box &  ,
const amrex::Box &  ,
const amrex::Box &  ,
amrex::Array4< amrex::Real const > const &  ,
amrex::Array4< amrex::Real > const &  ,
amrex::Array4< amrex::Real > const &  ,
amrex::Array4< amrex::Real > const &  ,
amrex::Array4< amrex::Real > const &  ,
amrex::Array4< amrex::Real > const &  ,
amrex::Array4< amrex::Real > const &  ,
amrex::Array4< amrex::Real const > const &  ,
amrex::Array4< amrex::Real const > const &  ,
amrex::GeometryData const &  ,
amrex::Array4< amrex::Real const > const &  ,
amrex::Array4< amrex::Real const > const &  ,
amrex::Array4< amrex::Real const > const &  ,
const SolverChoice  
)
inlinevirtual

Function to perform custom initialization of a test problem

Parameters
[in]bxcell-centered box on which to initialize scalars
[in]xbxbox on which to initialize x-component of velocity
[in]ybxbox on which to initialize y-component of velocity
[in]zbxbox on which to initialize z-component of velocity
[out]statecell-centered variables to be filled in this routine
[out]x_velocityx-component of velocity to be filled in this routine
[out]y_velocityy-component of velocity to be filled in this routine
[out]z_velocityz-component of velocity to be filled in this routine
[out]r_hsehydrostatic reference density
[out]p_hsehydrostatic reference pressure
[in]z_ndheight coordinate at nodes
[in]z_ccheight coordinate at cell centers
[in]qvwater vapor
[in]qccloud water
[in]qicloud ice
[in]mf_mmap factor on cell centers
[in]mf_umap factor on x-faces
[in]mf_vmap factor on y-faces
[in]scSolverChoice structure that carries parameters
102  {
103  amrex::Print() << "No perturbation to background fields supplied for "
104  << name() << " problem" << std::endl;;
105  }
Here is the call graph for this function:

◆ init_custom_terrain() [1/2]

virtual void ProblemBase::init_custom_terrain ( const amrex::Geometry &  ,
amrex::FArrayBox &  z_phys_nd,
const amrex::Real &   
)
inlinevirtual

Function to perform custom initialization of terrain

This version takes a single FArrayBox instead of a MultiFab

310  {
311  // Note that this only sets the terrain value at the ground IF k=0 is in the box
312  amrex::Print() << "Initializing flat terrain at z=0" << std::endl;
313 
314  // Bottom of domain
315  int k0 = 0;
316 
317  // Grown box with no z range
318  amrex::Box bx = z_phys_nd.box();
319  amrex::Array4<amrex::Real> const& z_arr = z_phys_nd.array();
320 
321  ParallelFor(bx, [=] AMREX_GPU_DEVICE (int i, int j, int) {
322  z_arr(i,j,k0) = 0.0;
323  });
324  }

◆ init_custom_terrain() [2/2]

virtual void ProblemBase::init_custom_terrain ( const amrex::Geometry &  ,
amrex::MultiFab &  z_phys_nd,
const amrex::Real &   
)
inlinevirtual

Function to perform custom initialization of terrain

Note: Terrain functionality can also be used to provide grid stretching.

Parameters
[in]geomcontainer for geometric information
[out]z_phys_ndheight coordinate at nodes
[in]timecurrent time
273  {
274  // Note that this only sets the terrain value at the ground IF k=0 is in the box
275  amrex::Print() << "Initializing flat terrain at z=0" << std::endl;
276 
277  // Number of ghost cells
278  int ngrow = z_phys_nd.nGrow();
279 
280  // Bottom of domain
281  int k0 = 0;
282 
283  for ( amrex::MFIter mfi(z_phys_nd, amrex::TilingIfNotGPU()); mfi.isValid(); ++mfi )
284  {
285  // Grown box with no z range
286  amrex::Box zbx = mfi.nodaltilebox(2);
287  if (zbx.smallEnd(2) <= 0) {
288  amrex::Box xybx = mfi.growntilebox(ngrow);
289  xybx.setRange(2,0);
290 
291  amrex::Array4<amrex::Real> const& z_arr = z_phys_nd.array(mfi);
292 
293  ParallelFor(xybx, [=] AMREX_GPU_DEVICE (int i, int j, int) {
294  z_arr(i,j,k0) = 0.0;
295  });
296  }
297  }
298  }

◆ init_uniform()

void ProblemBase::init_uniform ( const amrex::Box &  bx,
amrex::Array4< amrex::Real > const &  state 
)
inline

Function to set uniform background density and pressure fields

353  {
354  amrex::Real rho_0 = base_parms.rho_0;
355  amrex::Real T_0 = base_parms.T_0;
356  amrex::Print() << "Initializing uniform fields"
357  << " rho=" << rho_0 << " theta=" << T_0
358  << " -- this probably only makes sense with gravity turned off"
359  << std::endl;
360 
361  ParallelFor(bx, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
362  {
363  state(i, j, k, Rho_comp) = rho_0;
364  state(i, j, k, RhoTheta_comp) = rho_0 * T_0;
365  });
366  }
#define Rho_comp
Definition: IndexDefines.H:12
#define RhoTheta_comp
Definition: IndexDefines.H:13

◆ name()

virtual std::string ProblemBase::name ( )
protectedpure virtual

◆ update_geostrophic_profile()

virtual void ProblemBase::update_geostrophic_profile ( const amrex::Real &  ,
amrex::Vector< amrex::Real > &  u_geos,
amrex::Gpu::DeviceVector< amrex::Real > &  d_u_geos,
amrex::Vector< amrex::Real > &  v_geos,
amrex::Gpu::DeviceVector< amrex::Real > &  d_v_geos,
const amrex::Geometry &  geom,
std::unique_ptr< amrex::MultiFab > &  z_phys_cc 
)
inlinevirtual

Function to update user-specified temperature source terms that can vary with time and height.

Parameters
[in]timecurrent time
[out]u_geosgeostrophic wind profile
[out]v_geosgeostrophic wind profile
[in]geomcontainer for geometric information
[in]z_phys_ccheight coordinate at cell centers
236  {
237  if (u_geos.empty()) return;
238 
239  if (z_phys_cc) {
240  // use_terrain=1
241  amrex::Error("Geostrophic wind profile not defined for "+name()+" problem with terrain");
242  } else {
243  const int khi = geom.Domain().bigEnd()[2];
244  // const amrex::Real* prob_lo = geom.ProbLo();
245  // const auto dx = geom.CellSize();
246  for (int k = 0; k <= khi; k++)
247  {
248  // const amrex::Real z_cc = prob_lo[2] + (k+0.5)* dx[2];
249  // set RHS term of RhoTheta equation based on time, z_cc here
250  u_geos[k] = 0.0;
251  v_geos[k] = 0.0;
252  }
253  }
254 
255  // Copy from host version to device version
256  amrex::Gpu::copy(amrex::Gpu::hostToDevice, u_geos.begin(), u_geos.end(), d_u_geos.begin());
257  amrex::Gpu::copy(amrex::Gpu::hostToDevice, v_geos.begin(), v_geos.end(), d_v_geos.begin());
258  }
Here is the call graph for this function:

◆ update_rhoqt_sources()

virtual void ProblemBase::update_rhoqt_sources ( const amrex::Real &  ,
amrex::Vector< amrex::Real > &  qsrc,
amrex::Gpu::DeviceVector< amrex::Real > &  d_qsrc,
const amrex::Geometry &  geom,
std::unique_ptr< amrex::MultiFab > &  z_phys_cc 
)
inlinevirtual

Function to update user-specified temperature source terms that can vary with time and height.

Parameters
[in]timecurrent time
[out]rhoqt_sourcemoisture forcing profile
[in]geomcontainer for geometric information
[in]z_phys_ccheight coordinate at cell centers
159  {
160  if (qsrc.empty()) return;
161 
162  if (z_phys_cc) {
163  // use_terrain=1
164  amrex::Error("Moisture forcing not defined for "+name()+" problem with terrain");
165  } else {
166  const int khi = geom.Domain().bigEnd()[2];
167  // const amrex::Real* prob_lo = geom.ProbLo();
168  // const auto dx = geom.CellSize();
169  for (int k = 0; k <= khi; k++)
170  {
171  // const amrex::Real z_cc = prob_lo[2] + (k+0.5)* dx[2];
172  // set RHS term of RhoTheta equation based on time, z_cc here
173  qsrc[k] = 0.0;
174  }
175  }
176 
177  // Copy from host version to device version
178  amrex::Gpu::copy(amrex::Gpu::hostToDevice, qsrc.begin(), qsrc.end(), d_qsrc.begin());
179  }
Here is the call graph for this function:

◆ update_rhotheta_sources()

virtual void ProblemBase::update_rhotheta_sources ( const amrex::Real &  ,
amrex::Vector< amrex::Real > &  src,
amrex::Gpu::DeviceVector< amrex::Real > &  d_src,
const amrex::Geometry &  geom,
std::unique_ptr< amrex::MultiFab > &  z_phys_cc 
)
inlinevirtual

Function to update user-specified temperature source terms that can vary with time and height.

Parameters
[in]timecurrent time
[out]rhotheta_sourceforcing profile
[in]geomcontainer for geometric information
[in]z_phys_ccheight coordinate at cell centers
122  {
123  if (src.empty()) return;
124 
125  if (z_phys_cc) {
126  // use_terrain=1
127  amrex::Error("Temperature forcing not defined for "+name()+" problem with terrain");
128  } else {
129  const int khi = geom.Domain().bigEnd()[2];
130  // const amrex::Real* prob_lo = geom.ProbLo();
131  // const auto dx = geom.CellSize();
132  for (int k = 0; k <= khi; k++)
133  {
134  // const amrex::Real z_cc = prob_lo[2] + (k+0.5)* dx[2];
135  // set RHS term of RhoTheta equation based on time, z_cc here
136  src[k] = 0.0;
137  }
138  }
139 
140  // Copy from host version to device version
141  amrex::Gpu::copy(amrex::Gpu::hostToDevice, src.begin(), src.end(), d_src.begin());
142  }
Here is the call graph for this function:

◆ update_w_subsidence()

virtual void ProblemBase::update_w_subsidence ( const amrex::Real &  ,
amrex::Vector< amrex::Real > &  wbar,
amrex::Gpu::DeviceVector< amrex::Real > &  d_wbar,
const amrex::Geometry &  geom,
std::unique_ptr< amrex::MultiFab > &  z_phys_cc 
)
inlinevirtual

Function to update user-specified temperature source terms that can vary with time and height.

Parameters
[in]timecurrent time
[out]wbarw vel forcing profile
[in]geomcontainer for geometric information
[in]z_phys_ccheight coordinate at cell centers
196  {
197  if (wbar.empty()) return;
198 
199  if (z_phys_cc) {
200  // use_terrain=1
201  amrex::Error("Moisture forcing not defined for "+name()+" problem with terrain");
202  } else {
203  const int khi = geom.Domain().bigEnd()[2];
204  // const amrex::Real* prob_lo = geom.ProbLo();
205  // const auto dx = geom.CellSize();
206  for (int k = 0; k <= khi; k++)
207  {
208  // const amrex::Real z_cc = prob_lo[2] + (k+0.5)* dx[2];
209  // set RHS term of RhoTheta equation based on time, z_cc here
210  wbar[k] = 0.0;
211  }
212  }
213 
214  // Copy from host version to device version
215  amrex::Gpu::copy(amrex::Gpu::hostToDevice, wbar.begin(), wbar.end(), d_wbar.begin());
216  }
@ wbar
Definition: DataStruct.H:52
Here is the call graph for this function:

Member Data Documentation

◆ base_parms

ProbParmDefaults ProblemBase::base_parms
protected

Referenced by init_base_parms(), and init_uniform().


The documentation for this class was generated from the following file: