QMCPACK
ReferencePointsInput.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 // Some code refactored from: ReferencePoints.h & ReferencePoints.cpp
10 //////////////////////////////////////////////////////////////////////////////////////
11 
12 #ifndef QMCPLUSPLUS_REFERNCE_POINTS_INPUT_H
13 #define QMCPLUSPLUS_REFERNCE_POINTS_INPUT_H
14 
15 #include <map>
16 #include <string>
17 #include <string_view>
18 
19 #include <Configuration.h>
20 #include <OhmmsPETE/Tensor.h>
21 #include <OhmmsPETE/TinyVector.h>
22 #include "InputSection.h"
23 
24 namespace qmcplusplus
25 {
26 namespace testing
27 {
28 template<typename T>
30 }
31 
32 class SpaceGrid;
33 
35 {
36 public:
37  using Real = double;
40  using Points = std::map<std::string, Point>;
41  enum class Coord
42  {
43  CELL,
44  CARTESIAN
45  };
46 
47  /** mapping for enumerated options of ReferencePointsInput
48  * This data object is the basis of input enum string values
49  * translation to native C++ scoped enums. This boiler plate is
50  * generated by utils/code_tools/qmcpack-elisp-generators.el
51  * qmcp-add-enum-string-map
52  *
53  * This plus the virtual assignAnyEnum method are needed by InputSection to
54  * validate and assign enum values from input.
55  *
56  * In testing code we assume this map is bidirectional.
57  */
58  inline static const std::unordered_map<std::string, std::any> lookup_input_enum_value{
59  {"coord-cell", Coord::CELL},
60  {"coord-cartesian", Coord::CARTESIAN},
61  };
62 
64  {
65  public:
67  {
68  section_name = "reference_points";
69  enums = {"coord"};
70  attributes = {"coord"};
71  required = {"coord"};
72  }
73  std::any assignAnyEnum(const std::string& name) const override;
75  };
76 
77  /** Unlike many input classes ReferencePointInputs needs a way to be constructured even if there is no input node.
78  * The ReferencePoints for a space grid are assumed to just be a default ReferencePoints with
79  * the same CoordType.
80  */
81  ReferencePointsInput() = default;
82 
83  ReferencePointsInput(xmlNodePtr cur);
84  ReferencePointsInput(const ReferencePointsInput& rpi) = default;
85 
86  Coord get_coord_form() const { return coord_form_; }
87  const Points& get_points() const { return points_; }
88 
89 private:
90  void readRefPointsXML(xmlNodePtr cur);
91  // As far as I can tell if not specified in input this is what is happening in legacy.
95  static constexpr std::string_view error_tag{"ReferencePointsInput input: "};
96 };
97 
98 /** factory function used by InputSection to make reference points Input
99  * \param[out] value_label key value in delegating InputSection for storing the constructed Input from processed node.
100  */
101 std::any makeReferencePointsInput(xmlNodePtr, std::string& value_label);
102 
103 extern template bool InputSection::setIfInInput<ReferencePointsInput::Coord>(ReferencePointsInput::Coord& var,
104  const std::string& tag);
105 } // namespace qmcplusplus
106 #endif
std::any assignAnyEnum(const std::string &name) const override
Derived class overrides this to get proper assignment of scoped enum values.
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
std::any makeReferencePointsInput(xmlNodePtr cur, std::string &value_label)
factory function used by InputSection to make reference points Input
static constexpr std::string_view error_tag
std::unordered_set< std::string > attributes
Definition: InputSection.h:62
ReferencePointsInput()=default
Unlike many input classes ReferencePointInputs needs a way to be constructured even if there is no in...
static const std::unordered_map< std::string, std::any > lookup_input_enum_value
mapping for enumerated options of ReferencePointsInput This data object is the basis of input enum st...
std::unordered_set< std::string > required
Definition: InputSection.h:65
std::map< std::string, Point > Points
ReferencePointsInputSection input_section_
Input section provides basic parsing and a uniform method of access to the raw parsed input...
Definition: InputSection.h:37
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