diff --git a/src/core/ParticlePropertyIterator.hpp b/src/core/ParticlePropertyIterator.hpp index 6b2390a62c..b10e2cae1d 100644 --- a/src/core/ParticlePropertyIterator.hpp +++ b/src/core/ParticlePropertyIterator.hpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010-2022 The ESPResSo project + * Copyright (C) 2023 The ESPResSo project * * This file is part of ESPResSo. * @@ -16,21 +16,21 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -#ifndef ESPRESSO_SRC_CORE_PARTICLE_EXTRACT_PROPERTIES_HPP -#define ESPRESSO_SRC_CORE_PARTICLE_EXTRACT_PROPERTIES_HPP +#pragma once #include "BoxGeometry.hpp" #include "Particle.hpp" #include "ParticleRange.hpp" #include "grid.hpp" + #include #include -#include + #include namespace ParticlePropertyRange { -namespace { +namespace detail { template auto create_transform_range(ParticleRange const &particles, Kernel kernel) { auto transform_iterator_begin = @@ -40,32 +40,25 @@ auto create_transform_range(ParticleRange const &particles, Kernel kernel) { return boost::make_iterator_range( transform_iterator_begin, transform_iterator_end); } -} // namespace - -auto pos_range(ParticleRange const &particles) { - auto return_pos = [](Particle &p) { return p.pos(); }; - return create_transform_range(particles, return_pos); -} +} // namespace detail auto unfolded_pos_range(ParticleRange const &particles, BoxGeometry const &box) { auto return_unfolded_pos = [&box](Particle &p) { return unfolded_position(p.pos(), p.image_box(), box.length()); }; - return create_transform_range(particles, return_unfolded_pos); + return detail::create_transform_range(particles, return_unfolded_pos); } auto charge_range(ParticleRange const &particles) { - auto return_charge = [](Particle &p) { return p.q(); }; - return create_transform_range(particles, return_charge); + auto return_charge = [](Particle &p) -> double & { return p.q(); }; + return detail::create_transform_range(particles, return_charge); } auto force_range(ParticleRange const &particles) { auto return_force = [](Particle &p) -> Utils::Vector3d & { return p.force(); }; - return create_transform_range(particles, return_force); + return detail::create_transform_range(particles, return_force); } } // namespace ParticlePropertyRange - -#endif diff --git a/src/core/electrostatics/p3m.cpp b/src/core/electrostatics/p3m.cpp index 220384958f..512b8612b3 100644 --- a/src/core/electrostatics/p3m.cpp +++ b/src/core/electrostatics/p3m.cpp @@ -399,7 +399,7 @@ static auto calc_dipole_moment(boost::mpi::communicator const &comm, boost::accumulate(p_q_unfolded_pos_range, Utils::Vector3d{}, [](Utils::Vector3d dip, auto const &q_pos) { auto const p_q = boost::get<0>(q_pos); - auto const p_unfolded_pos = boost::get<1>(q_pos); + auto const &p_unfolded_pos = boost::get<1>(q_pos); return dip + dipole_moment(p_q, p_unfolded_pos); }); return boost::mpi::all_reduce(comm, local_dip, std::plus<>());