#include "mpi.h" #include #include "fem.h" void LoadBalance3d(Mesh *mesh){ int n,p,k,v,f; int nprocs = mesh->nprocs; int procid = mesh->procid; int **EToV = mesh->EToV; double **VX = mesh->GX; double **VY = mesh->GY; double **VZ = mesh->GZ; if(!procid) printf("Root: Entering LoadBalance\n"); int Nverts = mesh->Nverts; int *Kprocs = BuildIntVector(nprocs); /* local number of elements */ int Klocal = mesh->K; /* find number of elements on all processors */ MPI_Allgather(&Klocal, 1, MPI_INT, Kprocs, 1, MPI_INT, MPI_COMM_WORLD); /* element distribution -- cumulative element count on processes */ idxtype *elmdist = idxmalloc(nprocs+1, "elmdist"); elmdist[0] = 0; for(p=0;pGX!=NULL){ DestroyMatrix(mesh->GX); DestroyMatrix(mesh->GY); DestroyMatrix(mesh->GZ); DestroyIntMatrix(mesh->EToV); } mesh->GX = newVX; mesh->GY = newVY; mesh->GZ = newVZ; mesh->EToV = newEToV; mesh->K = totalinK; for(p=0;p