QMCPACK
GeneralGrid Class Reference

General Grid inherets from Grid. More...

+ Inheritance diagram for GeneralGrid:
+ Collaboration diagram for GeneralGrid:

Public Member Functions

GridType Type () override
 Returns the type of the grid (in this case GENERAL) More...
 
int ReverseMap (double r) override
 Returns the index of the nearest point below r. More...
 
void Write (IOSectionClass &outSection) override
 
void Read (IOSectionClass &inSection) override
 
void Init (Array< double, 1 > &points)
 
 GeneralGrid ()
 Useless constructor. More...
 
- Public Member Functions inherited from Grid
double operator() (int i) const
 The i'th point in the grid. More...
 
double * data ()
 
Array< double, 1 > & Points ()
 
virtual ~Grid ()
 

Additional Inherited Members

- Public Attributes inherited from Grid
double Start
 First and last grid points. More...
 
double End
 
int NumPoints
 Number of points in the grid. More...
 
- Protected Attributes inherited from Grid
Array< double, 1 > grid
 Contains the grid points. More...
 

Detailed Description

General Grid inherets from Grid.

Definition at line 141 of file Grid.h.

Constructor & Destructor Documentation

◆ GeneralGrid()

GeneralGrid ( )
inline

Useless constructor.

Definition at line 196 of file Grid.h.

197  { /* Do nothing */
198  }

Member Function Documentation

◆ Init()

void Init ( Array< double, 1 > &  points)
inline

Definition at line 186 of file Grid.h.

References Grid::End, Grid::grid, Grid::NumPoints, Array< T, D, ALLOC >::resize(), Array< T, D, ALLOC >::size(), and Grid::Start.

187  {
188  NumPoints = points.size();
190  grid = points;
191  Start = grid(0);
192  End = grid(NumPoints - 1);
193  }
double Start
First and last grid points.
Definition: Grid.h:51
double End
Definition: Grid.h:51
void resize(const std::array< SIZET, D > &dims)
Resize the container.
Definition: OhmmsArray.h:65
size_t size() const
Definition: OhmmsArray.h:57
Array< double, 1 > grid
Contains the grid points.
Definition: Grid.h:47
int NumPoints
Number of points in the grid.
Definition: Grid.h:54

◆ Read()

void Read ( IOSectionClass inSection)
inlineoverridevirtual

Implements Grid.

Definition at line 178 of file Grid.h.

References Grid::End, Grid::grid, Grid::NumPoints, IOSectionClass::ReadVar(), Array< T, D, ALLOC >::size(), and Grid::Start.

179  {
180  assert(inSection.ReadVar("Points", grid));
181  Start = grid(0);
182  End = grid(grid.size() - 1);
183  NumPoints = grid.size();
184  }
double Start
First and last grid points.
Definition: Grid.h:51
double End
Definition: Grid.h:51
size_t size() const
Definition: OhmmsArray.h:57
Array< double, 1 > grid
Contains the grid points.
Definition: Grid.h:47
bool ReadVar(std::string name, T &var)
Template function which reads a variable in the present section into the passed-by-reference T variab...
Definition: IO.h:168
int NumPoints
Number of points in the grid.
Definition: Grid.h:54

◆ ReverseMap()

int ReverseMap ( double  r)
inlineoverridevirtual

Returns the index of the nearest point below r.

Implements Grid.

Definition at line 148 of file Grid.h.

References BLAS::done, Grid::grid, omptarget::min(), and Grid::NumPoints.

149  {
150  if (r <= grid(0))
151  return (0);
152  else if (r >= grid(NumPoints - 1))
153  return (NumPoints - 1);
154  else
155  {
156  int hi = NumPoints - 1;
157  int lo = 0;
158  bool done = false;
159  while (!done)
160  {
161  int i = (hi + lo) >> 1;
162  if (grid(i) > r)
163  hi = i;
164  else
165  lo = i;
166  done = (hi - lo) < 2;
167  }
168  return std::min(lo, NumPoints - 2);
169  }
170  }
T min(T a, T b)
constexpr double done
Definition: BLAS.hpp:48
Array< double, 1 > grid
Contains the grid points.
Definition: Grid.h:47
int NumPoints
Number of points in the grid.
Definition: Grid.h:54

◆ Type()

GridType Type ( )
inlineoverridevirtual

Returns the type of the grid (in this case GENERAL)

Implements Grid.

Definition at line 145 of file Grid.h.

References GENERAL.

145 { return (GENERAL); }
Definition: Grid.h:37

◆ Write()

void Write ( IOSectionClass outSection)
inlineoverridevirtual

Implements Grid.

Definition at line 172 of file Grid.h.

References Grid::grid, and IOSectionClass::WriteVar().

173  {
174  outSection.WriteVar("Points", grid);
175  outSection.WriteVar("Type", std::string("General"));
176  }
bool WriteVar(std::string name, T val)
Writes a variable under the current section.
Definition: IO.h:184
Array< double, 1 > grid
Contains the grid points.
Definition: Grid.h:47

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