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
25
27#include "system/System.hpp"
28
29#include <memory>
30#include <utility>
31#include <variant>
32
33namespace CollisionDetection {
34
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
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
60 std::shared_ptr<ActiveProtocol> protocol) {
61 m_protocol = std::move(protocol);
62 initialize();
63}
64
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
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.
cudaStream_t stream[1]
CUDA streams for parallel computing on CPU and GPU.