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 ESPRESSO_COLLISION_DETECTION
23
24
#include "
CollisionDetection.hpp
"
25
26
#include "
cell_system/CellStructure.hpp
"
27
#include "system/System.hpp"
28
29
#include <memory>
30
#include <utility>
31
#include <variant>
32
33
namespace
CollisionDetection
{
34
35
void
CollisionDetection::handle_collisions
() {
36
auto
&
system
= get_system();
37
if
(m_protocol) {
38
std::visit(
39
[&
system
,
this
](
auto
&protocol) {
40
protocol.handle_collisions(
system
, local_collision_queue);
41
},
42
*m_protocol);
43
}
44
clear_queue();
45
}
46
47
void
CollisionDetection::initialize
() {
48
auto
&
system
= get_system();
49
if
(m_protocol) {
50
std::visit([&
system
](
auto
&protocol) { protocol.initialize(
system
); },
51
*m_protocol);
52
}
53
system
.on_short_range_ia_change();
54
#ifdef ESPRESSO_SHARED_MEMORY_PARALLELISM
55
system
.cell_structure->clear_local_properties();
56
#endif
57
}
58
59
void
CollisionDetection::set_protocol
(
60
std::shared_ptr<ActiveProtocol> protocol) {
61
m_protocol = std::move(protocol);
62
initialize();
63
}
64
65
void
CollisionDetection::unset_protocol
() {
66
m_protocol =
nullptr
;
67
auto
&
system
= get_system();
68
system
.on_short_range_ia_change();
69
#ifdef ESPRESSO_SHARED_MEMORY_PARALLELISM
70
system
.cell_structure->clear_local_properties();
71
#endif
72
}
73
74
}
// namespace CollisionDetection
75
76
#endif
// ESPRESSO_COLLISION_DETECTION
CellStructure.hpp
CollisionDetection::CollisionDetection::initialize
void initialize()
Validate parameters and create particle types if needed.
Definition
CollisionDetection.cpp:47
CollisionDetection::CollisionDetection::set_protocol
void set_protocol(std::shared_ptr< ActiveProtocol > protocol)
Set a new collision protocol.
Definition
CollisionDetection.cpp:59
CollisionDetection::CollisionDetection::unset_protocol
void unset_protocol()
Delete the currently active collision protocol.
Definition
CollisionDetection.cpp:65
CollisionDetection::CollisionDetection::handle_collisions
void handle_collisions()
Handle queued collisions.
Definition
CollisionDetection.cpp:35
stream
cudaStream_t stream[1]
CUDA streams for parallel computing on CPU and GPU.
Definition
common_cuda.cu:34
config.hpp
CollisionDetection
Definition
ActiveProtocol.hpp:33
CollisionDetection.hpp
src
core
collision_detection
CollisionDetection.cpp
Generated on Tue Dec 9 2025 02:28:52 for ESPResSo by
1.9.8