Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Message Exchange #136

Merged
merged 3 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ if(TEST_INTERPOLATION)
add_executable(aether ${SRC_FILES} ${MSIS_FILES} ${MAIN_DIR}/main_test_interpolation.cpp)
elseif(TEST_COORD)
add_executable(aether ${SRC_FILES} ${MSIS_FILES} ${MAIN_DIR}/main_test_coord.cpp)
elseif(TEST_EXCHANGE)
add_executable(aether ${SRC_FILES} ${MSIS_FILES} ${MAIN_DIR}/main_test_exchange.cpp)
set(USE_DOUBLE_PRECISION True)
else()
add_executable(aether ${SRC_FILES} ${MSIS_FILES} ${MAIN_DIR}/main.cpp)
endif()
Expand Down
21 changes: 21 additions & 0 deletions include/grid.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#ifndef INCLUDE_GRID_H_
#define INCLUDE_GRID_H_

#include <unordered_map>
#include "mpi.h"

// ----------------------------------------------------------------------------
Expand Down Expand Up @@ -167,6 +168,9 @@ class Grid {
void report_grid_boundaries();
void calc_cent_acc(Planets planet);

// Update ghost cells with values from other processors
void exchange(arma_cube &data, const bool pole_inverse);

// Need to move these to private at some point:

bool IsLatLonGrid;
Expand Down Expand Up @@ -334,6 +338,23 @@ class Grid {

// Processed interpolation coefficients
std::vector<struct interp_coef_t> interp_coefs;

// Initialize connections between processors
void init_connection();
// Used for message exchange
struct idx2d_t {
// Index of row and column
int64_t ilon;
int64_t ilat;
// -1 if message crosses the north/south pole, 1 otherwise
int inverse;
};
// Store which processor needs its value
std::unordered_map<int, std::vector<struct interp_coef_t>> exch_send;
// Store which processor it gets value from
std::unordered_map<int, std::vector<struct idx2d_t>> exch_recv;
// The communicator for set of processors whose iMembers are equal
MPI_Comm grid_comm;
};

#endif // INCLUDE_GRID_H_
1 change: 1 addition & 0 deletions include/neutrals.h
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ class Neutrals {
\param grid The grid to define the neutrals on
**/
bool exchange(Grid &grid);
bool exchange_old(Grid &grid);

/**********************************************************************
\brief add eddy contributions to vertical acceleration
Expand Down
6 changes: 6 additions & 0 deletions include/tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,4 +237,10 @@ bool is_nan_inf(double value);

std::vector<int> indef_vector(arma_cube cube);

// --------------------------------------------------------------------------
// Project a point described by lon and lat to a point on a surface of the 2-2-2 cube
// --------------------------------------------------------------------------

arma_vec sphere_to_cube(precision_t lon_in, precision_t lat_in);

#endif // INCLUDE_TOOLS_H_
2 changes: 1 addition & 1 deletion src/exchange_messages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ Grid::messages_struct Grid::make_new_interconnection(int64_t iDir,
// 5. Unpack variables from all sides
// -----------------------------------------------------------------------------

bool Neutrals::exchange(Grid &grid) {
bool Neutrals::exchange_old(Grid &grid) {

std::string function = "Neutrals::exchange";
static int iFunction = -1;
Expand Down
Loading
Loading