ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
SDInputs Struct Reference

GPU-compatible structure holding distribution parameters. More...

#include <ERF_SDInitialization.H>

Collaboration diagram for SDInputs:

Public Member Functions

 SDInputs (const std::string &a_common, const std::string &a_block)
 
template<typename T >
bool query (const std::string &a_key, T &a_val, const bool a_record=true)
 
template<typename T >
bool queryarr (const std::string &a_key, std::vector< T > &a_val)
 
template<typename T >
void record (const std::string &a_key, T &a_val)
 
template<typename T >
bool queryarr (const std::string &a_key, std::vector< T > &a_val, const int a_num)
 

Public Attributes

amrex::ParmParse m_common
 
amrex::ParmParse m_block
 
std::string m_common_name
 
std::string m_block_name
 

Detailed Description

GPU-compatible structure holding distribution parameters.

Resolves a super-droplet input across the two input tiers.

A property may be set once for every block under "<name>.<key>", or overridden for a single block under "<name>.<idx>.<key>". The common tier is what lets a property be shared, and is also what keeps input files written before multiple initializations were supported working unchanged.

Precedence is per-block over common. a_val enters holding the default and leaves holding the resolved value. The return value reports whether the value came from the input file, so a caller can tell "the user set this" from "this is the default" without asking ParmParse whether a name is present.

The resolved value is recorded under the per-block prefix so that it appears in job_info. That prefix is unique to this block, so the record cannot be read back by a later block as though the user had set it – which is precisely what recording under the common prefix would do.

Constructor & Destructor Documentation

◆ SDInputs()

SDInputs::SDInputs ( const std::string &  a_common,
const std::string &  a_block 
)
inline
74  : m_common(a_common), m_block(a_block),
75  m_common_name(a_common), m_block_name(a_block) {}
std::string m_block_name
Definition: ERF_SDInitialization.H:115
std::string m_common_name
Definition: ERF_SDInitialization.H:114
amrex::ParmParse m_common
Definition: ERF_SDInitialization.H:112
amrex::ParmParse m_block
Definition: ERF_SDInitialization.H:113

Member Function Documentation

◆ query()

template<typename T >
bool SDInputs::query ( const std::string &  a_key,
T &  a_val,
const bool  a_record = true 
)
inline
79  {
80  bool from_inputs = m_block.query(a_key.c_str(), a_val);
81  if (!from_inputs) { from_inputs = m_common.query(a_key.c_str(), a_val); }
82  if (!from_inputs && a_record) { m_block.add(a_key.c_str(), a_val); }
83  return from_inputs;
84  }

Referenced by SDInitialization::readInputs(), SDInjection::readInputs(), and SDInitProperties::readInputs().

Here is the caller graph for this function:

◆ queryarr() [1/2]

template<typename T >
bool SDInputs::queryarr ( const std::string &  a_key,
std::vector< T > &  a_val 
)
inline

Array-valued form, length taken from the input.

89  {
90  bool from_inputs = m_block.queryarr(a_key.c_str(), a_val);
91  if (!from_inputs) { from_inputs = m_common.queryarr(a_key.c_str(), a_val); }
92  if (!from_inputs) { m_block.addarr(a_key.c_str(), a_val); }
93  return from_inputs;
94  }

Referenced by SDInjection::readInputs(), and SDInitProperties::readInputs().

Here is the caller graph for this function:

◆ queryarr() [2/2]

template<typename T >
bool SDInputs::queryarr ( const std::string &  a_key,
std::vector< T > &  a_val,
const int  a_num 
)
inline

Array-valued form; a_num is the expected number of components.

105  {
106  bool from_inputs = m_block.queryarr(a_key.c_str(), a_val, 0, a_num);
107  if (!from_inputs) { from_inputs = m_common.queryarr(a_key.c_str(), a_val, 0, a_num); }
108  if (!from_inputs) { m_block.addarr(a_key.c_str(), a_val); }
109  return from_inputs;
110  }

◆ record()

template<typename T >
void SDInputs::record ( const std::string &  a_key,
T &  a_val 
)
inline

Record a resolved value under the per-block prefix, for provenance only. Use where one of several alternative spellings of an input is in effect and only the effective one should be reported.

100 { m_block.add(a_key.c_str(), a_val); }

Referenced by SDInitProperties::readInputs().

Here is the caller graph for this function:

Member Data Documentation

◆ m_block

amrex::ParmParse SDInputs::m_block

per-block tier: "<name>.<idx>"

Referenced by query(), queryarr(), and record().

◆ m_block_name

std::string SDInputs::m_block_name

Referenced by SDInjection::readInputs().

◆ m_common

amrex::ParmParse SDInputs::m_common

common tier: "<name>"

Referenced by query(), and queryarr().

◆ m_common_name

std::string SDInputs::m_common_name

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