QMCPACK
EstimatorManagerInput.h
Go to the documentation of this file.
1 //////////////////////////////////////////////////////////////////////////////////////
2 // This file is distributed under the University of Illinois/NCSA Open Source License.
3 // See LICENSE file in top directory for details.
4 //
5 // Copyright (c) 2022 QMCPACK developers.
6 //
7 // File developed by: Peter Doak, doakpw@ornl.gov, Oak Ridge National Laboratory
8 //
9 // File refactored from: EstimatorManagerNew.h
10 //////////////////////////////////////////////////////////////////////////////////////
11 
12 /** \file
13  * declares the list supported estimator input types and declares the input type for
14  * EstimatorManagerNew.
15  */
16 #ifndef QMCPLUSPLUS_ESIMATORMANAGERINPUT_H
17 #define QMCPLUSPLUS_ESIMATORMANAGERINPUT_H
18 
19 
21 #include <functional>
22 #include <vector>
23 #include <variant>
24 #include <libxml/tree.h>
25 
26 namespace qmcplusplus
27 {
28 
29 namespace testing
30 {
31 /** class to allow private method testing in unit tests
32  */
33 class EstimatorManagerInputTests;
34 } // namespace testing
35 
36 /** These are the estimator input types EstimatorManagerInput delegates to.
37  * We know all the estimator types at compile time and it is useful to have type safety for their usage.
38  * All input clasess must satisfy std::is_trivially_copyable..
39  */
40 class SpinDensityInput;
41 class MomentumDistributionInput;
42 class OneBodyDensityMatricesInput;
43 class SelfHealingOverlapInput;
44 class MagnetizationDensityInput;
45 class PerParticleHamiltonianLoggerInput;
46 using EstimatorInput = std::variant<std::monostate,
47  MomentumDistributionInput,
48  SpinDensityInput,
49  OneBodyDensityMatricesInput,
50  SelfHealingOverlapInput,
51  MagnetizationDensityInput,
53 using EstimatorInputs = std::vector<EstimatorInput>;
54 
55 /** The scalar esimtator inputs
56  */
57 class LocalEnergyInput;
58 class CSLocalEnergyInput;
60 using ScalarEstimatorInput = std::variant<std::monostate, LocalEnergyInput, CSLocalEnergyInput, RMCLocalEnergyInput>;
61 using ScalarEstimatorInputs = std::vector<ScalarEstimatorInput>;
62 
63 /** Input type for EstimatorManagerNew
64  * Parses Estimators level of input and and delegates child estimator nodes
65  * to appropriate estimator input class
66  * Will later provide access to estimator input instances for estimator construction.
67  */
69 {
70 public:
71  EstimatorManagerInput() = default;
76  // This constructor is for merging the global and local EstimatorManagerInput.
77  // but you could also merge more instances
78  EstimatorManagerInput(std::initializer_list<EstimatorManagerInput> emil);
79  EstimatorManagerInput(xmlNodePtr cur);
82 
83  /** read <estimators> node or (<estimator> node for legacy support)
84  * This can be done multiple times with <estimators> nodes
85  * or with <estimator> nodes to support deprecated bare <estimator> definitions
86  */
87  void readXML(xmlNodePtr cur);
88 
89  /** typed appending of already parsed inputs.
90  * only used in testing.
91  */
92  void append(const EstimatorInput& ei);
93  void append(const ScalarEstimatorInput& sei);
94 private:
95  /// this is a vector of variants for typesafe access to the estimator inputs
98 
99  template<typename T>
100  void appendEstimatorInput(xmlNodePtr node)
101  {
102  estimator_inputs_.emplace_back(std::in_place_type<T>, node);
103  }
104 
105  template<typename T>
107  {
108  scalar_estimator_inputs_.emplace_back(std::in_place_type<T>, node);
109  }
110 
112 };
113 
114 } // namespace qmcplusplus
115 
116 #endif
ScalarEstimatorInputs & get_scalar_estimator_inputs()
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
EstimatorManagerInput & operator=(const EstimatorManagerInput &emi)=default
if(!okay) throw std xmlNodePtr node
void readXML(xmlNodePtr cur)
read <estimators> node or (<estimator> node for legacy support) This can be done multiple times with ...
void appendScalarEstimatorInput(xmlNodePtr node)
EstimatorManagerInput emi(estimators_doc.getRoot())
std::vector< EstimatorInput > EstimatorInputs
void append(const EstimatorInput &ei)
typed appending of already parsed inputs.
EstimatorInputs estimator_inputs_
this is a vector of variants for typesafe access to the estimator inputs
ScalarEstimatorInputs scalar_estimator_inputs_
std::variant< std::monostate, MomentumDistributionInput, SpinDensityInput, OneBodyDensityMatricesInput, SelfHealingOverlapInput, MagnetizationDensityInput, PerParticleHamiltonianLoggerInput > EstimatorInput
std::vector< ScalarEstimatorInput > ScalarEstimatorInputs
Input type for EstimatorManagerNew Parses Estimators level of input and and delegates child estimator...
std::variant< std::monostate, LocalEnergyInput, CSLocalEnergyInput, RMCLocalEnergyInput > ScalarEstimatorInput