QMCPACK
ReferencePointsInput Class Reference
+ Collaboration diagram for ReferencePointsInput:

Classes

class  ReferencePointsInputSection
 

Public Types

enum  Coord { CELL, CARTESIAN }
 
using Real = double
 
using Consumer = SpaceGrid
 
using Point = TinyVector< Real, OHMMS_DIM >
 
using Points = std::map< std::string, Point >
 

Public Member Functions

 ReferencePointsInput ()=default
 Unlike many input classes ReferencePointInputs needs a way to be constructured even if there is no input node. More...
 
 ReferencePointsInput (xmlNodePtr cur)
 
 ReferencePointsInput (const ReferencePointsInput &rpi)=default
 
Coord get_coord_form () const
 
const Pointsget_points () const
 

Static Public Attributes

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 string values translation to native C++ scoped enums. More...
 

Private Member Functions

void readRefPointsXML (xmlNodePtr cur)
 

Private Attributes

Coord coord_form_ = Coord::CELL
 
Points points_
 
ReferencePointsInputSection input_section_
 

Static Private Attributes

static constexpr std::string_view error_tag {"ReferencePointsInput input: "}
 

Detailed Description

Definition at line 34 of file ReferencePointsInput.h.

Member Typedef Documentation

◆ Consumer

Definition at line 38 of file ReferencePointsInput.h.

◆ Point

Definition at line 39 of file ReferencePointsInput.h.

◆ Points

using Points = std::map<std::string, Point>

Definition at line 40 of file ReferencePointsInput.h.

◆ Real

using Real = double

Definition at line 37 of file ReferencePointsInput.h.

Member Enumeration Documentation

◆ Coord

enum Coord
strong
Enumerator
CELL 
CARTESIAN 

Definition at line 41 of file ReferencePointsInput.h.

42  {
43  CELL,
44  CARTESIAN
45  };

Constructor & Destructor Documentation

◆ ReferencePointsInput() [1/3]

ReferencePointsInput ( )
default

Unlike many input classes ReferencePointInputs needs a way to be constructured even if there is no input node.

The ReferencePoints for a space grid are assumed to just be a default ReferencePoints with the same CoordType.

◆ ReferencePointsInput() [2/3]

ReferencePointsInput ( xmlNodePtr  cur)

Definition at line 26 of file ReferencePointsInput.cpp.

References ReferencePointsInput::coord_form_, ReferencePointsInput::input_section_, LAMBDA_setIfInInput, ReferencePointsInput::readRefPointsXML(), and InputSection::readXML().

27 {
29  auto setIfInInput = LAMBDA_setIfInInput;
30  setIfInInput(coord_form_, "coord");
31  readRefPointsXML(cur);
32 }
#define LAMBDA_setIfInInput
If tag is present in input_secution set its variable.
void readXML(xmlNodePtr cur)
Read variable values (initialize) from XML input, call checkValid.
ReferencePointsInputSection input_section_

◆ ReferencePointsInput() [3/3]

ReferencePointsInput ( const ReferencePointsInput rpi)
default

Member Function Documentation

◆ get_coord_form()

Coord get_coord_form ( ) const
inline

◆ get_points()

const Points& get_points ( ) const
inline

◆ readRefPointsXML()

void readRefPointsXML ( xmlNodePtr  cur)
private

Definition at line 38 of file ReferencePointsInput.cpp.

References error(), ReferencePointsInput::error_tag, OHMMS_DIM, ReferencePointsInput::points_, qmcplusplus::modernstrutil::split(), qmcplusplus::split(), qmcplusplus::strip(), and qmcplusplus::modernstrutil::strip().

Referenced by ReferencePointsInput::ReferencePointsInput().

39 {
42 
43  // read refpoints values they are some sequence of value nodes
44  std::string node_str{XMLNodeString{cur}};
45  std::vector<std::string_view> lines = split(strip(node_str), "\n");
46  for (int i = 0; i < lines.size(); i++)
47  {
48  auto stripped_line = strip(lines[i]);
49  std::vector<std::string_view> tokens = split(stripped_line, " ");
50  if (tokens.size() != OHMMS_DIM + 1)
51  {
52  std::ostringstream error;
53  error << error_tag << "reference point has 4 entries, given " << tokens.size() << ": " << lines[i];
54  throw UniformCommunicateError(error.str());
55  }
56  else
57  {
58  Point rp;
59  for (int d = 0; d < OHMMS_DIM; d++)
60  {
61  try
62  {
63  rp[d] = std::stod(std::string(tokens[d + 1].begin(), tokens[d + 1].size()));
64  }
65  catch (const std::invalid_argument& ia)
66  {
67  throw UniformCommunicateError(ia.what());
68  }
69  }
70 
71  // This must be done in constructor of ReferencePoints
72  // rp = dot(crd, rp);
73  points_[std::string(tokens[0].begin(), tokens[0].size())] = rp;
74  }
75  }
76 }
TinyVector< Real, OHMMS_DIM > Point
std::string_view strip(const string_view s)
static constexpr std::string_view error_tag
#define OHMMS_DIM
Definition: config.h:64
std::string strip(const std::string &s)
Definition: string_utils.h:26
void error(char const *m)
Definition: Standard.h:204
std::vector< std::string > split(const std::string &s)
Definition: string_utils.h:57
convert xmlNode contents into a std::string
std::vector< std::string_view > split(const string_view s, const string_view delimiters)

Member Data Documentation

◆ coord_form_

◆ error_tag

constexpr std::string_view error_tag {"ReferencePointsInput input: "}
staticprivate

Definition at line 95 of file ReferencePointsInput.h.

Referenced by ReferencePointsInput::readRefPointsXML().

◆ input_section_

ReferencePointsInputSection input_section_
private

Definition at line 94 of file ReferencePointsInput.h.

Referenced by ReferencePointsInput::ReferencePointsInput().

◆ lookup_input_enum_value

const std::unordered_map<std::string, std::any> lookup_input_enum_value
inlinestatic
Initial value:
{
{"coord-cell", Coord::CELL},
{"coord-cartesian", Coord::CARTESIAN},
}

mapping for enumerated options of ReferencePointsInput This data object is the basis of input enum string values translation to native C++ scoped enums.

This boiler plate is generated by utils/code_tools/qmcpack-elisp-generators.el qmcp-add-enum-string-map

This plus the virtual assignAnyEnum method are needed by InputSection to validate and assign enum values from input.

In testing code we assume this map is bidirectional.

Definition at line 58 of file ReferencePointsInput.h.

Referenced by ReferencePointsInput::ReferencePointsInputSection::assignAnyEnum().

◆ points_

Points points_
private

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