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
CollisionDetection.cpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2011-2024 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#include <config/config.hpp>
21
22#ifdef COLLISION_DETECTION
23
25
26#include "system/System.hpp"
27
28#include <memory>
29#include <utility>
30#include <variant>
31
32namespace CollisionDetection {
33
35 auto &system = get_system();
36 if (m_protocol) {
37 std::visit(
38 [&system, this](auto &protocol) {
39 protocol.handle_collisions(system, local_collision_queue);
40 },
41 *m_protocol);
42 }
43 clear_queue();
44}
45
47 auto &system = get_system();
48 if (m_protocol) {
49 std::visit([&system](auto &protocol) { protocol.initialize(system); },
50 *m_protocol);
51 }
52 system.on_short_range_ia_change();
53}
54
56 std::shared_ptr<ActiveProtocol> protocol) {
57 m_protocol = std::move(protocol);
58 initialize();
59}
60
62 m_protocol = nullptr;
63 auto &system = get_system();
64 system.on_short_range_ia_change();
65}
66
67} // namespace CollisionDetection
68
69#endif // COLLISION_DETECTION
void initialize()
Validate parameters and create particle types if needed.
void set_protocol(std::shared_ptr< ActiveProtocol > protocol)
Set a new collision protocol.
void unset_protocol()
Delete the currently active collision protocol.
void handle_collisions()
Handle queued collisions.
This file contains the defaults for ESPResSo.