CASM  1.1.0
A Clusters Approach to Statistical Mechanics
Orbit.hh
Go to the documentation of this file.
1 #ifndef CASM_Orbit
2 #define CASM_Orbit
3 
4 #include <boost/iterator/transform_iterator.hpp>
5 #include <vector>
6 
8 #include "casm/misc/CASM_math.hh"
12 #include "casm/symmetry/SymOp.hh"
13 
14 namespace CASM {
15 class SymGroup;
16 
17 // -- Orbit -------------------------------------
18 
42 template <typename _SymCompareType>
43 class Orbit : public Comparisons<CRTPBase<Orbit<_SymCompareType>>> {
44  public:
45  using size_type = unsigned int;
46  using Element = typename _SymCompareType::Element;
47  using InvariantsType = typename _SymCompareType::InvariantsType;
48  using SymCompareType = _SymCompareType;
49  using const_iterator = typename std::vector<Element>::const_iterator;
50  using const_symop_iterator = typename std::vector<SymOp>::const_iterator;
51 
54  Orbit(Element generating_element, SymGroup const &generating_group,
56 
57  const_iterator begin() const { return m_element.cbegin(); }
58 
59  const_iterator end() const { return m_element.cend(); }
60 
61  const_iterator cbegin() const { return m_element.cbegin(); }
62 
63  const_iterator cend() const { return m_element.cend(); }
64 
65  size_type size() const { return m_element.size(); }
66 
68  const Element &prototype() const { return m_element[0]; }
69 
73  const Element &operator[](size_type index) const { return element(index); }
74 
78  const Element &element(size_type index) const { return m_element[index]; }
79 
83  const std::vector<Element> &elements() const { return m_element; }
84 
91  return m_equivalence_map;
92  }
93 
98  std::pair<const_symop_iterator, const_symop_iterator> equivalence_map(
99  size_type index) const {
100  return std::make_pair(m_equivalence_map[index].begin(),
101  m_equivalence_map[index].end());
102  }
103 
107  return m_canonization_rep_ID;
108  }
109 
114  const_iterator find(const Element &e) const {
115  return std::find_if(begin(), end(), [&](const Element &B) {
116  return m_sym_compare.equal(e, m_sym_compare.prepare(B));
117  });
118  }
119 
124  bool contains(const Element &e) const { return this->find(e) != end(); }
125 
127  const SymGroup &generating_group() const { return m_generating_group; }
128 
132  const SymCompareType &sym_compare() const { return m_sym_compare; }
133 
134  InvariantsType const &invariants() const { return m_invariants; }
135 
137  Orbit &apply_sym(const SymOp &op);
138 
140  bool operator<(const Orbit &B) const;
141 
142  private:
143  void _construct_canonization_rep() const;
144 
147  template <typename SymOpIterator>
148  void _construct(Element generating_element, SymOpIterator begin,
149  SymOpIterator end);
150 
154  std::vector<Element> m_element;
155 
159 
162 
166 
170 
173 };
174 
177 template <typename GeneratorIterator, typename SymCompareType,
178  typename OrbitOutputIterator>
179 OrbitOutputIterator make_orbits(GeneratorIterator gen_begin,
180  GeneratorIterator gen_end,
181  const SymGroup &generating_group,
182  const SymCompareType &sym_compare,
183  OrbitOutputIterator result) {
184  using OrbitType = typename OrbitOutputIterator::container_type::value_type;
185  for (; gen_begin != gen_end; ++gen_begin) {
186  *(result++) = OrbitType(*gen_begin, generating_group, sym_compare);
187  }
188  return result;
189 }
190 
191 // -- Orbit Helpers --------------------
192 
194 template <typename OrbitIterator, typename Element>
195 OrbitIterator find_orbit(OrbitIterator begin, OrbitIterator end, Element e);
196 
197 struct GetPrototype {
198  template <typename OrbitType>
199  typename OrbitType::Element const &operator()(const OrbitType &orbit) const {
200  return orbit.prototype();
201  }
202 };
203 
204 template <typename OrbitIterator>
206  boost::transform_iterator<GetPrototype, OrbitIterator>;
207 
209 template <typename OrbitIterator>
211  return boost::make_transform_iterator(orbit_it, GetPrototype());
212 }
213 
215  template <typename OrbitType>
216  typename OrbitType::InvariantsType const &operator()(
217  const OrbitType &orbit) const {
218  return orbit.invariants();
219  }
220 };
221 
222 template <typename OrbitIterator>
224  boost::transform_iterator<GetInvariants, OrbitIterator>;
225 
227 template <typename OrbitIterator>
229  return boost::make_transform_iterator(orbit_it, GetInvariants());
230 }
231 } // namespace CASM
232 
233 #endif
An Orbit of Element.
Definition: Orbit.hh:43
InvariantsType const & invariants() const
Definition: Orbit.hh:134
InvariantsType m_invariants
Orbit invariants.
Definition: Orbit.hh:172
const std::vector< Element > & elements() const
const Access vector of Element
Definition: Orbit.hh:83
Orbit(Element generating_element, SymGroup const &generating_group, SymCompareType const &sym_compare)
Construct an Orbit from a generating_element Element, using provided symmetry group.
Definition: Orbit_impl.hh:91
std::vector< Element > m_element
All symmetrically equivalent elements (excluding those that SymCompare equivalent)
Definition: Orbit.hh:154
void _construct_canonization_rep() const
Definition: Orbit_impl.hh:252
std::pair< const_symop_iterator, const_symop_iterator > equivalence_map(size_type index) const
Return the equivalence map for element[index].
Definition: Orbit.hh:98
const multivector< SymOp >::X< 2 > & equivalence_map() const
Return the equivalence map.
Definition: Orbit.hh:90
const_iterator begin() const
Definition: Orbit.hh:57
typename std::vector< SymOp >::const_iterator const_symop_iterator
Definition: Orbit.hh:50
const SymCompareType & sym_compare() const
Return the SymCompare functor reference.
Definition: Orbit.hh:132
Orbit & apply_sym(const SymOp &op)
Apply symmetry to Orbit.
Definition: Orbit_impl.hh:224
const_iterator end() const
Definition: Orbit.hh:59
const Element & prototype() const
Identical to element(0)
Definition: Orbit.hh:68
size_type size() const
Definition: Orbit.hh:65
multivector< SymOp >::X< 2 > m_equivalence_map
element(i) compares equivalent to prototype().copy_apply(m_equivalence_map[i][j]) for all j
Definition: Orbit.hh:158
SymGroup m_generating_group
Group used to generate the orbit.
Definition: Orbit.hh:161
const SymGroup & generating_group() const
Return the generating SymGroup.
Definition: Orbit.hh:127
const_iterator cbegin() const
Definition: Orbit.hh:61
const_iterator find(const Element &e) const
Find element in Orbit.
Definition: Orbit.hh:114
SymGroupRepID canonization_rep_ID() const
Return the canonization symmetry representation ID.
Definition: Orbit.hh:105
unsigned int size_type
Definition: Orbit.hh:45
typename _SymCompareType::InvariantsType InvariantsType
Definition: Orbit.hh:47
SymGroupRepID m_canonization_rep_ID
ID of symmetry representation that describes the effect of each SymOp with respect to the canonical e...
Definition: Orbit.hh:165
void _construct(Element generating_element, SymOpIterator begin, SymOpIterator end)
Construct an Orbit from a generating_element Element, using provided symmetry rep.
typename std::vector< Element >::const_iterator const_iterator
Definition: Orbit.hh:49
bool operator<(const Orbit &B) const
Compare orbits, using SymCompareType::inter_orbit_compare.
Definition: Orbit_impl.hh:246
const Element & element(size_type index) const
Equivalent to operator[](size_type index) const.
Definition: Orbit.hh:78
typename _SymCompareType::Element Element
Definition: Orbit.hh:46
SymCompareType m_sym_compare
Functor used to check compare Element, including symmetry rules, and make canonical forms.
Definition: Orbit.hh:169
_SymCompareType SymCompareType
Definition: Orbit.hh:48
bool contains(const Element &e) const
Check if element is in Orbit.
Definition: Orbit.hh:124
const_iterator cend() const
Definition: Orbit.hh:63
const Element & operator[](size_type index) const
Return Element at index, without bounds checking.
Definition: Orbit.hh:73
SymGroup is a collection of symmetry operations that satisfy the group property The symmetry operatio...
Definition: SymGroup.hh:42
Type-safe ID object for communicating and accessing Symmetry representation info.
bool empty() const
Returns true if SymGroupRepID has not been initialized with valid group_index or rep_index.
SymOp is the Coordinate representation of a symmetry operation it keeps fraction (FRAC) and Cartesian...
Definition: SymOp.hh:28
Main CASM namespace.
Definition: APICommand.hh:8
OrbitOutputIterator make_orbits(OrbitBranchSpecsIterator begin, OrbitBranchSpecsIterator end, const std::vector< IntegralClusterOrbitGenerator > &custom_generators, OrbitOutputIterator result, std::ostream &status)
Generate orbits of IntegralCluster using OrbitBranchSpecs.
OrbitIterator find_orbit(OrbitIterator begin, OrbitIterator end, Element e)
Find orbit containing an element in a range of Orbit.
Definition: Orbit_impl.hh:295
boost::transform_iterator< GetInvariants, OrbitIterator > InvariantsIterator
Definition: Orbit.hh:224
boost::transform_iterator< GetPrototype, OrbitIterator > PrototypeIterator
Definition: Orbit.hh:206
InvariantsIterator< OrbitIterator > invariants_iterator(OrbitIterator orbit_it)
Convert an Orbit iterator to an invariants iterator.
Definition: Orbit.hh:228
PrototypeIterator< OrbitIterator > prototype_iterator(OrbitIterator orbit_it)
Convert an Orbit iterator to a prototype iterator.
Definition: Orbit.hh:210
OrbitType::InvariantsType const & operator()(const OrbitType &orbit) const
Definition: Orbit.hh:216
OrbitType::Element const & operator()(const OrbitType &orbit) const
Definition: Orbit.hh:199
typename multivector_impl::multivector_tmp< T, N >::type X
Definition: multivector.hh:28
Implements other comparisons in terms of '<'.
Definition: Comparisons.hh:25