// Sequential component labeling for two phase systems // Reads parallel simulation data and performs connectivity analysis // and averaging on a blob-by-blob basis // James E. McClure 2015 #include #include #include "analysis/analysis.h" #include "analysis/TwoPhase.h" #define NUM_AVERAGES 30 using namespace std; inline void ReadFromRank(char *FILENAME, DoubleArray &Phase, DoubleArray &Pressure, DoubleArray &Vel_x, DoubleArray &Vel_y, DoubleArray &Vel_z, int nx, int ny, int nz, int iproc, int jproc, int kproc) { int i,j,k,q,n,N; int iglobal,jglobal,kglobal; double value; double denA,denB; double f0,f1,f2,f3,f4,f5,f6,f7,f8,f9; double f10,f11,f12,f13,f14,f15,f16,f17,f18; double vx,vy,vz; N = nx*ny*nz; double *Den, *DistEven, *DistOdd; Den = new double[2*N]; DistEven = new double[10*N]; DistOdd = new double[9*N]; 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; //....................................................................... nx+=2; ny+=2; nz+=2; nprocs = nprocx*nprocy*nprocz; printf("Number of MPI ranks: %i \n", nprocs); int BoundaryCondition=0; Nx = (nx-2)*nprocx; Ny = (ny-2)*nprocy; Nz = (nz-2)*nprocz; Domain Dm(Nx,Ny,Nz,rank,1,1,1,Lx,Ly,Lz,BoundaryCondition); Nx+=2; Ny+=2; Nz+=2; printf("Full domain size: %i x %i x %i \n", Nx,Ny,Nz); TwoPhase Averages(Dm); // Filenames used char LocalRankString[8]; char LocalRankFilename[40]; char BaseFilename[20]; sprintf(BaseFilename,"%s","dPdt."); int proc,iglobal,kglobal,jglobal; double * Temp; Temp = new double[nx*ny*nz]; // read the files and populate main arrays for ( kproc=0; kproc 0.0){ porosity += 1.0; } Averages.SDs(i,j,k) -= (1.0); } } } porosity /= (Nx*Ny*Nz*1.0); //printf("Media porosity is %f \n",porosity); double beta=0.95; int timestep=5; Averages.Initialize(); Averages.ComputeDelPhi(); Averages.ColorToSignedDistance(beta,Averages.Phase,Averages.SDn); Averages.UpdateMeshValues(); Averages.ComponentAverages(); Averages.SortBlobs(); Averages.PrintComponents(timestep); // Create the MeshDataStruct fillHalo fillData(Dm.Comm,Dm.rank_info,{Nx-2,Ny-2,Nz-2},{1,1,1},0,1); std::vector meshData(1); meshData[0].meshName = "domain"; meshData[0].mesh = std::shared_ptr( new IO::DomainMesh(Dm.rank_info,Nx-2,Ny-2,Nz-2,Lx,Ly,Lz) ); std::shared_ptr PhaseVar( new IO::Variable() ); std::shared_ptr SignDistVar( new IO::Variable() ); std::shared_ptr LabelWPVar( new IO::Variable() ); std::shared_ptr LabelNWPVar( new IO::Variable() ); std::shared_ptr PhaseIDVar( new IO::Variable() ); PhaseVar->name = "phase"; PhaseVar->type = IO::VariableType::VolumeVariable; PhaseVar->dim = 1; PhaseVar->data.resize(Nx-2,Ny-2,Nz-2); meshData[0].vars.push_back(PhaseVar); SignDistVar->name = "SignDist"; SignDistVar->type = IO::VariableType::VolumeVariable; SignDistVar->dim = 1; SignDistVar->data.resize(Nx-2,Ny-2,Nz-2); meshData[0].vars.push_back(SignDistVar); LabelNWPVar->name = "LabelNWP"; LabelNWPVar->type = IO::VariableType::VolumeVariable; LabelNWPVar->dim = 1; LabelNWPVar->data.resize(Nx-2,Ny-2,Nz-2); meshData[0].vars.push_back(LabelNWPVar); LabelWPVar->name = "LabelWP"; LabelWPVar->type = IO::VariableType::VolumeVariable; LabelWPVar->dim = 1; LabelWPVar->data.resize(Nx-2,Ny-2,Nz-2); meshData[0].vars.push_back(LabelWPVar); PhaseIDVar->name = "PhaseID"; PhaseIDVar->type = IO::VariableType::VolumeVariable; PhaseIDVar->dim = 1; PhaseIDVar->data.resize(Nx-2,Ny-2,Nz-2); meshData[0].vars.push_back(PhaseIDVar); fillData.copy(Averages.SDn,PhaseVar->data); fillData.copy(Averages.SDs,SignDistVar->data); fillData.copy(Averages.Label_WP,LabelWPVar->data); fillData.copy(Averages.Label_NWP,LabelNWPVar->data); fillData.copy(Averages.PhaseID,PhaseIDVar->data); IO::writeData( 0, meshData, comm ); /* FILE *NWP_FILE; NWP_FILE = fopen("NWP.dat","wb"); fwrite(Averages.Label_NWP.get(),4,Nx*Ny*Nz,NWP_FILE); fclose(NWP_FILE); FILE *WP_FILE; WP_FILE = fopen("WP.dat","wb"); fwrite(Averages.Label_WP.get(),4,Nx*Ny*Nz,WP_FILE); fclose(WP_FILE); FILE *DISTANCE; DISTANCE = fopen("SignDist.dat","wb"); fwrite(Averages.SDs.get(),8,Nx*Ny*Nz,DISTANCE); fclose(DISTANCE); */ // **************************************************** MPI_Barrier(comm); MPI_Finalize(); // **************************************************** }