1 #ifndef SRC_EXCHANGER_EXCHANGER_HPP_
2 #define SRC_EXCHANGER_EXCHANGER_HPP_
5 #include <athena/mesh/mesh.hpp>
8 #include <configure.hpp>
21 mpi_comm_ = MPI_COMM_WORLD;
30 virtual bool UnpackData(MeshBlock
const *pmb) {
return true; }
33 virtual void Transfer(MeshBlock
const *pmb,
int n = -1) = 0;
47 using ExchangerBase::mpi_comm_;
51 for (
int n = 0; n < MessageTraits<T>::num_buffers; ++n) {
53 req_mpi_send_[n] = MPI_REQUEST_NULL;
54 req_mpi_recv_[n] = MPI_REQUEST_NULL;
60 for (
int n = 0; n < MessageTraits<T>::num_buffers; ++n) {
62 req_mpi_send_[n] = MPI_REQUEST_NULL;
63 req_mpi_recv_[n] = MPI_REQUEST_NULL;
65 if (mpi_comm_ != MPI_COMM_WORLD) {
66 MPI_Comm_free(&mpi_comm_);
74 for (
int n = 0; n < MessageTraits<T>::num_buffers; ++n) {
76 MPI_Wait(&req_mpi_send_[n], MPI_STATUS_IGNORE);
118 void find_neighbors(MeshBlock
const *pmb, CoordinateDirection dir,
119 NeighborBlock *bblock, NeighborBlock *tblock);
122 template <
typename T>
129 using Base::mpi_comm_;
130 using Base::req_mpi_recv_;
131 using Base::req_mpi_send_;
137 void Transfer(MeshBlock
const *pmb,
int n = -1)
override;
143 template <
typename T>
148 using Base::mpi_comm_;
155 void Regroup(MeshBlock
const *pmb, CoordinateDirection dir);
165 template <
typename T>
virtual void Transfer(MeshBlock const *pmb, int n=-1)=0
Send and receive data.
virtual void PackData(MeshBlock const *pmb)
Pack data to send buffer.
virtual bool UnpackData(MeshBlock const *pmb)
Unpack data from receive buffer.
typename MessageTraits< T >::DataType DataType
std::vector< DataType > BufferType
BufferType recv_buffer_[MessageTraits< T >::num_buffers]
void SetBoundaryStatus(int bid, BoundaryStatus status)
Set the boundary status.
enum BoundaryStatus status_flag_[MessageTraits< T >::num_buffers]
virtual void ClearBuffer(MeshBlock const *pmb)
Clear buffer.
BufferType send_buffer_[MessageTraits< T >::num_buffers]
std::vector< int > color_
MPI color of each block.
std::vector< int > brank_
MPI rank of the bottom of each block.
int GetRankInGroup() const
void Regroup(MeshBlock const *pmb, CoordinateDirection dir)
void ClearBuffer(MeshBlock const *pmb) override
Clear buffer.
void Transfer(MeshBlock const *pmb, int n=-1) override
Send and receive data.
NeighborBlock const * find_back_neighbor(MeshBlock const *pmb)
find back neighbor block
NeighborBlock const * find_left_neighbor(MeshBlock const *pmb)
find left neighbor block
NeighborBlock const * find_front_neighbor(MeshBlock const *pmb)
find front neighbor block
NeighborBlock const * find_bot_neighbor(MeshBlock const *pmb)
find bottom neighbor block
NeighborBlock const * find_top_neighbor(MeshBlock const *pmb)
find top neighbor block
NeighborBlock const * find_right_neighbor(MeshBlock const *pmb)
find right neighbor block
void find_neighbors(MeshBlock const *pmb, CoordinateDirection dir, NeighborBlock *bblock, NeighborBlock *tblock)
find neighbors in one coordinate direction
Traits class providing Message information for class T.