CASM
AClustersApproachtoStatisticalMechanics
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules
ConfigIsEquivalent.hh
Go to the documentation of this file.
1 #ifndef CASM_ConfigIsEquivalent
2 #define CASM_ConfigIsEquivalent
3 
5 
6 
7 namespace CASM {
8 
15  class ConfigIsEquivalent {
21 
22  public:
23 
24  typedef std::vector<ConfigDoFIsEquivalent> eq_container;
25 
26  ConfigIsEquivalent(const Configuration &_config, double _tol) :
27  m_config(&_config) {
28 
29  if(config().has_deformation()) {
30  m_global_eq.push_back(make_dof_is_equivalent<DoFIsEquivalent::Strain>(_config, _tol));
31  }
32 
33  if(config().has_occupation()) {
34  m_site_eq.push_back(make_dof_is_equivalent<DoFIsEquivalent::Occupation>(_config));
35  }
36 
37  if(config().has_displacement()) {
38  m_site_eq.push_back(make_dof_is_equivalent<DoFIsEquivalent::Displacement>(_config, _tol));
39  }
40  }
41 
42  const Configuration &config() const {
43  return *m_config;
44  }
45 
46  eq_container &global_eq() {
47  return m_global_eq;
48  }
49 
50  const eq_container &global_eq() const {
51  return m_global_eq;
52  }
53 
54  eq_container &site_eq() {
55  return m_site_eq;
56  }
57 
58  const eq_container &site_eq() const {
59  return m_site_eq;
60  }
61 
65  bool is_less() const {
66  return m_less;
67  }
68 
72  bool operator()(const Configuration &other) const {
73  if(&config() == &other) {
74  return true;
75  }
76 
77  for(const auto &g : global_eq()) {
78  // check if config == other, for this global DoF type
79  if(!g(other.configdof())) {
80  m_less = g.is_less();
81  return false;
82  }
83  }
84 
85  for(const auto &s : site_eq()) {
86  // check if config == other, for this site DoF type
87  if(!s(other.configdof())) {
88  m_less = s.is_less();
89  return false;
90  }
91  }
92 
93  return true;
94  }
95 
97  bool operator()(const PermuteIterator &A) const {
98  for(const auto &g : global_eq()) {
99  // check if config == other, for this global DoF type
100  if(!g(A)) {
101  m_less = g.is_less();
102  return false;
103  }
104  }
105 
106  for(const auto &s : site_eq()) {
107  // check if config == other, for this site DoF type
108  if(!s(A)) {
109  m_less = s.is_less();
110  return false;
111  }
112  }
113 
114  return true;
115  }
116 
118  bool operator()(const PermuteIterator &A, const PermuteIterator &B) const {
119 
120  if(A.factor_group_index() != B.factor_group_index()) {
121  for(const auto &g : global_eq()) {
122  // check if config == other, for this global DoF type
123  if(!g(A, B)) {
124  m_less = g.is_less();
125  return false;
126  }
127  }
128  }
129 
130  for(const auto &s : site_eq()) {
131  // check if config == other, for this site DoF type
132  if(!s(A, B)) {
133  m_less = s.is_less();
134  return false;
135  }
136  }
137 
138  return true;
139  }
140 
141  private:
142 
144  eq_container m_global_eq;
145  eq_container m_site_eq;
146  mutable bool m_less;
147  };
148 
150 }
151 
152 #endif
const eq_container & global_eq() const
const eq_container & site_eq() const
const ConfigDoF & configdof() const
const Access the DoF
Main CASM namespace.
Definition: complete.cpp:8
ConfigIsEquivalent(const Configuration &_config, double _tol)
bool operator()(const PermuteIterator &A, const PermuteIterator &B) const
Check if A*config == B*config, store A*config < B*config.
bool is_less() const
Returns less than comparison.
bool operator()(const Configuration &other) const
Check if config == other, store config < other.
bool operator()(const PermuteIterator &A) const
Check if config == A*config, store config < A*config.
Index factor_group_index() const
Return the index into m_factor_group_permute of the factor group op being pointed at...
std::vector< ConfigDoFIsEquivalent > eq_container
const Configuration * m_config
const Configuration & config() const
A Configuration represents the values of all degrees of freedom in a Supercell.