preCICE v3.1.2
Loading...
Searching...
No Matches
MPICommunication.hpp
Go to the documentation of this file.
1#ifndef PRECICE_NO_MPI
2
3#pragma once
4
5#include <mpi.h>
6#include <string>
7
10#include "logging/Logger.hpp"
12
13namespace precice {
14namespace com {
22public:
24
27 {
28 }
29
35 virtual void send(std::string const &itemToSend, Rank rankReceiver) override;
36
38 virtual void send(precice::span<const int> itemsToSend, Rank rankReceiver) override;
39
41 virtual PtrRequest aSend(precice::span<const int> itemsToSend, Rank rankReceiver) override;
42
44 virtual void send(precice::span<const double> itemsToSend, Rank rankReceiver) override;
45
47 virtual PtrRequest aSend(precice::span<const double> itemsToSend, Rank rankReceiver) override;
48
54 virtual void send(double itemToSend, Rank rankReceiver) override;
55
57 virtual PtrRequest aSend(const double &itemToSend, Rank rankReceiver) override;
58
64 virtual void send(int itemToSend, Rank rankReceiver) override;
65
67 virtual PtrRequest aSend(const int &itemToSend, Rank rankReceiver) override;
68
74 virtual void send(bool itemToSend, Rank rankReceiver) override;
75
77 virtual PtrRequest aSend(const bool &itemToSend, Rank rankReceiver) override;
78
84 virtual void receive(std::string &itemToReceive, Rank rankSender) override;
85
87 virtual void receive(precice::span<int> itemsToReceive, Rank rankSender) override;
88
90 virtual void receive(precice::span<double> itemsToReceive, Rank rankSender) override;
91
93 virtual PtrRequest aReceive(precice::span<double> itemsToReceive, int rankSender) override;
94
100 virtual void receive(double &itemToReceive, Rank rankSender) override;
101
103 virtual PtrRequest aReceive(double &itemToReceive, Rank rankSender) override;
104
110 virtual void receive(int &itemToReceive, Rank rankSender) override;
111
113 virtual PtrRequest aReceive(int &itemToReceive, Rank rankSender) override;
114
120 virtual void receive(bool &itemToReceive, Rank rankSender) override;
121
123 virtual PtrRequest aReceive(bool &itemToReceive, Rank rankSender) override;
124
125protected:
128
129 virtual Rank rank(int rank) = 0;
130
131private:
132 logging::Logger _log{"com::MPICommunication"};
133};
134} // namespace com
135} // namespace precice
136
137#endif // not PRECICE_NO_MPI
Interface for all interprocess communication classes.
Provides implementation for basic MPI point-to-point communication.
virtual void receive(std::string &itemToReceive, Rank rankSender) override
Receives a std::string from process with given rank.
virtual PtrRequest aReceive(precice::span< double > itemsToReceive, int rankSender) override
Asynchronously receives an array of double values.
virtual MPI_Comm & communicator(Rank rank)=0
Returns the communicator.
virtual PtrRequest aSend(precice::span< const int > itemsToSend, Rank rankReceiver) override
Asynchronously sends an array of integer values.
virtual void send(std::string const &itemToSend, Rank rankReceiver) override
Sends a std::string to process with given rank.
virtual ~MPICommunication()
Destructor, empty.
virtual Rank rank(int rank)=0
This class provides a lightweight logger.
Definition Logger.hpp:16
A C++ 11 implementation of the non-owning C++20 std::span type.
Definition span.hpp:284
Main namespace of the precice library.
int Rank
Definition Types.hpp:37