PSCF v1.5.0
SymmetryGroup.h
1#ifndef PSCF_SYMMETRY_GROUP_H
2#define PSCF_SYMMETRY_GROUP_H
3
4/*
5* Pscfatico - Simulation Package for Polymeric and Molecular Liquids
6*
7* Copyright 2015 - 2026, David Morse (morse012@um.edu) and co-authors
8* Distributed under the terms of the GNU General Public License.
9*/
10
11//#include <iostream>
12#include <vector>
13
14namespace Pscf {
15
34 template <class Symmetry>
36 {
37
38 public:
39
46
51
55 virtual ~SymmetryGroup() = default;
56
62
71 bool add(Symmetry& symmetry);
72
76 void makeCompleteGroup();
77
83 void clear();
84
91 const Symmetry* find(const Symmetry& symmetry) const;
92
96 const Symmetry& identity() const;
97
101 int size() const;
102
108 Symmetry& operator [] (int i);
109
115 const Symmetry& operator [] (int i) const;
116
125 bool operator == (SymmetryGroup<Symmetry> const & other) const;
126
135 bool operator != (SymmetryGroup<Symmetry> const & other) const;
136
140 bool isValid() const;
141
142 private:
143
144 // Array of symmetry elements
145 std::vector<Symmetry> elements_;
146
147 // Identity element
148 Symmetry identity_;
149
150 };
151
152
153 // Inline member function definitions
154
155 /*
156 * Return the current size of the group.
157 */
158 template <class Symmetry>
159 inline
161 { return elements_.size(); }
162
163 /*
164 * Return identity element.
165 */
166 template <class Symmetry>
167 inline
168 const Symmetry& SymmetryGroup<Symmetry>::identity() const
169 { return identity_; }
170
171 /*
172 * Element access operator (by reference).
173 */
174 template <class Symmetry>
175 inline
177 { return elements_[i]; }
178
179 /*
180 * Element access operator (by reference).
181 */
182 template <class Symmetry>
183 inline
184 const Symmetry& SymmetryGroup<Symmetry>::operator [] (int i) const
185 { return elements_[i]; }
186
187 #ifndef PSCF_SYMMETRY_GROUP_TPP
188 // Explicit instantiation declarations
189 template <int D> class SpaceSymmetry;
190 extern template class SymmetryGroup< SpaceSymmetry<1> >;
191 extern template class SymmetryGroup< SpaceSymmetry<2> >;
192 extern template class SymmetryGroup< SpaceSymmetry<3> >;
193 #endif
194
195}
196#endif
A SpaceSymmetry represents a crystallographic space group symmetry.
Class template for a group of elements.
bool operator!=(SymmetryGroup< Symmetry > const &other) const
Inequality operator.
const Symmetry & identity() const
Return a reference to the identity element.
void clear()
Remove all elements except the identity.
bool operator==(SymmetryGroup< Symmetry > const &other) const
Equality operator.
SymmetryGroup()
Default constructor.
virtual ~SymmetryGroup()=default
Destructor.
const Symmetry * find(const Symmetry &symmetry) const
Find a symmetry within a group.
Symmetry & operator[](int i)
Element access operator (by reference).
int size() const
Return number of elements in group (i.e., the order of the group).
SymmetryGroup< Symmetry > & operator=(const SymmetryGroup< Symmetry > &other)
Assignment operator.
bool add(Symmetry &symmetry)
Add a new element to the group.
void makeCompleteGroup()
Generate a complete group from the current elements.
PSCF package top-level namespace.