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 */
20
21#include "BoxGeometry.hpp"
22#include "system/System.hpp"
23#include "utils_histogram.hpp"
24
25#include <utils/Histogram.hpp>
27
28#include <boost/mpi/collectives/gather.hpp>
29#include <boost/serialization/vector.hpp>
30
31#include <utility>
32#include <vector>
33
34namespace Observables {
35std::vector<double>
37 boost::mpi::communicator const &comm,
38 ParticleReferenceRange const &local_particles,
40 using pos_type = decltype(traits.position(std::declval<Particle>()));
41 using flux_type = Utils::Vector3d;
42
43 std::vector<pos_type> local_folded_positions{};
44 std::vector<flux_type> local_flux_densities{};
45 local_folded_positions.reserve(local_particles.size());
46 local_flux_densities.reserve(local_particles.size());
47
48 auto const &system = System::get_system();
49 auto const &box_geo = *system.box_geo;
50 auto const &lb = system.lb;
51 auto const vel_conv = lb.get_lattice_speed();
52
53 for (auto const &p : local_particles) {
54 auto const pos = box_geo.folded_position(traits.position(p));
55 auto const pos_shifted = pos - transform_params->center();
56 auto const vel = *lb.get_interpolated_velocity(pos);
57 auto const dens = *lb.get_interpolated_density(pos);
59 pos_shifted, transform_params->axis(), transform_params->orientation());
61 vel * vel_conv * dens, transform_params->axis(), pos_shifted);
62 local_folded_positions.emplace_back(pos_cyl);
63 local_flux_densities.emplace_back(flux_cyl);
64 }
65
66 auto const [global_folded_positions, global_flux_densities] =
67 detail::gather(comm, local_folded_positions, local_flux_densities);
68
69 if (comm.rank() != 0) {
70 return {};
71 }
72
74 detail::accumulate(histogram, global_folded_positions, global_flux_densities);
75 return detail::normalize_by_bin_size(histogram);
76}
77} // namespace Observables
__shared__ int pos[MAXDEPTH *THREADS5/WARPSIZE]
std::vector< double > evaluate(boost::mpi::communicator const &comm, ParticleReferenceRange const &local_particles, const ParticleObservables::traits< Particle > &traits) const override
std::shared_ptr< Utils::CylindricalTransformationParameters > transform_params
Histogram in cylindrical coordinates.
Convert coordinates from the Cartesian system to the cylindrical system.
std::vector< std::reference_wrapper< Particle const > > ParticleReferenceRange
System & get_system()
VectorXd< 3 > Vector3d
Definition Vector.hpp:157
Vector3d transform_vector_cartesian_to_cylinder(Vector3d const &vec, Vector3d const &axis, Vector3d const &pos)
Vector transformation from Cartesian to cylindrical coordinates.
Vector3d transform_coordinate_cartesian_to_cylinder(Vector3d const &pos)
Coordinate transformation from Cartesian to cylindrical coordinates.