From a0b24b99341923b58da877c43dd8f6c9f543b83f Mon Sep 17 00:00:00 2001 From: James McClure Date: Fri, 20 Mar 2015 12:27:00 -0400 Subject: [PATCH] UPdate tests/lbpm_BlobAnalysis --- tests/lbpm_BlobAnalysis.cpp | 243 ++++++++++++++++++++++++++++++++++++ 1 file changed, 243 insertions(+) create mode 100644 tests/lbpm_BlobAnalysis.cpp diff --git a/tests/lbpm_BlobAnalysis.cpp b/tests/lbpm_BlobAnalysis.cpp new file mode 100644 index 00000000..766b4a8f --- /dev/null +++ b/tests/lbpm_BlobAnalysis.cpp @@ -0,0 +1,243 @@ +/* +This code computes TCAT averages on a blob-by-blob basis in parallel +It requires that the blobs be labeled using BlobIdentify.cpp +James E. McClure 2015 + */ + +#include +#include +#include +#include +#include +#include +#include + +#include "Domain.h" +#include "TwoPhase.h" +#include "common/MPI_Helpers.h" +#include "common/Utilities.h" + +inline void ReadBlobLabel(char *FILENAME, int *Data, int N) +{ + int n; + int value; + ifstream File(FILENAME,ios::binary); + if (File.good()){ + for (n=0; n 1){ + nblobs_global = atoi(argv[1]); + if (rank==0) printf("Number of global blobs is: %i \n",nblobs_global); + } + else{ + ERROR("Number of blobs was not specified"); + } + + int *CubeList; + + if (rank==0){ + //....................................................................... + // Reading the domain information file + //....................................................................... + ifstream domain("Domain.in"); + domain >> nprocx; + domain >> nprocy; + domain >> nprocz; + domain >> Nx; + domain >> Ny; + domain >> Nz; + domain >> nspheres; + domain >> Lx; + domain >> Ly; + domain >> Lz; + //....................................................................... + } + //................................................. + MPI_Barrier(MPI_COMM_WORLD); + // Computational domain + MPI_Bcast(&Nx,1,MPI_INT,0,MPI_COMM_WORLD); + MPI_Bcast(&Ny,1,MPI_INT,0,MPI_COMM_WORLD); + MPI_Bcast(&Nz,1,MPI_INT,0,MPI_COMM_WORLD); + MPI_Bcast(&nprocx,1,MPI_INT,0,MPI_COMM_WORLD); + MPI_Bcast(&nprocy,1,MPI_INT,0,MPI_COMM_WORLD); + MPI_Bcast(&nprocz,1,MPI_INT,0,MPI_COMM_WORLD); + MPI_Bcast(&nspheres,1,MPI_INT,0,MPI_COMM_WORLD); + MPI_Bcast(&Lx,1,MPI_DOUBLE,0,MPI_COMM_WORLD); + MPI_Bcast(&Ly,1,MPI_DOUBLE,0,MPI_COMM_WORLD); + MPI_Bcast(&Lz,1,MPI_DOUBLE,0,MPI_COMM_WORLD); + MPI_Barrier(MPI_COMM_WORLD); + //................................................. + Domain Dm(Nx,Ny,Nz,rank,nprocx,nprocy,nprocz,Lx,Ly,Lz,BC); + TwoPhase Averages(Dm); + BlobTwoPhase BlobAverages(nblobs_global); + //....................................................................... + // Filenames used + char LocalRankString[8]; + char LocalRankFilename[40]; + char LocalRestartFile[40]; + char tmpstr[10]; + sprintf(LocalRankString,"%05d",rank); + sprintf(LocalRankFilename,"%s%s","ID.",LocalRankString); + sprintf(LocalRestartFile,"%s%s","Restart.",LocalRankString); + //........................................................................... + if (rank == 0) cout << "Reading in domain from signed distance function..." << endl; + //....................................................................... + sprintf(LocalRankFilename,"%s%s","SignDist.",LocalRankString); + ReadBinaryFile(LocalRankFilename, Averages.SDs.data, N); + MPI_Barrier(MPI_COMM_WORLD); + if (rank == 0) cout << "Domain set." << endl; + //....................................................................... + sprintf(LocalRankFilename,"%s%s","BlobLabel.",LocalRankString); + ReadBlobFile(LocalRankFilename, Averages.BlobLabel.data, N); + MPI_Barrier(MPI_COMM_WORLD); + if (rank == 0) cout << "BlobLabel set." << endl; + //....................................................................... + //copies of data needed to perform checkpointing from cpu + double *Den, *DistEven, *DistOdd; + Den = new double[2*N]; + DistEven = new double[10*N]; + DistOdd = new double[9*N]; + //......................................................................... + if (rank==0) printf("Reading restart file! \n"); + // Read in the restart file to CPU buffers + ReadCheckpoint(LocalRestartFile, Den, DistEven, DistOdd, N); + MPI_Barrier(MPI_COMM_WORLD); + //......................................................................... + // Populate the arrays needed to perform averaging + for (int n=0; n