CASM  1.1.0
A Clusters Approach to Statistical Mechanics
SymGroupRep.hh
Go to the documentation of this file.
1 #ifndef SYMGROUPREP_HH
2 #define SYMGROUPREP_HH
3 
4 #include <iomanip>
5 #include <iostream>
6 #include <string>
7 
9 #include "casm/misc/algorithm.hh"
11 #include "casm/symmetry/SymOp.hh"
12 
13 namespace CASM {
14 class SymGroupRep;
15 class MasterSymGroup;
16 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
17 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
18 
19 class SymGroupRepHandle;
20 
31 class SymGroupRep : public std::vector<SymOpRepresentation *> {
32  public:
33  friend class SymGroup;
34 
36 
40 
41  // No default construction allowed
42  SymGroupRep() = delete;
43 
44  SymGroupRep(const SymGroup &_head, SymGroupRepID _rep_ID = SymGroupRepID())
45  : m_rep_ID(_rep_ID), m_master_group(&_head.master_group()) {
46  if (has_valid_master())
47  resize(master_group().size(), nullptr);
48  else {
49  std::cerr << "WARNING: SymGroupRep initialized without valid "
50  "master_group! Bad things may happen!\n";
51  assert(0);
52  }
53  }
54 
59  : std::vector<SymOpRepresentation *>(_size, nullptr),
60  m_master_group(nullptr) {}
61 
65  SymGroupRep(const SymGroupRep &RHS);
66 
70  ~SymGroupRep();
71 
76  const MasterSymGroup &master_group() const {
77  assert(m_master_group);
78  return *m_master_group;
79  }
80 
82  Index dim() const { return MatrixXd(0)->cols(); }
83 
86  bool has_valid_master() const { return m_master_group != nullptr; }
87 
89  void set_master_group(const MasterSymGroup &master,
90  const SymGroupRepID &_rep_ID);
91 
97  void set_rep(Index op_index, const SymOpRepresentation &new_rep);
98 
107  void set_rep(const SymOpRepresentation &base_rep,
108  const SymOpRepresentation &new_rep);
109 
117  void set_rep(const SymOp &base_rep, const SymOpRepresentation &new_rep);
118 
122  SymGroupRep &operator=(const SymGroupRep &RHS);
123 
125  SymGroupRep *copy() const { return new SymGroupRep(*this); }
126 
130  Eigen::MatrixXd const *MatrixXd(Index i) const;
131 
136  Eigen::MatrixXd const *MatrixXd(const SymOpRepresentation &_op) const;
137 
141  Permutation const *permutation(Index i) const;
142 
147  Permutation const *permutation(const SymOpRepresentation &_op) const;
148 
151  SymGroupRepID symrep_ID() const { return m_rep_ID; }
152 
153  private:
154  void clear();
155 
158 
161 
162  using std::vector<SymOpRepresentation *>::push_back;
163  using std::vector<SymOpRepresentation *>::resize;
164 
167  SymGroupRep(const MasterSymGroup *_home) : m_master_group(_home) {}
168 };
169 
176 SymGroupRep coord_transformed_copy(SymGroupRep const &_rep,
177  const Eigen::MatrixXd &trans_mat);
178 
179 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
180 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
181 
185 class SymGroupRepHandle { // <-- typedefed as SymGroupRep::RemoteHandle
186 
189 
191  std::vector<Index> m_subgroup_op_inds;
192 
193  public:
195 
197  : m_group_rep(nullptr), m_subgroup_op_inds(head_group.op_indices()) {
198  if (head_group.size() == 0 || !head_group[0].has_valid_master()) {
199  std::cerr << "CRITICAL ERROR: Requested representation of an improperly "
200  "initialized SymGroup.\n"
201  << " Exiting...\n";
202  assert(0);
203  }
204  assert(!symrep_ID.empty());
205  m_group_rep = &(head_group[0].master_group().representation(symrep_ID));
206  assert(m_group_rep);
207  }
208 
210  Index size() const { return m_subgroup_op_inds.size(); }
211 
212  SymGroupRepID symrep_ID() const { return rep_ptr()->symrep_ID(); }
213 
215  Index dim() const {
216  return (m_group_rep->MatrixXd(m_subgroup_op_inds[0]))->cols();
217  }
218 
219  bool empty() const { return m_group_rep == nullptr; }
220 
221  SymGroupRep const *rep_ptr() const { return m_group_rep; }
222 
223  SymGroupRep const *operator->() const { return rep_ptr(); }
224 
230  return m_group_rep->at(m_subgroup_op_inds[i]);
231  }
232 
233  bool operator==(const SymGroupRepHandle &RHS) const {
234  return m_group_rep == RHS.m_group_rep &&
236  }
237 
238  void set_rep(const SymGroup &head_group, SymGroupRepID symrep_ID) {
239  m_subgroup_op_inds = head_group.op_indices();
240  assert(head_group.size() && !symrep_ID.empty() &&
241  head_group[0].has_valid_master());
242  m_group_rep = &(head_group[0].master_group().representation(symrep_ID));
243  assert(m_group_rep);
244  }
245 };
246 
248 } // namespace CASM
249 
250 #endif
SymGroupRep const & representation(SymGroupRepID i) const
Const access of alternate Representations of a SymGroup.
Definition: SymGroup.cc:717
SymGroup is a collection of symmetry operations that satisfy the group property The symmetry operatio...
Definition: SymGroup.hh:42
std::vector< Index > op_indices() const
Definition: SymGroup.cc:850
const MasterSymGroup & master_group() const
Definition: SymGroup.hh:73
SymGroupRepID symrep_ID() const
Definition: SymGroupRep.hh:212
Index dim() const
Matrix dimension of representation.
Definition: SymGroupRep.hh:215
SymGroupRep const * m_group_rep
Pointer to the SymGroupRep this is providing an interface to.
Definition: SymGroupRep.hh:188
void set_rep(const SymGroup &head_group, SymGroupRepID symrep_ID)
Definition: SymGroupRep.hh:238
SymGroupRepHandle(const SymGroup &head_group, SymGroupRepID symrep_ID)
Definition: SymGroupRep.hh:196
Index size() const
Size of the associated SymGroupRep.
Definition: SymGroupRep.hh:210
SymGroupRep const * operator->() const
Definition: SymGroupRep.hh:223
bool operator==(const SymGroupRepHandle &RHS) const
Definition: SymGroupRep.hh:233
std::vector< Index > m_subgroup_op_inds
MasterSymGroup indices of the operations in this SymGroupRep.
Definition: SymGroupRep.hh:191
SymOpRepresentation const * operator[](Index i) const
Definition: SymGroupRep.hh:229
SymGroupRep const * rep_ptr() const
Definition: SymGroupRep.hh:221
SymGroupRep is an alternative representation of a SymGroup for something other than real space....
Definition: SymGroupRep.hh:31
SymGroupRepID symrep_ID() const
Returns SymGroupRepID of this SymGroupRep in its master_group. If this is not contained in a master_g...
Definition: SymGroupRep.hh:151
SymGroupRep & operator=(const SymGroupRep &RHS)
explicit assignment operator Necessary because SymGroupRep directly manages heap-allocated SymOpRepre...
Definition: SymGroupRep.cc:30
const MasterSymGroup & master_group() const
Reference to MasterSymGroup for which this SymGroupRep is a group representation If a MasterSymGroup ...
Definition: SymGroupRep.hh:76
SymGroupRep * copy() const
Returns pointer to unmanaged copy of this SymGroupRep.
Definition: SymGroupRep.hh:125
~SymGroupRep()
explicit destructor Necessary because SymGroupRep directly manages heap-allocated SymOpRepresentation...
Definition: SymGroupRep.cc:26
SymGroupRep(const MasterSymGroup *_home)
Definition: SymGroupRep.hh:167
SymGroupRep(const SymGroup &_head, SymGroupRepID _rep_ID=SymGroupRepID())
Definition: SymGroupRep.hh:44
void set_rep(Index op_index, const SymOpRepresentation &new_rep)
Sets the representation of operation at entry 'op_index' of this group representation Throws if this ...
Definition: SymGroupRep.cc:114
SymGroupRepHandle RemoteHandle
Definition: SymGroupRep.hh:35
SymGroupRepID m_rep_ID
rep_ID is unique identifier of a specific SymGroupRep instantiation
Definition: SymGroupRep.hh:157
bool has_valid_master() const
Returns true if this SymGroupRep has valid pointer to a MasterSymGroup.
Definition: SymGroupRep.hh:86
Eigen::MatrixXd const * MatrixXd(Index i) const
pointer to MatrixXd corresponding to SymOpRepresentation at entry 'i' of this SymGroupRep Returns nul...
Definition: SymGroupRep.cc:144
Permutation const * permutation(Index i) const
pointer to Permutation corresponding to SymOpRepresentation at entry 'i' of this SymGroupRep Returns ...
Definition: SymGroupRep.cc:157
SymGroupRep()=delete
SymGroupRep(SymGroupRep::NullInitializer init, Index _size)
Standalone constructor Use this constructor when MasterSymGroup is unknown or doesn't exist Ex: SymGr...
Definition: SymGroupRep.hh:58
void set_master_group(const MasterSymGroup &master, const SymGroupRepID &_rep_ID)
Assign ma.
Definition: SymGroupRep.cc:47
MasterSymGroup const * m_master_group
Pointer to the home_group that generated this SymGroupRep.
Definition: SymGroupRep.hh:160
Index dim() const
Matrix dimension of representation.
Definition: SymGroupRep.hh:82
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
SymOpRepresentation is the base class for anything describes a symmetry operation.
Main CASM namespace.
Definition: APICommand.hh:8
Eigen::MatrixXd MatrixXd
SymGroupRep coord_transformed_copy(SymGroupRep const &_rep, const Eigen::MatrixXd &trans_mat)
Make a copy of representation on vector space 'V' that is transformed into a representation on vector...
Definition: SymGroupRep.cc:175
INDEX_TYPE Index
For long integer indexing:
Definition: definitions.hh:39
Definition: stream_io.hh:24