⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mpicart.cc

📁 Flens库-一个在C++的矩阵运算库
💻 CC
字号:
#include <poisson_solver/flens_impl/mpicart.h>#include <cstdlib>#include <iostream>namespace flens {MpiCart::MpiCart(){}MpiCart::MpiCart(int argc, char **argv)    : numRows(1), numCols(1){    MPI::Init(argc, argv);    if (argc==3) {        numRows = std::atoi(argv[1]);        numCols = std::atoi(argv[2]);    } else {        if (MPI::COMM_WORLD.Get_rank()==0) {            std::cerr << "usage: " << argv[0] << " numRows numCols" << std::endl;        }        std::exit(0);    }    // create mpi_cart:  2-dimensional, non-periodic    int  dims[2];    bool periods[2];    dims[0]    = numRows;    dims[1]    = numCols;    periods[0] = false;    periods[1] = false;    comm = MPI::COMM_WORLD.Create_cart(2, dims, periods, true);    // find your position in the cart    int rank = MPI::COMM_WORLD.Get_rank();    int coords[2];    comm.Get_coords(rank, 2, coords);    row = coords[0];    col = coords[1];    // find your neighbors    enum CartDir { North=0, East=1, South=2, West=3 };    comm.Shift(0, 1, neighbors[South], neighbors[North]);    comm.Shift(1, 1, neighbors[West],  neighbors[East]);}MpiCart::MpiCart(const MpiCart &rhs)    : comm(rhs.comm),      numRows(rhs.numRows), numCols(rhs.numCols),      row(rhs.row), col(rhs.col){    neighbors[North] = rhs.neighbors[North];    neighbors[East]  = rhs.neighbors[East];    neighbors[South] = rhs.neighbors[South];    neighbors[West]  = rhs.neighbors[West];}} // namespace flens

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -