1 #ifndef CASM_NeighborList_HH
2 #define CASM_NeighborList_HH
14 class PrimNeighborList {
28 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
33 typedef std::set<UnitCell, std::function<bool (UnitCell, UnitCell)> >
NeighborSet;
41 template<
typename SublatIterator>
52 template<
typename UnitCellCoordIterator>
53 void expand(UnitCellCoordIterator
begin, UnitCellCoordIterator
end);
56 size_type
size()
const;
59 const_iterator
begin()
const;
62 const_iterator
end()
const;
65 const_iterator
cbegin()
const;
68 const_iterator
cend()
const;
77 std::unique_ptr<PrimNeighborList>
clone()
const;
82 void _expand(Scalar prev_range);
94 static bool _compare_vec(
const VectorXType &A,
const VectorXType &B);
154 std::unique_ptr<SuperNeighborList>
clone()
const;
168 std::vector< std::vector<size_type> >
m_site;
187 template<
typename SublatIterator>
192 m_sublat_indices(begin, end) {
195 Eigen::LLT<Eigen::MatrixXd> llt(W.cast<
double>());
196 if(llt.info() != Eigen::Success) {
197 std::cerr <<
"Error constructing PrimNeighborList: weight matrix is not positive definite." << std::endl;
198 std::cerr <<
"weight matrix: \n" << W << std::endl;
199 throw std::runtime_error(
"Error constructing PrimNeighborList: weight matrix is not positive definite.");
220 template<
typename UnitCellCoordIterator>
226 bool any_new =
false;
227 for(
auto it = begin; it !=
end; ++it) {
const SublatIndices & sublat_indices() const
pair of const_iterators over a range of indices of sublattices to include
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef Index Scalar
size_type m_prim_grid_size
store prim grid size for site index -> unitcell index conversion unitcell_index = site_index % m_prim...
Scalar _dist(const UnitCell &A) const
Calculate A.transpose()*M*A.
std::unique_ptr< PrimNeighborList > clone() const
Clone.
std::unique_ptr< SuperNeighborList > clone() const
Clone.
const_iterator cend() const
const_iterator over the neighborhood of unit cells
Scalar m_range
the neighborhood, m_neighborhood, contains all UnitCell with r <= m_range
const_iterator cbegin() const
const_iterator over the neighborhood of unit cells
std::vector< std::vector< size_type > > m_unitcell
m_unitcell[unitcell_index][neighbor unitcell index]
NeighborSet::size_type size_type
NeighborSet::const_iterator const_iterator
void expand(UnitCellCoord uccoord)
Expand the neighbor list to include the given UnitCellCoord.
bool _compare_unitcell(const UnitCell &A, const UnitCell &B) const
Convert [i,j,k] -> [r,i,j,k] and then lexicographically compare.
SuperNeighborList(const PrimGrid &prim_grid, const PrimNeighborList &prim_nlist)
Constructor.
The SuperNeighborList gives the linear indices of neighboring sites and unitcells in a particular Sup...
Matrix3Type m_W
Weighting matrix.
void _expand(Scalar prev_range)
Ensure that all intermediate UnitCell are included in our neighborhood.
static bool _compare_vec(const VectorXType &A, const VectorXType &B)
Lexicographical comparison.
Eigen::Matrix< long, Eigen::Dynamic, 1 > VectorXType
NeighborSet m_neighborhood
the neighborhood of [i, j, k]
std::vector< std::vector< size_type > > m_site
m_site[unitcell_index][neighbor site index]
const std::vector< size_type > & unitcells(size_type unitcell_index) const
const Access the list of unitcells neighboring a particular unit cell
EigenIndex Index
For long integer indexing:
VectorXType _add_dist(const UnitCell &A) const
Return [r, i, j, k], where r = _dist(A)
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.
std::set< UnitCell, std::function< bool(UnitCell, UnitCell)> > NeighborSet
size_type size() const
size of the neighborhood of unit cells
The PrimNeighborList gives the coordinates of UnitCell that are neighbors of the origin UnitCell...
std::set< int > SublatIndices
SublatIndices m_sublat_indices
the indices of sublattices that should be included
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 unit cell index from site index
bool overlaps() const
Returns true if periodic images of the neighbor list overlap.
const_iterator begin() const
const_iterator over the neighborhood of unit cells
Matrix< long int, 3, 3 > Matrix3l
const std::vector< size_type > & sites(size_type unitcell_index) const
const Access the list of sites neighboring a particular unit cell
Eigen::MatrixXd m_Uinv
Cholesky decomposition: W = U.transpose()*U, useful for getting bounding box.
Matrix3Type weight_matrix() const
Return the weighting matrix W used to define the canonical order.
Eigen::Matrix3l Matrix3Type
size_type sublat_index(size_type site_index) const
get sublat index from site index
const_iterator end() const
const_iterator over the neighborhood of unit cells