PSCF v1.5.0
SpaceGroup.h
1#ifndef PSCF_SPACE_GROUP_H
2#define PSCF_SPACE_GROUP_H
3
4/*
5* Simpatico - 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 <pscf/crystal/SpaceSymmetry.h>
12#include <pscf/crystal/SymmetryGroup.h>
13#include <pscf/math/IntVec.h>
14#include <util/containers/FSArray.h>
15#include <util/param/Label.h>
16#include <iostream>
17
18namespace Pscf {
19
20 using namespace Util;
21
29 template <int D>
30 class SpaceGroup : public SymmetryGroup< SpaceSymmetry<D> >
31 {
32
33 public:
34
44 bool
46 const;
47
59 void
60 shiftOrigin(typename SpaceSymmetry<D>::Translation const & origin);
61
92 void checkMeshDimensions(IntVec<D> const & dimensions) const;
93
94 // Using declarations for some inherited functions
95 using SymmetryGroup< SpaceSymmetry <D> >::size;
96
97 };
98
99 // Template function definition
100
108 template <int D>
109 std::ostream& operator << (std::ostream& out, SpaceGroup<D> const & g)
110 {
111 int size = g.size();
112 out << "dim " << D << std::endl;
113 out << "size " << size << std::endl;
114 for (int i = 0; i < size; ++i) {
115 out << std::endl;
116 out << g[i];
117 }
118 return out;
119 }
120
129 template <int D>
130 std::istream& operator >> (std::istream& in, SpaceGroup<D>& g)
131 {
132 int dim, size;
133 in >> Label("dim") >> dim;
134 UTIL_CHECK(D == dim);
135 in >> Label("size") >> size;
136
138 g.clear();
139 for (int i = 0; i < size; ++i) {
140 in >> s;
141 g.add(s);
142 }
143 return in;
144 }
145
154 template <int D>
155 void readGroup(std::string groupName, SpaceGroup<D>& group);
156
165 template <int D>
166 void writeGroup(std::string filename, SpaceGroup<D> const & group);
167
168 // Explicit instantiation declarations
169 extern template class SpaceGroup<1>;
170 extern template class SpaceGroup<2>;
171 extern template class SpaceGroup<3>;
172 extern template void readGroup(std::string, SpaceGroup<1>& );
173 extern template void readGroup(std::string, SpaceGroup<2>& );
174 extern template void readGroup(std::string, SpaceGroup<3>& );
175 extern template void writeGroup(std::string, SpaceGroup<1> const &);
176 extern template void writeGroup(std::string, SpaceGroup<2> const &);
177 extern template void writeGroup(std::string, SpaceGroup<3> const &);
178
179}
180#endif
An IntVec<D, T> is a D-component vector of elements of integer type T.
Definition IntVec.h:27
Crystallographic space group.
Definition SpaceGroup.h:31
bool hasInversionCenter(typename SpaceSymmetry< D >::Translation &center) const
Determines if this space group has an inversion center.
void checkMeshDimensions(IntVec< D > const &dimensions) const
Check if input mesh dimensions are compatible with space group.
void shiftOrigin(typename SpaceSymmetry< D >::Translation const &origin)
Shift the origin of space used in the coordinate system.
A SpaceSymmetry represents a crystallographic space group symmetry.
FArray< Rational, D > Translation
Typedef for vector used to represent fractional translation.
void clear()
Remove all elements except the identity.
bool add(Symmetry &symmetry)
Add a new element to the group.
Label(bool isRequired=true)
Constructor.
Definition Label.cpp:75
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
Definition global.h:68
PSCF package top-level namespace.
std::istream & operator>>(std::istream &in, Pair< Data > &pair)
Input a Pair from an istream.
Definition Pair.h:44
std::ostream & operator<<(std::ostream &out, const Pair< Data > &pair)
Output a Pair to an ostream, without line breaks.
Definition Pair.h:57