ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
send_mesh.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2010-2026 The ESPResSo project
3 * Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009,2010
4 * Max-Planck-Institute for Polymer Research, Theory Group
5 *
6 * This file is part of ESPResSo.
7 *
8 * ESPResSo is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * ESPResSo is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#pragma once
23
24#include <config/config.hpp>
25
26#if defined(ESPRESSO_P3M) or defined(ESPRESSO_DP3M)
27
28#include "p3m/common.hpp"
29
30#include <utils/Vector.hpp>
31
32#include <boost/mpi/communicator.hpp>
33
34#include <span>
35#include <vector>
36
37/** @brief P3M halo communicator. */
38template <typename FloatType> class p3m_send_mesh {
39 enum Requests {
40 REQ_P3M_INIT = 200,
41 REQ_P3M_GATHER = 201,
42 REQ_P3M_SPREAD = 202
43 };
44 /** dimension of sub meshes to send. */
45 int s_dim[6][3];
46 /** lower left corners of sub meshes to send. */
47 int s_ld[6][3];
48 /** upper right corners of sub meshes to send. */
49 int s_ur[6][3];
50 /** sizes for send buffers. */
51 int s_size[6];
52 /** dimension of sub meshes to recv. */
53 int r_dim[6][3];
54 /** lower left corners of sub meshes to recv. */
55 int r_ld[6][3];
56 /** upper right corners of sub meshes to recv. */
57 int r_ur[6][3];
58 /** sizes for recv buffers. */
59 int r_size[6];
60 /** maximal size for send/recv buffers (both directions of a dimension). */
61 int max = -1;
62
63 /** vector to store grid points to send. */
64 std::vector<FloatType> send_grid;
65 /** vector to store grid points to recv */
66 std::vector<FloatType> recv_grid;
67
68 /**
69 * Exchange halo blocks with both neighbors along one dimension.
70 * Send buffer layout: [to left | to right],
71 * recv buffer layout: [from right | from left].
72 */
73 void exchange(boost::mpi::communicator const &comm, int left, int right,
74 int send_left, int send_right, int recv_right, int recv_left,
75 int tag);
76
77public:
78 void resize(boost::mpi::communicator const &comm,
79 P3MLocalMesh const &local_mesh);
80 void gather_grid(boost::mpi::communicator const &comm,
81 std::span<FloatType *> meshes, Utils::Vector3i const &dim);
82 void gather_grid(boost::mpi::communicator const &comm, FloatType *mesh,
83 Utils::Vector3i const &dim) {
84 gather_grid(comm, std::span(&mesh, 1u), dim);
85 }
86 void spread_grid(boost::mpi::communicator const &comm,
87 std::span<FloatType *> meshes, Utils::Vector3i const &dim);
88 void spread_grid(boost::mpi::communicator const &comm, FloatType *mesh,
89 Utils::Vector3i const &dim) {
90 spread_grid(comm, std::span(&mesh, 1u), dim);
91 }
92};
93
94#endif // defined(ESPRESSO_P3M) or defined(ESPRESSO_DP3M)
Vector implementation and trait types for boost qvm interoperability.
P3M halo communicator.
Definition send_mesh.hpp:38
void gather_grid(boost::mpi::communicator const &comm, std::span< FloatType * > meshes, Utils::Vector3i const &dim)
void spread_grid(boost::mpi::communicator const &comm, FloatType *mesh, Utils::Vector3i const &dim)
Definition send_mesh.hpp:88
void gather_grid(boost::mpi::communicator const &comm, FloatType *mesh, Utils::Vector3i const &dim)
Definition send_mesh.hpp:82
void spread_grid(boost::mpi::communicator const &comm, std::span< FloatType * > meshes, Utils::Vector3i const &dim)
void resize(boost::mpi::communicator const &comm, P3MLocalMesh const &local_mesh)
Definition send_mesh.cpp:93
VectorXi< 3 > Vector3i
Definition Vector.hpp:216
Common functions for dipolar and charge P3M.
Properties of the local mesh and halo region.