ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
CylindricalLBFluxDensityProfileAtParticlePositions.cpp
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2016-2022 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
#include "
CylindricalLBFluxDensityProfileAtParticlePositions.hpp
"
20
21
#include "
BoxGeometry.hpp
"
22
#include "system/System.hpp"
23
#include "
utils_histogram.hpp
"
24
25
#include <
utils/Histogram.hpp
>
26
#include <
utils/math/coordinate_transformation.hpp
>
27
28
#include <boost/mpi/collectives/gather.hpp>
29
#include <boost/serialization/vector.hpp>
30
31
#include <utility>
32
#include <vector>
33
34
namespace
Observables
{
35
std::vector<double>
36
CylindricalLBFluxDensityProfileAtParticlePositions::evaluate
(
37
boost::mpi::communicator
const
&comm,
38
ParticleReferenceRange
const
&local_particles,
39
const
ParticleObservables::traits<Particle>
&
traits
)
const
{
40
using
pos_type
=
decltype
(
traits
.position(std::declval<Particle>()));
41
using
flux_type
=
Utils::Vector3d
;
42
43
auto
const
buffer_size
= local_particles.size();
44
std::vector<pos_type>
local_folded_positions
{};
45
std::vector<flux_type>
local_flux_densities
{};
46
local_folded_positions
.reserve(
buffer_size
);
47
local_flux_densities
.reserve(
buffer_size
);
48
49
auto
&
system
=
System::get_system
();
50
auto
const
&box_geo = *
system
.box_geo;
51
auto
&lb =
system
.lb;
52
lb.ghost_communication_pdf();
53
lb.ghost_communication_vel();
54
55
std::vector<Utils::Vector3d>
unfolded_pos
{};
56
std::vector<Utils::Vector3d>
folded_pos
{};
57
unfolded_pos
.reserve(
buffer_size
);
58
folded_pos
.reserve(
buffer_size
);
59
for
(
auto
const
&p : local_particles) {
60
unfolded_pos
.emplace_back(
traits
.position(p));
61
folded_pos
.emplace_back(box_geo.folded_position(
traits
.position(p)));
62
}
63
auto
const
interpolated_vel
=
64
lb.get_coupling_interpolated_velocities(
folded_pos
);
65
auto
const
interpolated_rho
= lb.get_interpolated_densities(
unfolded_pos
);
66
auto
vel_it
=
interpolated_vel
.begin();
67
auto
rho_it
=
interpolated_rho
.begin();
68
for
(
auto
const
&pos :
folded_pos
) {
69
auto
const
pos_shifted
= pos -
transform_params
->center();
70
auto
const
pos_cyl
=
Utils::transform_coordinate_cartesian_to_cylinder
(
71
pos_shifted
,
transform_params
->axis(),
transform_params
->orientation());
72
auto
const
flux_cyl
=
Utils::transform_vector_cartesian_to_cylinder
(
73
(*
vel_it
) * (*
rho_it
),
transform_params
->axis(),
pos_shifted
);
74
local_folded_positions
.emplace_back(
pos_cyl
);
75
local_flux_densities
.emplace_back(
flux_cyl
);
76
++
vel_it
;
77
++
rho_it
;
78
}
79
80
auto
const
[
global_folded_positions
,
global_flux_densities
] =
81
detail::gather(comm,
local_folded_positions
,
local_flux_densities
);
82
83
if
(comm.rank() != 0) {
84
return
{};
85
}
86
87
Utils::CylindricalHistogram<double, 3>
histogram
(
n_bins
(),
limits
());
88
detail::accumulate(
histogram
,
global_folded_positions
,
global_flux_densities
);
89
return
detail::normalize_by_bin_size(
histogram
);
90
}
91
}
// namespace Observables
BoxGeometry.hpp
CylindricalLBFluxDensityProfileAtParticlePositions.hpp
Histogram.hpp
Observables::CylindricalLBFluxDensityProfileAtParticlePositions::evaluate
std::vector< double > evaluate(boost::mpi::communicator const &comm, ParticleReferenceRange const &local_particles, const ParticleObservables::traits< Particle > &traits) const override
Definition
CylindricalLBFluxDensityProfileAtParticlePositions.cpp:36
Observables::CylindricalProfileObservable::transform_params
std::shared_ptr< Utils::CylindricalTransformationParameters > transform_params
Definition
CylindricalProfileObservable.hpp:43
Observables::ProfileObservable::n_bins
auto n_bins() const
Definition
core/observables/ProfileObservable.hpp:70
Observables::ProfileObservable::limits
auto limits() const
Definition
core/observables/ProfileObservable.hpp:72
Utils::CylindricalHistogram
Histogram in cylindrical coordinates.
Definition
Histogram.hpp:201
stream
cudaStream_t stream[1]
CUDA streams for parallel computing on CPU and GPU.
Definition
common_cuda.cu:34
coordinate_transformation.hpp
Convert coordinates from the Cartesian system to the cylindrical system.
Observables
Definition
BondAngles.hpp:37
Observables::ParticleReferenceRange
std::vector< std::reference_wrapper< Particle const > > ParticleReferenceRange
Definition
core/observables/PidObservable.hpp:47
System::get_system
System & get_system()
Definition
core/system/System.cpp:132
Utils::Vector3d
VectorXd< 3 > Vector3d
Definition
Vector.hpp:185
Utils::transform_vector_cartesian_to_cylinder
Vector3d transform_vector_cartesian_to_cylinder(Vector3d const &vec, Vector3d const &axis, Vector3d const &pos)
Vector transformation from Cartesian to cylindrical coordinates.
Definition
coordinate_transformation.hpp:147
Utils::transform_coordinate_cartesian_to_cylinder
Vector3d transform_coordinate_cartesian_to_cylinder(Vector3d const &pos)
Coordinate transformation from Cartesian to cylindrical coordinates.
Definition
coordinate_transformation.hpp:70
traits
Definition
traits.hpp:24
ParticleObservables::traits
Definition
properties.hpp:27
utils_histogram.hpp
src
core
observables
CylindricalLBFluxDensityProfileAtParticlePositions.cpp
Generated on Tue Dec 9 2025 02:28:52 for ESPResSo by
1.9.8