QMCPACK
EstimatorManagerInput Class Reference

Input type for EstimatorManagerNew Parses Estimators level of input and and delegates child estimator nodes to appropriate estimator input class Will later provide access to estimator input instances for estimator construction. More...

+ Collaboration diagram for EstimatorManagerInput:

Public Member Functions

 EstimatorManagerInput ()=default
 
 EstimatorManagerInput (const EstimatorManagerInput &emi)=default
 
 EstimatorManagerInput (EstimatorManagerInput &&emi)=default
 
EstimatorManagerInputoperator= (const EstimatorManagerInput &emi)=default
 
EstimatorManagerInputoperator= (EstimatorManagerInput &&emi)=default
 
 EstimatorManagerInput (std::initializer_list< EstimatorManagerInput > emil)
 
 EstimatorManagerInput (xmlNodePtr cur)
 
EstimatorInputsget_estimator_inputs ()
 
ScalarEstimatorInputsget_scalar_estimator_inputs ()
 
void readXML (xmlNodePtr cur)
 read <estimators> node or (<estimator> node for legacy support) This can be done multiple times with <estimators> nodes or with <estimator> nodes to support deprecated bare <estimator> definitions More...
 
void append (const EstimatorInput &ei)
 typed appending of already parsed inputs. More...
 
void append (const ScalarEstimatorInput &sei)
 

Private Member Functions

template<typename T >
void appendEstimatorInput (xmlNodePtr node)
 
template<typename T >
void appendScalarEstimatorInput (xmlNodePtr node)
 

Private Attributes

EstimatorInputs estimator_inputs_
 this is a vector of variants for typesafe access to the estimator inputs More...
 
ScalarEstimatorInputs scalar_estimator_inputs_
 

Friends

class testing::EstimatorManagerInputTests
 

Detailed Description

Input type for EstimatorManagerNew Parses Estimators level of input and and delegates child estimator nodes to appropriate estimator input class Will later provide access to estimator input instances for estimator construction.

Definition at line 68 of file EstimatorManagerInput.h.

Constructor & Destructor Documentation

◆ EstimatorManagerInput() [1/5]

EstimatorManagerInput ( )
default

◆ EstimatorManagerInput() [2/5]

EstimatorManagerInput ( const EstimatorManagerInput emi)
default

◆ EstimatorManagerInput() [3/5]

◆ EstimatorManagerInput() [4/5]

EstimatorManagerInput ( std::initializer_list< EstimatorManagerInput emil)

Definition at line 21 of file EstimatorManagerInput.cpp.

References copy(), qmcplusplus::emi(), EstimatorManagerInput::estimator_inputs_, and EstimatorManagerInput::scalar_estimator_inputs_.

22 {
23  // \todo the following code fusing two vectors can be written in more consice way with std::back_inserter. See history.
24  // Right now needs to use a clumsy way to make intel classic compiler 19.1.x happy when using gcc 9 on some OS distros.
25  size_t est_offset = 0;
26  size_t scalar_est_offset = 0;
27  for (const EstimatorManagerInput& emi : emil)
28  {
29  est_offset += emi.estimator_inputs_.size();
30  scalar_est_offset += emi.scalar_estimator_inputs_.size();
31  }
32  estimator_inputs_.resize(est_offset);
33  scalar_estimator_inputs_.resize(scalar_est_offset);
34 
35  est_offset = 0;
36  scalar_est_offset = 0;
37  for (const EstimatorManagerInput& emi : emil)
38  {
39  std::copy(emi.estimator_inputs_.begin(), emi.estimator_inputs_.end(), estimator_inputs_.begin() + est_offset);
40  est_offset += emi.estimator_inputs_.size();
42  scalar_estimator_inputs_.begin() + scalar_est_offset);
43  scalar_est_offset += emi.scalar_estimator_inputs_.size();
44  }
45 }
EstimatorManagerInput emi(estimators_doc.getRoot())
void copy(const Array< T1, 3 > &src, Array< T2, 3 > &dest)
Definition: Blitz.h:639
EstimatorInputs estimator_inputs_
this is a vector of variants for typesafe access to the estimator inputs
ScalarEstimatorInputs scalar_estimator_inputs_

◆ EstimatorManagerInput() [5/5]

EstimatorManagerInput ( xmlNodePtr  cur)

Definition at line 19 of file EstimatorManagerInput.cpp.

References EstimatorManagerInput::readXML().

19 { readXML(cur); }
void readXML(xmlNodePtr cur)
read <estimators> node or (<estimator> node for legacy support) This can be done multiple times with ...

Member Function Documentation

◆ append() [1/2]

void append ( const EstimatorInput ei)

typed appending of already parsed inputs.

only used in testing.

Definition at line 113 of file EstimatorManagerInput.cpp.

References EstimatorManagerInput::estimator_inputs_.

Referenced by qmcplusplus::TEST_CASE().

113 { estimator_inputs_.emplace_back(ei); }
EstimatorInputs estimator_inputs_
this is a vector of variants for typesafe access to the estimator inputs

◆ append() [2/2]

void append ( const ScalarEstimatorInput sei)

Definition at line 114 of file EstimatorManagerInput.cpp.

References EstimatorManagerInput::scalar_estimator_inputs_.

114 { scalar_estimator_inputs_.emplace_back(sei); }
ScalarEstimatorInputs scalar_estimator_inputs_

◆ appendEstimatorInput()

void appendEstimatorInput ( xmlNodePtr  node)
inlineprivate

Definition at line 100 of file EstimatorManagerInput.h.

References EstimatorManagerInput::estimator_inputs_, and qmcplusplus::node.

Referenced by EstimatorManagerInputTests::testAppendFromXML().

101  {
102  estimator_inputs_.emplace_back(std::in_place_type<T>, node);
103  }
if(!okay) throw std xmlNodePtr node
EstimatorInputs estimator_inputs_
this is a vector of variants for typesafe access to the estimator inputs

◆ appendScalarEstimatorInput()

void appendScalarEstimatorInput ( xmlNodePtr  node)
inlineprivate

Definition at line 106 of file EstimatorManagerInput.h.

References qmcplusplus::node, and EstimatorManagerInput::scalar_estimator_inputs_.

107  {
108  scalar_estimator_inputs_.emplace_back(std::in_place_type<T>, node);
109  }
if(!okay) throw std xmlNodePtr node
ScalarEstimatorInputs scalar_estimator_inputs_

◆ get_estimator_inputs()

EstimatorInputs& get_estimator_inputs ( )
inline

Definition at line 80 of file EstimatorManagerInput.h.

References EstimatorManagerInput::estimator_inputs_.

Referenced by EstimatorManagerNew::EstimatorManagerNew(), and qmcplusplus::TEST_CASE().

80 { return estimator_inputs_; }
EstimatorInputs estimator_inputs_
this is a vector of variants for typesafe access to the estimator inputs

◆ get_scalar_estimator_inputs()

ScalarEstimatorInputs& get_scalar_estimator_inputs ( )
inline

◆ operator=() [1/2]

EstimatorManagerInput& operator= ( const EstimatorManagerInput emi)
default

◆ operator=() [2/2]

EstimatorManagerInput& operator= ( EstimatorManagerInput &&  emi)
default

◆ readXML()

void readXML ( xmlNodePtr  cur)

read <estimators> node or (<estimator> node for legacy support) This can be done multiple times with <estimators> nodes or with <estimator> nodes to support deprecated bare <estimator> definitions

Definition at line 47 of file EstimatorManagerInput.cpp.

References qmcplusplus::app_summary(), qmcplusplus::app_warning(), castXMLCharToChar(), getXMLAttributeValue(), and qmcplusplus::lowerCase().

Referenced by EstimatorManagerInput::EstimatorManagerInput().

48 {
49  const std::string error_tag{"EstimatorManager input:"};
50  std::string cur_name{lowerCase(castXMLCharToChar(cur->name))};
51  xmlNodePtr child;
52  if (cur_name == "estimators")
53  child = cur->xmlChildrenNode;
54  else
55  child = cur; // the case when 'estimator's are not encapsulated by a 'estimators' node
56  while (child != NULL)
57  {
58  std::string cname{lowerCase(castXMLCharToChar(child->name))};
59  if (cname == "estimator")
60  {
61  std::string atype(lowerCase(getXMLAttributeValue(child, "type")));
62  std::string aname(lowerCase(getXMLAttributeValue(child, "name")));
63  if (atype.empty() && !aname.empty())
64  atype = aname;
65  if (aname.empty() && !atype.empty())
66  aname = atype;
67  if (atype == "localenergy" || atype == "elocal")
68  appendScalarEstimatorInput<LocalEnergyInput>(child);
69  else if (atype == "cslocalenergy")
70  {
71  appendScalarEstimatorInput<CSLocalEnergyInput>(child);
72  app_warning() << "CSLocalEnergyEstimator support is at best experimental with batch drivers" << std::endl;
73  }
74  else if (atype == "rmc")
75  {
76  appendScalarEstimatorInput<RMCLocalEnergyInput>(child);
77  app_warning() << "RMCLocalEnergyEstimator support is at best experimental with batch drivers" << std::endl;
78  }
79  else if (atype == "onebodydensitymatrices")
80  appendEstimatorInput<OneBodyDensityMatricesInput>(child);
81  else if (atype == "spindensity")
82  appendEstimatorInput<SpinDensityInput>(child);
83  else if (atype == "momentumdistribution")
84  appendEstimatorInput<MomentumDistributionInput>(child);
85  else if (atype == "selfhealingoverlap")
86  appendEstimatorInput<SelfHealingOverlapInput>(child);
87  else if (atype == "perparticlehamiltonianlogger")
88  appendEstimatorInput<PerParticleHamiltonianLoggerInput>(child);
89  else if (atype == "magnetizationdensity")
90  appendEstimatorInput<MagnetizationDensityInput>(child);
91  else
92  throw UniformCommunicateError(error_tag + "unparsable <estimator> node, name: " + aname + " type: " + atype +
93  " in Estimators input.");
94  }
95  else if (cname != "text")
96  {
97  std::string atype(lowerCase(getXMLAttributeValue(child, "type")));
98  std::string aname(lowerCase(getXMLAttributeValue(child, "name")));
99  throw UniformCommunicateError(error_tag + "<estimators> can only contain <estimator> nodes");
100  }
101 
102  if (cur_name == "estimators")
103  child = child->next;
104  else
105  {
106  app_summary() << "<estimator> nodes not contained in <estimators>...</estimators> is a deprecated input xml idiom"
107  << std::endl;
108  break;
109  }
110  }
111 }
std::ostream & app_warning()
Definition: OutputManager.h:69
std::ostream & app_summary()
Definition: OutputManager.h:63
std::string lowerCase(const std::string_view s)
++17
char * castXMLCharToChar(xmlChar *c)
assign a value from a node. Use specialization for classes.
Definition: libxmldefs.h:62
std::string getXMLAttributeValue(const xmlNodePtr cur, const std::string_view name)
get the value string for attribute name if name is unfound in cur you get an empty string back this i...

Friends And Related Function Documentation

◆ testing::EstimatorManagerInputTests

Definition at line 111 of file EstimatorManagerInput.h.

Member Data Documentation

◆ estimator_inputs_

EstimatorInputs estimator_inputs_
private

this is a vector of variants for typesafe access to the estimator inputs

Definition at line 96 of file EstimatorManagerInput.h.

Referenced by EstimatorManagerInput::append(), EstimatorManagerInput::appendEstimatorInput(), EstimatorManagerInput::EstimatorManagerInput(), and EstimatorManagerInput::get_estimator_inputs().

◆ scalar_estimator_inputs_


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