ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
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
24
#include "
CollisionDetection.hpp
"
25
26
#include "system/System.hpp"
27
28
#include <memory>
29
#include <utility>
30
#include <variant>
31
32
namespace
CollisionDetection
{
33
34
void
CollisionDetection::handle_collisions
() {
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
46
void
CollisionDetection::initialize
() {
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
55
void
CollisionDetection::set_protocol
(
56
std::shared_ptr<ActiveProtocol> protocol) {
57
m_protocol = std::move(protocol);
58
initialize();
59
}
60
61
void
CollisionDetection::unset_protocol
() {
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
CollisionDetection::CollisionDetection::initialize
void initialize()
Validate parameters and create particle types if needed.
Definition
CollisionDetection.cpp:46
CollisionDetection::CollisionDetection::set_protocol
void set_protocol(std::shared_ptr< ActiveProtocol > protocol)
Set a new collision protocol.
Definition
CollisionDetection.cpp:55
CollisionDetection::CollisionDetection::unset_protocol
void unset_protocol()
Delete the currently active collision protocol.
Definition
CollisionDetection.cpp:61
CollisionDetection::CollisionDetection::handle_collisions
void handle_collisions()
Handle queued collisions.
Definition
CollisionDetection.cpp:34
config.hpp
This file contains the defaults for ESPResSo.
CollisionDetection
Definition
ActiveProtocol.hpp:33
CollisionDetection.hpp
src
core
collision_detection
CollisionDetection.cpp
Generated on Thu Dec 19 2024 02:13:16 for ESPResSo by
1.9.8