Mantid
Loading...
Searching...
No Matches
Group.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2014 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7#pragma once
8
10#include "MantidGeometry/DllConfig.h"
12
13#include <set>
14#include <vector>
15
16#include <memory>
17
18namespace Mantid {
19namespace Geometry {
20
22class MANTID_GEOMETRY_DLL AtomPositionsEqual {
23public:
24 AtomPositionsEqual(double precision = 1.e-4) : m_precision(precision) {}
25
26 bool operator()(const Kernel::V3D &lhs, const Kernel::V3D &rhs) const {
27 return !(fabs(lhs.X() - rhs.X()) > m_precision || fabs(lhs.Y() - rhs.Y()) > m_precision ||
28 fabs(lhs.Z() - rhs.Z()) > m_precision);
29 }
30
31private:
33};
34
37class MANTID_GEOMETRY_DLL AtomPositionsLessThan {
38public:
39 AtomPositionsLessThan(double precision = 1.e-4) : m_precision(precision) {}
40
41 bool operator()(const Kernel::V3D &lhs, const Kernel::V3D &rhs) const {
42 if (fabs(lhs.X() - rhs.X()) > m_precision) {
43 return lhs.X() < rhs.X();
44 }
45
46 if (fabs(lhs.Y() - rhs.Y()) > m_precision) {
47 return lhs.Y() < rhs.Y();
48 }
49
50 if (fabs(lhs.Z() - rhs.Z()) > m_precision) {
51 return lhs.Z() < rhs.Z();
52 }
53
54 return false;
55 }
56
57private:
59};
60
135class MANTID_GEOMETRY_DLL Group {
136public:
137 enum CoordinateSystem { Orthogonal, Hexagonal };
138
139 enum GroupAxiom { Closure, Identity, Inversion, Associativity };
140
141 Group();
142 Group(const std::string &symmetryOperationString);
143 Group(const std::vector<SymmetryOperation> &symmetryOperations);
144 virtual ~Group() = default;
145
146 size_t order() const;
147 CoordinateSystem getCoordinateSystem() const;
148 std::vector<SymmetryOperation> getSymmetryOperations() const;
149 bool containsOperation(const SymmetryOperation &operation) const;
150
151 Group operator*(const Group &other) const;
152
153 std::vector<Kernel::V3D> operator*(const Kernel::V3D &vector) const;
154
155 bool isInvariant(const Kernel::DblMatrix &tensor, double tolerance = 1e-8) const;
156
157 bool operator==(const Group &other) const;
158 bool operator!=(const Group &other) const;
159
160 bool fulfillsAxiom(GroupAxiom axiom) const;
161 bool isGroup() const;
162
163protected:
164 void setSymmetryOperations(const std::vector<SymmetryOperation> &symmetryOperations);
165
166 CoordinateSystem getCoordinateSystemFromOperations(const std::vector<SymmetryOperation> &symmetryOperations) const;
167
168 bool isClosed() const;
169 bool hasIdentity() const;
170 bool eachElementHasInverse() const;
171 bool associativityHolds() const;
172
173 std::vector<SymmetryOperation> m_allOperations;
174 std::set<SymmetryOperation> m_operationSet;
176};
177
178using Group_sptr = std::shared_ptr<Group>;
179using Group_const_sptr = std::shared_ptr<const Group>;
180
181namespace GroupFactory {
184template <typename T> Group_const_sptr create(const std::string &initializationString) {
185 return std::make_shared<const T>(initializationString);
186}
187
190template <typename T> Group_const_sptr create(const std::vector<SymmetryOperation> &symmetryOperations) {
191 return std::make_shared<const T>(symmetryOperations);
192}
193} // namespace GroupFactory
194
195MANTID_GEOMETRY_DLL Group_const_sptr operator*(const Group_const_sptr &lhs, const Group_const_sptr &rhs);
196MANTID_GEOMETRY_DLL std::vector<Kernel::V3D> operator*(const Group_const_sptr &lhs, const Kernel::V3D &rhs);
197MANTID_GEOMETRY_DLL bool operator==(const Group_const_sptr &lhs, const Group_const_sptr &rhs);
198MANTID_GEOMETRY_DLL bool operator!=(const Group_const_sptr &lhs, const Group_const_sptr &rhs);
199
200} // namespace Geometry
201} // namespace Mantid
const std::vector< double > & rhs
#define fabs(x)
Definition: Matrix.cpp:22
double tolerance
Equality-functor for comparison of atom positions with specifiable precision.
Definition: Group.h:22
AtomPositionsEqual(double precision=1.e-4)
Definition: Group.h:24
bool operator()(const Kernel::V3D &lhs, const Kernel::V3D &rhs) const
Definition: Group.h:26
Less-than-functor for comparison of atom positions with specifiable precision.
Definition: Group.h:37
bool operator()(const Kernel::V3D &lhs, const Kernel::V3D &rhs) const
Definition: Group.h:41
AtomPositionsLessThan(double precision=1.e-4)
Definition: Group.h:39
The class Group represents a set of symmetry operations (or symmetry group).
Definition: Group.h:135
CoordinateSystem m_axisSystem
Definition: Group.h:175
virtual ~Group()=default
std::vector< SymmetryOperation > m_allOperations
Definition: Group.h:173
std::set< SymmetryOperation > m_operationSet
Definition: Group.h:174
Crystallographic symmetry operations are composed of a rotational component, which is represented by ...
Class for 3D vectors.
Definition: V3D.h:34
constexpr double X() const noexcept
Get x.
Definition: V3D.h:232
constexpr double Y() const noexcept
Get y.
Definition: V3D.h:233
constexpr double Z() const noexcept
Get z.
Definition: V3D.h:234
MatrixWorkspace_sptr MANTID_API_DLL operator*(const MatrixWorkspace_sptr &lhs, const MatrixWorkspace_sptr &rhs)
Multiply two workspaces.
std::unique_ptr< T > create(const P &parent, const IndexArg &indexArg, const HistArg &histArg)
This is the create() method that all the other create() methods call.
MANTID_GEOMETRY_DLL bool operator==(const Group_const_sptr &lhs, const Group_const_sptr &rhs)
Equality operator for shared pointers.
Definition: Group.cpp:266
std::shared_ptr< Group > Group_sptr
Definition: Group.h:178
MANTID_GEOMETRY_DLL Group_const_sptr operator*(const Group_const_sptr &lhs, const Group_const_sptr &rhs)
Convenience operator* for directly multiplying groups using shared pointers.
Definition: Group.cpp:248
MANTID_GEOMETRY_DLL bool operator!=(const Group_const_sptr &lhs, const Group_const_sptr &rhs)
Inequality operator for shared pointers.
Definition: Group.cpp:275
std::shared_ptr< const Group > Group_const_sptr
Definition: Group.h:179
Helper class which provides the Collimation Length for SANS instruments.
constexpr bool operator==(const wide_integer< Bits, Signed > &lhs, const wide_integer< Bits2, Signed2 > &rhs)
constexpr bool operator!=(const wide_integer< Bits, Signed > &lhs, const wide_integer< Bits2, Signed2 > &rhs)