QMCPACK
SpaceGridInput::SpaceGridInputSection Class Reference
+ Inheritance diagram for SpaceGridInput::SpaceGridInputSection:
+ Collaboration diagram for SpaceGridInput::SpaceGridInputSection:

Public Member Functions

 SpaceGridInputSection ()
 
std::any assignAnyEnum (const std::string &name) const override
 Derived class overrides this to get proper assignment of scoped enum values. More...
 
void checkParticularValidity () override
 Do validation for a particular subtype of InputSection Called by check_valid. More...
 
 SpaceGridInputSection (const SpaceGridInputSection &sgis)=default
 
- Public Member Functions inherited from InputSection
 InputSection ()=default
 
 InputSection (const InputSection &other)=default
 
InputSectionoperator= (const InputSection &other)=default
 
bool has (const std::string &name) const
 
template<typename T >
get (const std::string &name) const
 
template<typename T >
bool setIfInInput (T &var, const std::string &tag)
 set var if input section has read the tag More...
 
void readXML (xmlNodePtr cur)
 Read variable values (initialize) from XML input, call checkValid. More...
 
void init (const std::unordered_map< std::string, std::any > &init_values)
 

Additional Inherited Members

- Public Types inherited from InputSection
using Real = QMCTraits::FullPrecRealType
 
using Position = typename QMCTypes< Real, OHMMS_DIM >::PosType
 
- Static Public Member Functions inherited from InputSection
template<typename ENUM_T >
static std::string reverseLookupInputEnumMap (ENUM_T enum_val, const std::unordered_map< std::string, std::any > &enum_map)
 Get string represtation of enum class type value from enum_val. More...
 
- Protected Types inherited from InputSection
using DelegateHandler = std::function< std::any(xmlNodePtr cur, std::string &value_name)>
 Function that returns Input class as std::any. More...
 
- Protected Member Functions inherited from InputSection
void readAttributes (xmlNodePtr cur, const std::string &element_name, const std::vector< std::string > &do_not_consume)
 reads attributes for both the root node and parameter/child nodes that aren't delegated. More...
 
void registerDelegate (const std::string &tag, DelegateHandler delegate_handler)
 register factory function for delegate input More...
 
virtual void setFromStreamCustom (const std::string &ename, const std::string &name, std::istringstream &svalue)
 Derived class can overrides this to do custom parsing of the element values for Custom elements These can have a name attribute only. More...
 
void report () const
 
void report (std::ostream &out) const
 
- Static Protected Member Functions inherited from InputSection
static std::any lookupAnyEnum (const std::string &enum_name, const std::string &enum_value, const std::unordered_map< std::string, std::any > &enum_map)
 Assign any enum helper for InputSection derived class assumes enum lookup table of this form: inline static const std::unordered_map<std::string, std::any> lookup_input_enum_value{{"integrator-uniform_grid", Integrator::UNIFORM_GRID}, {"integrator-uniform", Integrator::UNIFORM}, {"integrator-density", Integrator::DENSITY}, {"evaluator-loop", Evaluator::LOOP}, {"evaluator-matrix", Evaluator::MATRIX}};. More...
 
- Protected Attributes inherited from InputSection
std::string section_name
 "Name" of the input section, you must define this in the subtype and the ename, name, type, or method must match. More...
 
std::vector< std::string > section_name_alternates
 For historical reasons some sections must recognize several different names. Assign them to this variable in your subtype. More...
 
std::unordered_set< std::string > attributes
 
std::unordered_set< std::string > parameters
 
std::unordered_set< std::string > delegates
 
std::unordered_set< std::string > required
 
std::unordered_set< std::string > multiple
 
std::unordered_set< std::string > strings
 
std::unordered_set< std::string > multi_strings
 
std::unordered_set< std::string > multi_reals
 
std::unordered_set< std::string > bools
 
std::unordered_set< std::string > integers
 
std::unordered_set< std::string > reals
 
std::unordered_set< std::string > positions
 
std::unordered_set< std::string > custom
 
std::unordered_set< std::string > enums
 list of enum inputs which allow a finite set of strings to map to enum values The enum class types and values need only be known to IS subtypes More...
 
std::unordered_map< std::string, std::any > default_values
 
std::unordered_map< std::string, std::function< std::any(xmlNodePtr cur, std::string &value_key)> > delegate_factories_
 
std::unordered_map< std::string, std::any > values_
 

Detailed Description

Definition at line 143 of file SpaceGridInput.h.

Constructor & Destructor Documentation

◆ SpaceGridInputSection() [1/2]

Definition at line 146 of file SpaceGridInput.h.

References InputSection::attributes, InputSection::delegates, InputSection::enums, SpaceGridInput::SpaceGridAxisInput::makeAxis(), SpaceGridInput::SpaceGridOriginInput::makeOrigin(), InputSection::multiple, InputSection::registerDelegate(), and InputSection::section_name.

147  {
148  section_name = "SpaceGrid";
149  attributes = {"coord"};
150  enums = {"coord"};
151  delegates = {"origin", "axis"};
152  multiple = {"axis"};
155  }
static std::any makeAxis(xmlNodePtr cur, std::string &value_label)
std::unordered_set< std::string > delegates
Definition: InputSection.h:64
std::unordered_set< std::string > attributes
Definition: InputSection.h:62
static std::any makeOrigin(xmlNodePtr cur, std::string &value_label)
std::unordered_set< std::string > multiple
Definition: InputSection.h:66
void registerDelegate(const std::string &tag, DelegateHandler delegate_handler)
register factory function for delegate input
std::string section_name
"Name" of the input section, you must define this in the subtype and the ename, name, type, or method must match.
Definition: InputSection.h:57
std::unordered_set< std::string > enums
list of enum inputs which allow a finite set of strings to map to enum values The enum class types an...
Definition: InputSection.h:78

◆ SpaceGridInputSection() [2/2]

SpaceGridInputSection ( const SpaceGridInputSection sgis)
default

Member Function Documentation

◆ assignAnyEnum()

std::any assignAnyEnum ( const std::string &  tag) const
overridevirtual

Derived class overrides this to get proper assignment of scoped enum values.

In most cases all you'll need it to define the map and write: std::any DerivedInputSection::assignAnyEnum(const std::string& name) const { return lookupAnyEnum(name, get<std::string>(name), derived_input_lookup_enum); }

See test_InputSection.cpp and OneBodyDensityMatricesInput You really should do this if your input class has a finite set of string values for an input example: OneBodyDensityMatricesInput

can't be bothered then just define your enum option as a string.

Reimplemented from InputSection.

Definition at line 138 of file SpaceGridInput.cpp.

References SpaceGridInput::lookup_input_enum_value.

139 {
140  return lookupAnyEnum(name, get<std::string>(name), lookup_input_enum_value);
141 }
static const std::unordered_map< std::string, std::any > lookup_input_enum_value
static std::any lookupAnyEnum(const std::string &enum_name, const std::string &enum_value, const std::unordered_map< std::string, std::any > &enum_map)
Assign any enum helper for InputSection derived class assumes enum lookup table of this form: inline ...

◆ checkParticularValidity()

void checkParticularValidity ( )
overridevirtual

Do validation for a particular subtype of InputSection Called by check_valid.

Default implementation is noop The InputSection subtype should make all correctness checks reasonable at parse time.

Reimplemented from InputSection.

Definition at line 150 of file SpaceGridInput.cpp.

References error(), qmcplusplus::is_same(), and OHMMS_DIM.

151 {
152  auto axes = std::any_cast<std::vector<std::any>>(values_["axis"]);
153  static_assert(std::is_same<decltype(axes), std::vector<std::any>>::value);
154  auto axis_count = axes.size();
155  if (axis_count != OHMMS_DIM)
156  {
157  std::ostringstream error;
158  error << "SpaceGrid input must contain " << OHMMS_DIM << " axes, " << axis_count << " found!";
159  throw UniformCommunicateError(error.str());
160  }
161 }
bool is_same(const xmlChar *a, const char *b)
#define OHMMS_DIM
Definition: config.h:64
void error(char const *m)
Definition: Standard.h:204
std::unordered_map< std::string, std::any > values_
Definition: InputSection.h:83

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