30#include "communication.hpp"
31#include "system/System.hpp"
37#include <boost/mpi/collectives/all_reduce.hpp>
43#include <unordered_map>
52 std::vector<int> buffer_pid{};
53 std::vector<T> buffer_obs{};
61 if (ptr !=
nullptr and not ptr->is_ghost()) {
62 buffer_pid.emplace_back(pid);
63 buffer_obs.emplace_back(
kernel(*ptr));
68 std::unordered_map<int, T> map{};
72 for (std::size_t i = 0
u; i < buffer_pid.size(); ++i) {
73 map[buffer_pid[i]] = buffer_obs[i];
107 auto const &cell_structure = *
system.cell_structure;
109 double dist = 0.0, dist2 = 0.0,
dist4 = 0.0;
110 std::array<double, 4>
re{};
112 for (
int i = 0; i <
n_chains; i++) {
120 for (
int i = 0; i <
n_chains; i++) {
123 auto const norm2 = (map.at(
pid1) - map.at(
pid2)).norm2();
126 dist4 += norm2 * norm2;
139 auto const &cell_structure = *
system.cell_structure;
144 std::array<double, 4>
rg{};
149 auto const ptr = cell_structure.get_local_particle(pid);
150 if (ptr !=
nullptr and not ptr->is_ghost()
and ptr->is_virtual()) {
156 throw std::runtime_error(
157 "Center of mass is not well-defined for chains including virtual "
158 "sites. Virtual sites do not have a meaningful mass.");
172 for (
int i = 0; i <
n_chains; i++) {
203 auto const &cell_structure = *
system.cell_structure;
206 std::array<double, 2>
rh{};
210 for (
int p = 0; p <
n_chains; p++) {
221 for (
int p = 0; p <
n_chains; p++) {
226 ri += 1.0 / (map.at(i) - map.at(
j)).norm();
Vector implementation and trait types for boost qvm interoperability.
auto unfolded_position(Utils::Vector3d const &pos, Utils::Vector3i const &image_box) const
Unfold particle coordinates to image box.
Describes a cell structure / cell system.
Particle * get_local_particle(int id)
Get a local particle by id.
DEVICE_QUALIFIER constexpr reference at(size_type i)
cudaStream_t stream[1]
CUDA streams for parallel computing on CPU and GPU.
boost::mpi::communicator comm_cart
The communicator.
void gather_buffer(std::vector< T, Allocator > &buffer, boost::mpi::communicator const &comm, int root=0)
Gather buffer with different size on each node.
DEVICE_QUALIFIER constexpr T sqr(T x)
Calculates the SQuaRe of x.
std::array< double, 4 > calc_rg(System::System const &system, int chain_start, int chain_length, int n_chains)
Calculate the radius of gyration.
std::array< double, 2 > calc_rh(System::System const &system, int chain_start, int chain_length, int n_chains)
Calculate the hydrodynamic radius (ref.
std::array< double, 4 > calc_re(System::System const &system, int chain_start, int chain_length, int n_chains)
Calculate the end-to-end-distance.
This file contains the code for statistics on chains.
GatherCom(BoxGeometry const &box_geo)
BoxGeometry const & m_box_geo
Utils::Vector3d kernel(Particle const &p) const override
~GatherCom() override=default
~GatherMass() override=default
double kernel(Particle const &p) const override
Gather particle properties (or any derived quantities) on MPI rank 0.
virtual T kernel(Particle const &) const =0
void fetch(CellStructure const &cell_structure, int pid)
virtual ~GatherParticleTraits()=default
BoxGeometry const & m_box_geo
Utils::Vector3d kernel(Particle const &p) const override
~GatherPos() override=default
GatherPos(BoxGeometry const &box_geo)
Struct holding all information for one particle.
auto const & mass() const
auto const & image_box() const