ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
actions.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2022 The ESPResSo project
3 *
4 * This file is part of ESPResSo.
5 *
6 * ESPResSo is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * ESPResSo is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#pragma once
21
22#include <boost/functional/hash.hpp>
23#include <boost/variant.hpp>
24
25#include <array>
26#include <cstddef>
27
28namespace BondBreakage {
29
30// Delete Actions
31struct DeleteBond {
35 std::size_t hash_value() const {
36 std::size_t seed = 3875;
37 boost::hash_combine(seed, particle_id);
38 boost::hash_combine(seed, bond_partner_id);
39 boost::hash_combine(seed, bond_type);
40 return seed;
41 }
42 bool operator==(DeleteBond const &rhs) const {
43 return rhs.particle_id == particle_id and
45 rhs.bond_type == bond_type;
46 }
47 bool operator!=(DeleteBond const &rhs) const { return not(*this == rhs); }
48};
49
52 std::array<int, 2> bond_partner_id;
54 std::size_t hash_value() const {
55 std::size_t seed = 3876;
56 boost::hash_combine(seed, particle_id);
57 boost::hash_combine(seed, bond_partner_id);
58 boost::hash_combine(seed, bond_type);
59 return seed;
60 }
61 bool operator==(DeleteAngleBond const &rhs) const {
62 return rhs.particle_id == particle_id and
64 rhs.bond_type == bond_type;
65 }
66 bool operator!=(DeleteAngleBond const &rhs) const {
67 return not(*this == rhs);
68 }
69};
70
74 std::size_t hash_value() const {
75 std::size_t seed = 75;
76 boost::hash_combine(seed, particle_id_1);
77 boost::hash_combine(seed, particle_id_2);
78 return seed;
79 }
80 bool operator==(DeleteAllBonds const &rhs) const {
81 return rhs.particle_id_1 == particle_id_1 and
83 }
84 bool operator!=(DeleteAllBonds const &rhs) const { return not(*this == rhs); }
85};
86
87} // namespace BondBreakage
88
89// Hash support for std::unordered_set
90namespace boost {
91template <> struct hash<BondBreakage::DeleteBond> {
92 std::size_t operator()(BondBreakage::DeleteBond const &t) const noexcept {
93 return t.hash_value();
94 }
95};
96template <> struct hash<BondBreakage::DeleteAngleBond> {
97 std::size_t
98 operator()(BondBreakage::DeleteAngleBond const &t) const noexcept {
99 return t.hash_value();
100 };
101};
102template <> struct hash<BondBreakage::DeleteAllBonds> {
103 std::size_t operator()(BondBreakage::DeleteAllBonds const &t) const noexcept {
104 return t.hash_value();
105 }
106};
107} // namespace boost
bool operator==(DeleteAllBonds const &rhs) const
Definition actions.hpp:80
std::size_t hash_value() const
Definition actions.hpp:74
bool operator!=(DeleteAllBonds const &rhs) const
Definition actions.hpp:84
bool operator==(DeleteAngleBond const &rhs) const
Definition actions.hpp:61
bool operator!=(DeleteAngleBond const &rhs) const
Definition actions.hpp:66
std::size_t hash_value() const
Definition actions.hpp:54
std::array< int, 2 > bond_partner_id
Definition actions.hpp:52
bool operator!=(DeleteBond const &rhs) const
Definition actions.hpp:47
std::size_t hash_value() const
Definition actions.hpp:35
bool operator==(DeleteBond const &rhs) const
Definition actions.hpp:42
std::size_t operator()(BondBreakage::DeleteAllBonds const &t) const noexcept
Definition actions.hpp:103
std::size_t operator()(BondBreakage::DeleteAngleBond const &t) const noexcept
Definition actions.hpp:98
std::size_t operator()(BondBreakage::DeleteBond const &t) const noexcept
Definition actions.hpp:92