Canoe
Comprehensive Atmosphere N' Ocean Engine
decomposition.hpp
Go to the documentation of this file.
1 #ifndef SRC_SNAP_DECOMPOSITION_DECOMPOSITION_HPP_
2 #define SRC_SNAP_DECOMPOSITION_DECOMPOSITION_HPP_
3 
4 // C/C++
5 #include <memory>
6 
7 // athena
8 #include <athena/athena.hpp>
9 #include <athena/bvals/bvals.hpp>
10 
11 // MPI headers
12 #ifdef MPI_PARALLEL
13 #include <mpi.h>
14 #endif
15 
16 class MeshBlock;
17 template <typename T>
19 
21  public:
22  // data
24  NeighborBlock tblock, bblock;
25 
26  // functions
27  explicit Decomposition(MeshBlock *pmb);
29  void FindNeighbors();
30  int CreateMPITag(int lid, int bufid, int phy);
31 
32  void RecvFromTop(AthenaArray<Real> &psf, int kl, int ku, int jl, int ju);
33  void SendToBottom(AthenaArray<Real> const &psf, int kl, int ku, int jl,
34  int ju);
35  void SyncNewVariables(AthenaArray<Real> const &w, int kl, int ku, int jl,
36  int ju);
37  void WaitToFinishSync(AthenaArray<Real> &w, int kl, int ku, int jl, int ju);
38 
40  int ku, int jl, int ju);
41 
42  void RecvBuffer(AthenaArray<Real> &psf, int kl, int ku, int jl, int ju,
43  int il, int iu, NeighborBlock nb);
44  void SendBuffer(AthenaArray<Real> const &psf, int kl, int ku, int jl, int ju);
45  void PopulateBotEntropy(AthenaArray<Real> const &w, int kl, int ku, int jl,
46  int ju);
47  void WaitToFinishSend();
48 
49  void ChangeToPerturbation(AthenaArray<Real> &w, int kl, int ku, int jl,
50  int ju);
52  AthenaArray<Real> &wr, int k, int j, int il,
53  int iu);
54 
55  void ChangeToBuoyancy(AthenaArray<Real> &w, int kl, int ku, int jl, int ju);
57  AthenaArray<Real> &wr, int k, int j, int il, int iu);
58 
59  void ChangeToEntropy(AthenaArray<Real> &w, int kl, int ku, int jl, int ju);
61  AthenaArray<Real> &wr, int k, int j, int il, int iu);
62 
63  private:
64  MeshBlock *pmy_block_;
65 
66  // pressure decomposition
68  AthenaArray<Real> pres_, dens_; // save of original w
69  //
70  Real *buffer_, *send_buffer_; // MPI data buffer
71  Real *wsend_top_, *wrecv_top_; // MPI data buffer
72  Real *wsend_bot_, *wrecv_bot_; // MPI data buffer
73  int *brank_, *color_; // bottom block rank and color
74 
75  AthenaArray<Real> entropy_; // adiabatic index and pseudo entropy
76  AthenaArray<Real> gamma_; // adiabatic index
77 
78 #ifdef MPI_PARALLEL
79  MPI_Request req_send_top_;
80  MPI_Request req_send_bot_;
81  MPI_Request req_send_sync_top_;
82  MPI_Request req_send_sync_bot_;
83  MPI_Request req_recv_sync_top_;
84  MPI_Request req_recv_sync_bot_;
85 #endif
86 };
87 
88 using DecompositionPtr = std::shared_ptr<Decomposition>;
89 
90 #endif // SRC_SNAP_DECOMPOSITION_DECOMPOSITION_HPP_
void RecvBuffer(AthenaArray< Real > &psf, int kl, int ku, int jl, int ju, int il, int iu, NeighborBlock nb)
AthenaArray< Real > psf_
AthenaArray< Real > gamma_
NeighborBlock tblock
MeshBlock * pmy_block_
void ChangeToEntropy(AthenaArray< Real > &w, int kl, int ku, int jl, int ju)
AthenaArray< Real > pres_
AthenaArray< Real > dens_
void WaitToFinishSync(AthenaArray< Real > &w, int kl, int ku, int jl, int ju)
void ApplyHydroBoundary(AthenaArray< Real > &w, AthenaArray< Real > &psf, int kl, int ku, int jl, int ju)
void RecvFromTop(AthenaArray< Real > &psf, int kl, int ku, int jl, int ju)
NeighborBlock bblock
int CreateMPITag(int lid, int bufid, int phy)
void SyncNewVariables(AthenaArray< Real > const &w, int kl, int ku, int jl, int ju)
AthenaArray< Real > psv_
Decomposition(MeshBlock *pmb)
void WaitToFinishSend()
void RestoreFromBuoyancy(AthenaArray< Real > &w, AthenaArray< Real > &wl, AthenaArray< Real > &wr, int k, int j, int il, int iu)
void SendBuffer(AthenaArray< Real > const &psf, int kl, int ku, int jl, int ju)
void ChangeToBuoyancy(AthenaArray< Real > &w, int kl, int ku, int jl, int ju)
void RestoreFromEntropy(AthenaArray< Real > &w, AthenaArray< Real > &wl, AthenaArray< Real > &wr, int k, int j, int il, int iu)
AthenaArray< Real > entropy_
void FindNeighbors()
void RestoreFromPerturbation(AthenaArray< Real > &w, AthenaArray< Real > &wl, AthenaArray< Real > &wr, int k, int j, int il, int iu)
void ChangeToPerturbation(AthenaArray< Real > &w, int kl, int ku, int jl, int ju)
void SendToBottom(AthenaArray< Real > const &psf, int kl, int ku, int jl, int ju)
void PopulateBotEntropy(AthenaArray< Real > const &w, int kl, int ku, int jl, int ju)
std::shared_ptr< Decomposition > DecompositionPtr