From 91def9d84130e97d676c10c4b43bd42d7bcf8ea5 Mon Sep 17 00:00:00 2001 From: James E McClure Date: Tue, 2 Jun 2015 15:17:09 -0400 Subject: [PATCH] Created tests/BlobAnalyzeParallel from tests/BlobIdentifyParallel --- tests/BlobAnalyzeParallel.cpp | 131 ++++++++++++++++++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 tests/BlobAnalyzeParallel.cpp diff --git a/tests/BlobAnalyzeParallel.cpp b/tests/BlobAnalyzeParallel.cpp new file mode 100644 index 00000000..e772f5da --- /dev/null +++ b/tests/BlobAnalyzeParallel.cpp @@ -0,0 +1,131 @@ +// Sequential blob analysis +// Reads parallel simulation data and performs connectivity analysis +// and averaging on a blob-by-blob basis +// James E. McClure 2014 + +#include +#include +#include "common/pmmc.h" +#include "common/Communication.h" +#include "analysis/analysis.h" +#include "ProfilerApp.h" + + +//#include "Domain.h" + +using namespace std; + + +inline void ReadBinaryFile(char *FILENAME, double *Data, int N) +{ + int n; + double value; + ifstream File(FILENAME,ios::binary); + for (n=0; n> nprocx; + domain >> nprocy; + domain >> nprocz; + domain >> nx; + domain >> ny; + domain >> nz; + domain >> nspheres; + domain >> Lx; + domain >> Ly; + domain >> Lz; + + // Check that the number of processors >= the number of ranks + if ( rank==0 ) { + printf("Number of MPI ranks required: %i \n", nprocx*nprocy*nprocz); + printf("Number of MPI ranks used: %i \n", nprocs); + printf("Full domain size: %i x %i x %i \n",nx*nprocx,ny*nprocy,nz*nprocz); + } + if ( nprocs < nprocx*nprocy*nprocz ) + ERROR("Insufficient number of processors"); + + // Get the rank info + const RankInfoStruct rank_info(rank,nprocx,nprocy,nprocz); + + // Read the local file + DoubleArray Phase; + DoubleArray SignDist; + readRankData( rank, nx+2, ny+2, nz+2, Phase, SignDist ); + + // Communication the halos + fillHalo fillData(rank_info,nx,ny,nz,1,1,1,0,1); + fillData.fill(Phase); + fillData.fill(SignDist); + + // Find blob domains + if ( rank==0 ) { printf("Finding blob domains\n"); } + double vF=0.0; + double vS=0.0; + IntArray GlobalBlobID; + int nblobs = ComputeGlobalBlobIDs(nx,ny,nz,rank_info, + Phase,SignDist,vF,vS,GlobalBlobID); + if ( rank==0 ) { printf("Identified %i blobs\n",nblobs); } + + // Write the local blob ids + char LocalRankFilename[100]; + sprintf(LocalRankFilename,"BlobLabel.%05i",rank); + FILE *BLOBLOCAL = fopen(LocalRankFilename,"wb"); + fwrite(GlobalBlobID.get(),4,GlobalBlobID.length(),BLOBLOCAL); + fclose(BLOBLOCAL); + printf("Wrote BlobLabel.%05i \n",rank); + + + /*FILE *BLOBS = fopen("Blobs.dat","wb"); + fwrite(GlobalBlobID.get(),4,Nx*Ny*Nz,BLOBS); + fclose(BLOBS);*/ + + PROFILE_STOP("main"); + PROFILE_SAVE("BlobIdentifyParallel",false); + MPI_Barrier(MPI_COMM_WORLD); + MPI_Finalize(); + return 0; +} +