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
"
23
#include "
cell_system/CellStructure.hpp
"
24
#include "communication.hpp"
25
#include "system/System.hpp"
26
27
#include <
utils/Vector.hpp
>
28
#include <
utils/serialization/optional.hpp
>
29
30
#include <boost/mpi/collectives/all_reduce.hpp>
31
32
#include <optional>
33
#include <stdexcept>
34
35
Utils::Vector3d
get_ibm_particle_position
(
CellStructure
const
&cell_structure,
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
}
CellStructure.hpp
Particle.hpp
Vector.hpp
Vector implementation and trait types for boost qvm interoperability.
CellStructure
Describes a cell structure / cell system.
Definition
CellStructure.hpp:156
CellStructure::get_local_particle
Particle * get_local_particle(int id)
Get a local particle by id.
Definition
CellStructure.hpp:301
Utils::Vector
Definition
Vector.hpp:50
stream
cudaStream_t stream[1]
CUDA streams for parallel computing on CPU and GPU.
Definition
common_cuda.cu:34
comm_cart
boost::mpi::communicator comm_cart
The communicator.
Definition
communication.cpp:63
get_ibm_particle_position
Utils::Vector3d get_ibm_particle_position(CellStructure const &cell_structure, int pid)
Returns the position of a given particle.
Definition
ibm_common.cpp:35
ibm_common.hpp
Particle::pos
constexpr auto const & pos() const
Definition
Particle.hpp:476
optional.hpp
src
core
immersed_boundary
ibm_common.cpp
Generated on Tue Jul 28 2026 01:32:39 for ESPResSo by
1.9.8