Loading [MathJax]/extensions/TeX/AMSmath.js
ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages Concepts
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 &) const = default;
43 bool operator!=(DeleteBond const &) const = default;
44};
45
48 std::array<int, 2> bond_partner_id;
50 std::size_t hash_value() const {
51 std::size_t seed = 3876;
52 boost::hash_combine(seed, particle_id);
53 boost::hash_combine(seed, bond_partner_id);
54 boost::hash_combine(seed, bond_type);
55 return seed;
56 }
57 bool operator==(DeleteAngleBond const &) const = default;
58 bool operator!=(DeleteAngleBond const &) const = default;
59};
60
64 std::size_t hash_value() const {
65 std::size_t seed = 75;
66 boost::hash_combine(seed, particle_id_1);
67 boost::hash_combine(seed, particle_id_2);
68 return seed;
69 }
70 bool operator==(DeleteAllBonds const &) const = default;
71 bool operator!=(DeleteAllBonds const &) const = default;
72};
73
74} // namespace BondBreakage
75
76// Hash support for std::unordered_set
77namespace boost {
78template <> struct hash<BondBreakage::DeleteBond> {
79 std::size_t operator()(BondBreakage::DeleteBond const &t) const noexcept {
80 return t.hash_value();
81 }
82};
83template <> struct hash<BondBreakage::DeleteAngleBond> {
84 std::size_t
85 operator()(BondBreakage::DeleteAngleBond const &t) const noexcept {
86 return t.hash_value();
87 };
88};
89template <> struct hash<BondBreakage::DeleteAllBonds> {
90 std::size_t operator()(BondBreakage::DeleteAllBonds const &t) const noexcept {
91 return t.hash_value();
92 }
93};
94} // namespace boost
std::size_t hash_value() const
Definition actions.hpp:64
bool operator!=(DeleteAllBonds const &) const =default
bool operator==(DeleteAllBonds const &) const =default
bool operator==(DeleteAngleBond const &) const =default
std::size_t hash_value() const
Definition actions.hpp:50
std::array< int, 2 > bond_partner_id
Definition actions.hpp:48
bool operator!=(DeleteAngleBond const &) const =default
bool operator!=(DeleteBond const &) const =default
std::size_t hash_value() const
Definition actions.hpp:35
bool operator==(DeleteBond const &) const =default
std::size_t operator()(BondBreakage::DeleteAllBonds const &t) const noexcept
Definition actions.hpp:90
std::size_t operator()(BondBreakage::DeleteAngleBond const &t) const noexcept
Definition actions.hpp:85
std::size_t operator()(BondBreakage::DeleteBond const &t) const noexcept
Definition actions.hpp:79