ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
ibm_common.cpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2010-2026 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 "ibm_common.hpp"
21
22#include "Particle.hpp"
24#include "communication.hpp"
25#include "system/System.hpp"
26
27#include <utils/Vector.hpp>
29
30#include <boost/mpi/collectives/all_reduce.hpp>
31
32#include <optional>
33#include <stdexcept>
34
36 int pid) {
37 auto *p = cell_structure.get_local_particle(pid);
38 std::optional<Particle> opt_part{std::nullopt};
39
40 if (p and not p->is_ghost()) {
41 opt_part = *p;
42 }
43 opt_part = boost::mpi::all_reduce(comm_cart, opt_part,
44 [](std::optional<Particle> const &acc,
45 std::optional<Particle> const &item) {
46 if (acc) {
47 return acc;
48 }
49 return item;
50 });
51 if (opt_part)
52 return opt_part.value().pos();
53 throw std::runtime_error("Immersed Boundary: Particle not found");
54}
Vector implementation and trait types for boost qvm interoperability.
Describes a cell structure / cell system.
Particle * get_local_particle(int id)
Get a local particle by id.
cudaStream_t stream[1]
CUDA streams for parallel computing on CPU and GPU.
boost::mpi::communicator comm_cart
The communicator.
Utils::Vector3d get_ibm_particle_position(CellStructure const &cell_structure, int pid)
Returns the position of a given particle.
auto const & pos() const
Definition Particle.hpp:471