1 #ifndef CASM_NeighborList_HH
2 #define CASM_NeighborList_HH
18 using xtal::UnitCellCoord;
41 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
54 template <
typename SublatIterator>
69 template <
typename UnitCellCoordIterator>
70 void expand(UnitCellCoordIterator
begin, UnitCellCoordIterator
end);
94 Index max_element_value,
double tol);
102 template <
typename UnitCellCoordIterator>
104 UnitCellCoordIterator _end);
107 std::unique_ptr<PrimNeighborList>
clone()
const;
210 std::unique_ptr<SuperNeighborList>
clone()
const;
225 std::vector<std::vector<size_type> >
m_site;
243 template <
typename SublatIterator>
248 std::placeholders::_1,
std::placeholders::_2)),
250 m_sublat_indices(begin, end) {
252 Eigen::LLT<Eigen::MatrixXd> llt(W.cast<
double>());
253 if (llt.info() != Eigen::Success) {
254 std::cerr <<
"Error constructing PrimNeighborList: weight matrix is not "
257 std::cerr <<
"weight matrix: \n" << W << std::endl;
258 throw std::runtime_error(
259 "Error constructing PrimNeighborList: weight matrix is not positive "
283 template <
typename UnitCellCoordIterator>
285 UnitCellCoordIterator end) {
289 bool any_new =
false;
290 for (
auto it =
begin; it !=
end; ++it) {
291 any_new =
_expand(*it) || any_new;
304 template <
typename UnitCellCoordIterator>
306 UnitCellCoordIterator _begin, UnitCellCoordIterator _end) {
308 std::vector<Scalar> result;
309 std::transform(_begin, _end, std::back_inserter(result),
The PrimNeighborList gives the coordinates of UnitCell that are neighbors of the origin UnitCell.
bool _expand(UnitCell const &uc)
Expand the neighbor list to include the given UnitCell, but do not do additional updates returns true...
Scalar m_range
the neighborhood, m_neighborhood, contains all UnitCell with r <= m_range
std::vector< Scalar > neighbor_indices(UnitCellCoordIterator _begin, UnitCellCoordIterator _end)
Get neighborlist indices of a collection of UnitCells, stored in.
NeighborSet m_neighborhood
the neighborhood of [i, j, k]
Scalar _neighbor_index(UnitCellCoord const &_ucc) const
Get neighborlist index of UnitCellCoord.
Scalar _dist(const UnitCell &A) const
Calculate A.transpose()*M*A.
Scalar neighbor_index(UnitCellCoord const &_ucc)
Get neighborlist index of UnitCellCoord.
const_iterator cend() const
const_iterator over the neighborhood of unit cells
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef Index Scalar
std::unique_ptr< PrimNeighborList > clone() const
Clone.
void expand(UnitCell const &uc)
Expand the neighbor list to include the given UnitCellCoord.
const_iterator cbegin() const
const_iterator over the neighborhood of unit cells
size_type size() const
size of the neighborhood of unit cells
std::set< int > SublatIndices
std::set< UnitCell, std::function< bool(UnitCell, UnitCell)> > NeighborSet
const_iterator end() const
const_iterator over the neighborhood of unit cells
const_iterator begin() const
const_iterator over the neighborhood of unit cells
NeighborSet::size_type size_type
Eigen::MatrixXd m_Uinv
Cholesky decomposition: W = U.transpose()*U, useful for getting bounding box.
const SublatIndices & sublat_indices() const
pair of const_iterators over a range of indices of sublattices to include
SublatIndices m_sublat_indices
the indices of sublattices that should be included
bool _compare_unitcell(const UnitCell &A, const UnitCell &B) const
Convert [i,j,k] -> [r,i,j,k] and then lexicographically compare.
Matrix3Type m_W
Weighting matrix.
Matrix3Type weight_matrix() const
Return the weighting matrix W used to define the canonical order.
static bool _compare_vec(const VectorXType &A, const VectorXType &B)
Lexicographical comparison.
Eigen::Matrix< long, Eigen::Dynamic, 1 > VectorXType
Eigen::Matrix3l Matrix3Type
NeighborSet::const_iterator const_iterator
static Matrix3Type make_weight_matrix(const Eigen::Matrix3d lat_column_mat, Index max_element_value, double tol)
Returns a NeighborList weighting matrix appropriate for a particular lattice.
VectorXType _add_dist(const UnitCell &A) const
Return [r, i, j, k], where r = _dist(A)
PrimNeighborList(const Matrix3Type &W, SublatIterator begin, SublatIterator end)
Constructor, specifying the weighting matrix to use and the indices of sublattices to include.
size_type unitcell_index(size_type site_index) const
Get unitcell_index from site_index.
std::vector< std::vector< size_type > > m_site
m_site[unitcell_index][neighbor site index]
std::vector< std::vector< size_type > > m_unitcell
m_unitcell[unitcell_index][neighbor unitcell index]
size_type sublat_index(size_type site_index) const
Get sublattice index from site_index.
const std::vector< size_type > & unitcells(size_type unitcell_index) const
const Access the list of unitcells neighboring a particular unit cell
bool overlaps() const
Returns true if periodic images of the neighbor list overlap.
std::unique_ptr< SuperNeighborList > clone() const
Clone.
SuperNeighborList(Eigen::Matrix3l const &transformation_matrix_to_super, PrimNeighborList const &prim_nlist)
Constructor.
size_type m_prim_grid_size
store prim grid size for site index -> unitcell index conversion unitcell_index = site_index % m_prim...
const std::vector< size_type > & sites(size_type unitcell_index) const
const Access the list of sites neighboring a particular unit cell
INDEX_TYPE Index
For long integer indexing:
Matrix< long int, 3, 3 > Matrix3l