CASM  1.1.0
A Clusters Approach to Statistical Mechanics
CASM::xtal::UnitCellCoordIndexConverter Class Reference

#include <LinearIndexConverter.hh>

+ Inheritance diagram for CASM::xtal::UnitCellCoordIndexConverter:

Detailed Description

Converts back and forth between UnitCellCoord and its linear index, where the linear index is guaranteed to preserve order based on the sublattice index of the UnitCellCoord, and the Smith Normal Form of the UnitCell.

By default, the constructed index converter will always accept UnitCellCoord values that fall outside of the superlattice. When this happens, the given UnitCellCoord is brought into the superlattice using superlattice vector translations, and the index of the resulting UnitCellCoord is returned.

Definition at line 26 of file LinearIndexConverter.hh.

Public Types

typedef impl::OrderedLatticePointGenerator::matrix_type matrix_type
 

Public Member Functions

 UnitCellCoordIndexConverter (const matrix_type &transformation_matrix, int basis_sites_in_prim)
 
void never_bring_within ()
 
void always_bring_within ()
 
UnitCellCoord bring_within (const UnitCellCoord &bijk) const
 
const UnitCellCoordoperator() (Index ix) const
 Given the linear index, retreive the corresponding UnitCellCoord. More...
 
Index operator() (const UnitCellCoord &bijk) const
 
Index total_sites () const
 Returns the total number of sites within the superlattice. More...
 

Private Member Functions

void _throw_if_incompatible_index (Index ix) const
 Throws exception if the specified index is out of the allowed range. More...
 
void _throw_if_incompatible_bijk (const UnitCellCoord &bijk) const
 

Static Private Member Functions

static std::vector< UnitCellCoord_make_all_ordered_bijk_values (const impl::OrderedLatticePointGenerator &make_point, int basis_sites_in_prim)
 
static void _throw_if_bad_basis_sites_in_prim (int basis_sites_in_prim)
 

Private Attributes

std::vector< UnitCellCoordm_linear_index_to_bijk
 Convert from linear index to UnitCellCoord. More...
 
std::unordered_map< UnitCellCoord, Indexm_bijk_to_linear_index
 Convert from UnitCellCoord to linear index. More...
 
std::unordered_map< UnitCellCoord, Indexm_bijk_to_linear_index_outside_of_superlattice
 
int m_basis_sites_in_prim
 
bool m_automatically_bring_bijk_within
 
IntegralCoordinateWithin_f m_bring_within_f
 Functor to bring UnitCellCoord values back into the superlattice. More...
 

Member Typedef Documentation

◆ matrix_type

Constructor & Destructor Documentation

◆ UnitCellCoordIndexConverter()

CASM::xtal::UnitCellCoordIndexConverter::UnitCellCoordIndexConverter ( const matrix_type transformation_matrix,
int  basis_sites_in_prim 
)
inline

Initialize with the transformation that defines how to convert from the tiling unit (prim) to the superlattice, and the number of basis sites in the primitive cell

Definition at line 33 of file LinearIndexConverter.hh.

Member Function Documentation

◆ _make_all_ordered_bijk_values()

std::vector< UnitCellCoord > CASM::xtal::UnitCellCoordIndexConverter::_make_all_ordered_bijk_values ( const impl::OrderedLatticePointGenerator make_point,
int  basis_sites_in_prim 
)
staticprivate

Enumerates every possible UnitCellCoord and returns them in the expected order (blocks by basis site, with the Smith Normal Form order within each block

Definition at line 51 of file LinearIndexConverter.cc.

◆ _throw_if_bad_basis_sites_in_prim()

void CASM::xtal::UnitCellCoordIndexConverter::_throw_if_bad_basis_sites_in_prim ( int  basis_sites_in_prim)
staticprivate

Throws exception if the number of sites specified in the tiling unit is less than 1

Definition at line 11 of file LinearIndexConverter.cc.

◆ _throw_if_incompatible_bijk()

void CASM::xtal::UnitCellCoordIndexConverter::_throw_if_incompatible_bijk ( const UnitCellCoord bijk) const
private

Throws exception if the specified UnitCellCoord has a sublattice index that isn't compatible. If the state is set to not automatically bring the UnitCellCoord within the superlattice, then any UnitCellCoord outside the boundary will also trigger an exception

Definition at line 32 of file LinearIndexConverter.cc.

◆ _throw_if_incompatible_index()

void CASM::xtal::UnitCellCoordIndexConverter::_throw_if_incompatible_index ( Index  ix) const
private

Throws exception if the specified index is out of the allowed range.

Definition at line 22 of file LinearIndexConverter.cc.

◆ always_bring_within()

void CASM::xtal::UnitCellCoordIndexConverter::always_bring_within ( )

Automatically bring UnitCellCoord values within the supercell when querying for the index (on by default)

Definition at line 71 of file LinearIndexConverter.cc.

◆ bring_within()

UnitCellCoord CASM::xtal::UnitCellCoordIndexConverter::bring_within ( const UnitCellCoord bijk) const

Bring the given UnitCellCoord into the superlattice using lattice translations

Definition at line 75 of file LinearIndexConverter.cc.

◆ never_bring_within()

void CASM::xtal::UnitCellCoordIndexConverter::never_bring_within ( )

Prevent the index converter from bringing UnitCellCoord within the supercell when querying for the index

Definition at line 67 of file LinearIndexConverter.cc.

◆ operator()() [1/2]

Index CASM::xtal::UnitCellCoordIndexConverter::operator() ( const UnitCellCoord bijk) const

Given the UnitCellCoord, retreive its corresponding linear index. If applicable, brings the UnitCellCoord within the superlattice

Definition at line 88 of file LinearIndexConverter.cc.

◆ operator()() [2/2]

const UnitCellCoord & CASM::xtal::UnitCellCoordIndexConverter::operator() ( Index  ix) const

Given the linear index, retreive the corresponding UnitCellCoord.

Definition at line 83 of file LinearIndexConverter.cc.

◆ total_sites()

Index CASM::xtal::UnitCellCoordIndexConverter::total_sites ( ) const
inline

Returns the total number of sites within the superlattice.

Definition at line 73 of file LinearIndexConverter.hh.

Member Data Documentation

◆ m_automatically_bring_bijk_within

bool CASM::xtal::UnitCellCoordIndexConverter::m_automatically_bring_bijk_within
private

If set to true, UnitCellCoord values will be brought within the supercell before querying for the index

Definition at line 93 of file LinearIndexConverter.hh.

◆ m_basis_sites_in_prim

int CASM::xtal::UnitCellCoordIndexConverter::m_basis_sites_in_prim
private

How many blocks of "b", i.e. number of atoms in the primitive cell, as specified at construction

Definition at line 89 of file LinearIndexConverter.hh.

◆ m_bijk_to_linear_index

std::unordered_map<UnitCellCoord, Index> CASM::xtal::UnitCellCoordIndexConverter::m_bijk_to_linear_index
private

Convert from UnitCellCoord to linear index.

Definition at line 80 of file LinearIndexConverter.hh.

◆ m_bijk_to_linear_index_outside_of_superlattice

std::unordered_map<UnitCellCoord, Index> CASM::xtal::UnitCellCoordIndexConverter::m_bijk_to_linear_index_outside_of_superlattice
mutableprivate

Stores a cache of UnitCellCoord values that landed outside of the superlattice

Definition at line 85 of file LinearIndexConverter.hh.

◆ m_bring_within_f

IntegralCoordinateWithin_f CASM::xtal::UnitCellCoordIndexConverter::m_bring_within_f
private

Functor to bring UnitCellCoord values back into the superlattice.

Definition at line 96 of file LinearIndexConverter.hh.

◆ m_linear_index_to_bijk

std::vector<UnitCellCoord> CASM::xtal::UnitCellCoordIndexConverter::m_linear_index_to_bijk
private

Convert from linear index to UnitCellCoord.

Definition at line 77 of file LinearIndexConverter.hh.


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