Classes | Namespaces | Macros | Functions | Variables
vesin.cpp File Reference
#include "vesin.h"
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <tuple>
#include <new>
#include <vector>
#include <array>
#include <cmath>
#include <stdexcept>
#include <string>

Classes

class  PLMD::metatensor::vesin::BoundingBox
 
struct  PLMD::metatensor::vesin::cpu::CellList::Cell
 
class  PLMD::metatensor::vesin::cpu::CellList
 The cell list is used to sort atoms inside bins/cells. More...
 
struct  PLMD::metatensor::vesin::CellShift
 A cell shift represents the displacement along cell axis between the actual position of an atom and a periodic image of this atom. More...
 
class  PLMD::metatensor::vesin::cpu::GrowableNeighborList
 Wrapper around VesinNeighborList that behaves like a std::vector, automatically growing memory allocations. More...
 
struct  PLMD::metatensor::vesin::Matrix
 
struct  PLMD::metatensor::vesin::cpu::CellList::Point
 the cells themselves are a list of points & corresponding shift to place the point inside the cell More...
 
struct  PLMD::metatensor::vesin::Vector
 

Namespaces

 PLMD
 
 PLMD::metatensor
 
 PLMD::metatensor::vesin
 
 PLMD::metatensor::vesin::cpu
 

Macros

#define MAX_NUMBER_OF_CELLS   1e5
 Maximal number of cells, we need to use this to prevent having too many cells with a small bounding box and a large cutoff. More...
 
#define VESIN_CPU_CELL_LIST_HPP
 
#define VESIN_MATH_HPP
 
#define VESIN_TYPES_HPP
 

Functions

template<typename scalar_t >
static scalar_t * alloc (scalar_t *ptr, size_t size, size_t new_size)
 
template<typename scalar_t , size_t N>
static scalar_t(* alloc (scalar_t(*ptr)[N], size_t size, size_t new_size))[N]
 
static std::tuple< int32_t, int32_t > divmod (int32_t a, size_t b)
 Function to compute both quotient and remainder of the division of a by b. More...
 
static std::tuple< std::array< int32_t, 3 >, std::array< int32_t, 3 > > divmod (std::array< int32_t, 3 > a, std::array< size_t, 3 > b)
 Apply the divmod function to three components at the time. More...
 
void PLMD::metatensor::vesin::cpu::free_neighbors (VesinNeighborList &neighbors)
 
void PLMD::metatensor::vesin::cpu::neighbors (const Vector *points, size_t n_points, BoundingBox cell, VesinOptions options, VesinNeighborList &neighbors)
 
Vector PLMD::metatensor::vesin::operator* (double scalar, Vector vector)
 
Vector PLMD::metatensor::vesin::operator* (Matrix matrix, Vector vector)
 
Vector PLMD::metatensor::vesin::operator* (Vector vector, double scalar)
 
Vector PLMD::metatensor::vesin::operator* (Vector vector, Matrix matrix)
 
CellShift PLMD::metatensor::vesin::operator+ (CellShift a, CellShift b)
 
Vector PLMD::metatensor::vesin::operator+ (Vector u, Vector v)
 
CellShift PLMD::metatensor::vesin::operator- (CellShift a, CellShift b)
 
Vector PLMD::metatensor::vesin::operator- (Vector u, Vector v)
 
void vesin_free (VesinNeighborList *neighbors)
 Free all allocated memory inside a VesinNeighborList, according the it's device. More...
 
int vesin_neighbors (const double(*points)[3], size_t n_points, const double box[3][3], bool periodic, VesinDevice device, VesinOptions options, VesinNeighborList *neighbors, const char **error_message)
 Compute a neighbor list. More...
 

Variables

thread_local std::string LAST_ERROR
 

Macro Definition Documentation

◆ MAX_NUMBER_OF_CELLS

#define MAX_NUMBER_OF_CELLS   1e5

Maximal number of cells, we need to use this to prevent having too many cells with a small bounding box and a large cutoff.

◆ VESIN_CPU_CELL_LIST_HPP

#define VESIN_CPU_CELL_LIST_HPP

◆ VESIN_MATH_HPP

#define VESIN_MATH_HPP

◆ VESIN_TYPES_HPP

#define VESIN_TYPES_HPP

Function Documentation

◆ alloc() [1/2]

template<typename scalar_t >
static scalar_t* alloc ( scalar_t *  ptr,
size_t  size,
size_t  new_size 
)
static

◆ alloc() [2/2]

template<typename scalar_t , size_t N>
static scalar_t(* alloc ( scalar_t(*)  ptr[N],
size_t  size,
size_t  new_size 
) )[N]
static

◆ divmod() [1/2]

static std::tuple<int32_t, int32_t> divmod ( int32_t  a,
size_t  b 
)
static

Function to compute both quotient and remainder of the division of a by b.

This function follows Python convention, making sure the remainder have the same sign as b.

◆ divmod() [2/2]

static std::tuple<std::array<int32_t, 3>, std::array<int32_t, 3> > divmod ( std::array< int32_t, 3 >  a,
std::array< size_t, 3 >  b 
)
static

Apply the divmod function to three components at the time.

◆ vesin_free()

void vesin_free ( VesinNeighborList neighbors)

Free all allocated memory inside a VesinNeighborList, according the it's device.

◆ vesin_neighbors()

int vesin_neighbors ( const double(*)  points[3],
size_t  n_points,
const double  box[3][3],
bool  periodic,
VesinDevice  device,
struct VesinOptions  options,
struct VesinNeighborList neighbors,
const char **  error_message 
)

Compute a neighbor list.

The data is returned in a VesinNeighborList. For an initial call, the VesinNeighborList should be zero-initialized (or default-initalized in C++). The VesinNeighborList can be re-used across calls to this functions to re-use memory allocations, and once it is no longer needed, users should call vesin_free to release the corresponding memory.

Parameters
pointspositions of all points in the system;
n_pointsnumber of elements in the points array
boxbounding box for the system. If the system is non-periodic, this is ignored. This should contain the three vectors of the bounding box, one vector per row of the matrix.
periodicis the system using periodic boundary conditions?
devicedevice where the points and box data is allocated.
optionsoptions for the calculation
neighborsnon-NULL pointer to VesinNeighborList that will be used to store the computed list of neighbors.
error_messagePointer to a char* that wil be set to the error message if this function fails. This does not need to be freed when no longer needed.

Variable Documentation

◆ LAST_ERROR

thread_local std::string LAST_ERROR