35#include "system/System.hpp"
39#include <boost/archive/binary_iarchive.hpp>
40#include <boost/archive/binary_oarchive.hpp>
41#include <boost/iostreams/device/array.hpp>
42#include <boost/iostreams/device/back_inserter.hpp>
43#include <boost/iostreams/stream.hpp>
44#include <boost/mpi/collectives.hpp>
45#include <boost/range/numeric.hpp>
46#include <boost/serialization/vector.hpp>
58#define REQ_GHOST_SEND 100
68 char *
data() {
return buf.data(); }
69 const char *
data()
const {
return buf.data(); }
73 std::size_t
size()
const {
return buf.size(); }
79 void resize(std::size_t new_size) { buf.resize(new_size); }
83 auto &
bonds() {
return bondbuf; }
84 const auto &
bonds()
const {
return bondbuf; }
86 auto make_span() {
return std::span(buf.data(), buf.size()); }
89 std::vector<char> buf;
90 std::vector<char> bondbuf;
95 std::size_t m_size = 0;
98 auto size()
const {
return m_size; }
105 template <
class T>
auto &
operator&(T &t) {
return *
this << t; }
125template <
class Archive>
133#ifdef ESPRESSO_ROTATION
135#ifdef ESPRESSO_ROTATIONAL_INERTIA
142#ifdef ESPRESSO_ELECTROSTATICS
145#ifdef ESPRESSO_DIPOLES
148#ifdef ESPRESSO_LB_ELECTROHYDRODYNAMICS
151#ifdef ESPRESSO_VIRTUAL_SITES_RELATIVE
154#ifdef ESPRESSO_THERMOSTAT_PER_PARTICLE
156#ifdef ESPRESSO_ROTATION
160#ifdef ESPRESSO_EXTERNAL_FORCES
163#ifdef ESPRESSO_ROTATION
167#ifdef ESPRESSO_ENGINE
183#ifdef ESPRESSO_ROTATION
186#ifdef ESPRESSO_BOND_CONSTRAINT
192#ifdef ESPRESSO_ROTATION
205#ifdef ESPRESSO_ROTATION
216#ifdef ESPRESSO_BOND_CONSTRAINT
245 auto const n_part = boost::accumulate(
247 [](std::size_t
sum,
auto part_list) { return sum + part_list->size(); });
264 namespace io = boost::iostreams;
265 io::stream<io::back_insert_device<std::vector<char>>>
os{
273 auto np =
static_cast<unsigned int>(
part_list->size());
295 for (
auto &p : *cell) {
331 namespace io = boost::iostreams;
332 io::stream<io::array_source>
bond_stream(io::array_source{
349#ifdef ESPRESSO_BOND_CONSTRAINT
359 part.rattle_params() +=
pr;
373 part.force_and_torque() +=
pf;
386 auto const offset =
ghost_comm.part_lists.size() / 2;
387 for (std::size_t pl = 0; pl < offset; pl++) {
398 for (std::size_t i = 0; i <
src_part.size(); i++) {
409 p2.bonds() =
p1.bonds();
450 auto const &comm =
gcr.mpi_comm;
452 for (
auto cit =
gcr.communications.cbegin();
cit !=
gcr.communications.cend();
479 std::find_if(std::next(
cit),
gcr.communications.cend(),
481 return is_prefetchable(other_ghost_comm, this_node);
508 if (node == comm.rank()) {
511 boost::mpi::broadcast(comm,
send_buffer.bonds(), node);
515 boost::mpi::broadcast(comm,
recv_buffer.bonds(), node);
519 if (node == comm.rank())
521 comm,
reinterpret_cast<double *
>(
send_buffer.data()),
522 static_cast<int>(
send_buffer.size() /
sizeof(
double)),
523 reinterpret_cast<double *
>(
recv_buffer.data()), std::plus<double>{},
527 comm,
reinterpret_cast<double *
>(
send_buffer.data()),
528 static_cast<int>(
send_buffer.size() /
sizeof(
double)),
529 std::plus<double>{}, node);
540#ifdef ESPRESSO_BOND_CONSTRAINT
552 std::make_reverse_iterator(
cit),
gcr.communications.crend(),
554 return is_poststorable(other_ghost_comm, this_node);
563#ifdef ESPRESSO_BOND_CONSTRAINT
void fold_position(Utils::Vector3d &pos, Utils::Vector3i &image_box) const
Fold coordinates to primary simulation box in-place.
Class that stores marshalled data for ghost communications.
const auto & bonds() const
const char * data() const
char * data()
Returns a pointer to the non-bond storage.
std::size_t size() const
Returns the number of elements in the non-bond storage.
auto & bonds()
Returns a reference to the bond storage.
void resize(std::size_t new_size)
Resizes the underlying storage s.t.
Pseudo-archive to calculate the size of the serialization buffer.
void resize(std::size_t new_size)
Resize container.
Archive that deserializes from a buffer via memcpy.
Archive that serializes to a buffer via memcpy.
cudaStream_t stream[1]
CUDA streams for parallel computing on CPU and GPU.
int this_node
The number of this node.
static void serialize_and_reduce(Archive &ar, Particle &p, unsigned int data_parts, ReductionPolicy policy, SerializationDirection direction, BoxGeometry const &box_geo, Utils::Vector3d const *ghost_shift)
Serialize particle data, possibly with reduction.
static void add_rattle_correction_from_recv_buffer(CommBuf &recv_buffer, const GhostCommunication &ghost_comm)
static void prepare_recv_buffer(CommBuf &recv_buffer, GhostCommunication const &ghost_comm, BoxGeometry const &box_geo, unsigned int data_parts)
#define REQ_GHOST_SEND
Tag for ghosts communications.
static void put_recv_buffer(CommBuf &recv_buffer, GhostCommunication const &ghost_comm, BoxGeometry const &box_geo, unsigned int data_parts)
static void prepare_send_buffer(CommBuf &send_buffer, GhostCommunication const &ghost_comm, BoxGeometry const &box_geo, unsigned int data_parts)
ReductionPolicy
Type of reduction to carry out during serialization.
@ UPDATE
Reduction for cell-to-cell particle update.
@ MOVE
Reduction for domain-to-domain particle communication.
static bool is_recv_op(int comm_type, int node, int this_node)
static void add_forces_from_recv_buffer(CommBuf &recv_buffer, const GhostCommunication &ghost_comm)
static void cell_cell_transfer(GhostCommunication const &ghost_comm, BoxGeometry const &box_geo, unsigned int data_parts)
static bool is_send_op(int comm_type, int node, int this_node)
static void prepare_ghost_cell(ParticleList *cell, std::size_t size)
static auto calc_transmit_size(BoxGeometry const &box_geo, unsigned data_parts)
static bool is_prefetchable(GhostCommunication const &ghost_comm, int this_node)
void ghost_communicator(GhostCommunicator const &gcr, BoxGeometry const &box_geo, unsigned int data_parts)
Do a ghost communication with the specified data parts.
static bool is_poststorable(GhostCommunication const &ghost_comm, int this_node)
SerializationDirection
Whether to save the state to or load the state from the archive.
Ghost particles and particle exchange.
#define GHOST_RECV
recv from a single node
#define GHOST_PSTSTORE
additional flag for poststoring
#define GHOST_JOBMASK
mask to the job area of the transfer type
#define GHOST_RDCE
reduce, the node entry gives the receiver
#define GHOST_LOCL
transfer data from cell to cell on this node
#define GHOST_BCST
broadcast, the node entry gives the sender
@ GHOSTTRANS_MOMENTUM
transfer ParticleMomentum
@ GHOSTTRANS_RATTLE
transfer ParticleRattle
@ GHOSTTRANS_PARTNUM
resize the receiver particle arrays to the size of the senders
@ GHOSTTRANS_POSITION
transfer ParticlePosition
@ GHOSTTRANS_PROPRTS
transfer ParticleProperties
@ GHOSTTRANS_FORCE
transfer ParticleForce
#define GHOST_SEND
send to a single node
#define GHOST_PREFETCH
additional flag for prefetching
Properties for a ghost communication.
Force information on a particle.
Struct holding all information for one particle.
auto const & swimming() const
auto const & propagation() const
auto const & rinertia() const
auto const & mass() const
auto const & quat() const
auto const & rotation() const
auto const & vs_relative() const
auto const & gamma() const
auto const & pos_last_time_step() const
auto const & gamma_rot() const
auto const & torque() const
auto const & fixed() const
auto const & ext_force() const
auto const & omega() const
auto const & image_box() const
auto const & type() const
auto const & ext_torque() const
auto const & dipm() const
auto const & mol_id() const
auto const & mu_E() const
auto const & force() const
auto const & rattle_correction() const