1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
|
#include "includes.h"
#include "typedefs.h"
#include "mesh.h"
#include "blas.h"
#include "partitioning.h"
#include "utilities.h"
//#include "metis.h"
int main(int argc, char* argv[])
{
int num_procs, myrank;
MPI_Init(&argc, &argv);
MPI_Status status;
MPI_Comm_size(MPI_COMM_WORLD, &num_procs);
MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
VecIdx_t Local2Global;
VecVecIdx_t Local_Local2Global;
Blas Blas;
Utilities Utilities;
VecInt_t MPI_reps;
size_t size_mpi_reps = 0;
size_t size_l2g = 0;
size_t nNodes_global = 0;
int tag = 1;
if (myrank == 0) {
Partitioning Partitioning("mesh.txt");
Global_Coordinate = Partitioning.Global_Coordinate_;
Connectivity = Partitioning.Master_Rank_Connectivity_;
Coordinate = Partitioning.Master_Rank_Coordinate_;
MPI_reps = Partitioning.MPI_reps_;
//Local_Local2Global = Partitioning.Local_Local2Global_;
//size_l2g = Local_Local2Global[0].size();
//Local2Global = Partitioning.Local_Local2Global_[0];
//nNodes_global = Partitioning.nNodes_global_;
VecVecIdx_t Local_Local2Global;
Local_Local2Global.resize(2);
Local_Local2Global[0] = { 0,1,3 };
Local_Local2Global[1] = { 0,2,3 };
Local2Global = Partitioning.Local_Local2Global_[0];
for (int i_proc = 0; i_proc < num_procs; i_proc++) {
if (i_proc == 0) {
}
else {
size_t size_local2global = Local_Local2Global[i_proc].size();
MPI_Send(&size_local2global, 1, MPI_INT, i_proc, tag, MPI_COMM_WORLD);
MPI_Send(Local_Local2Global[i_proc].data(), Local_Local2Global[i_proc].size(), MPI_INT, i_proc, tag, MPI_COMM_WORLD);
}
}
}
else {
MPI_Recv(&size_l2g, 1, MPI_INT, 0, tag, MPI_COMM_WORLD, &status);
Local2Global.resize(size_l2g);
MPI_Recv(Local2Global.data(), size_l2g, MPI_INT, 0, tag, MPI_COMM_WORLD, &status);
//MPI_Recv(&nNodes_global, 1, MPI_UNSIGNED, 0, 0, MPI_COMM_WORLD, &status);
//int n;
//MPI_Recv(&n, 1, MPI_INT, 0, tag, MPI_COMM_WORLD, &status);
//MPI_Recv(a.data(), n, MPI_DOUBLE, 0, tag, MPI_COMM_WORLD, &status);
}
printf("process %d prainting local2global\n", myrank);
for (int i = 0; i < Local2Global.size(); i++)
{
printf("%d \t", Local2Global[i], myrank);
printf("\n");
}
MPI_Finalize();
return 0;
}
| |