From 83f7526cf1d7bd08fc08a601f3c1ff978a112860 Mon Sep 17 00:00:00 2001 From: James E McClure Date: Wed, 15 Jul 2015 09:12:49 -0400 Subject: [PATCH] Refactor tests/ComponentLabel to use TwoPhase.h --- tests/ComponentLabel.cpp | 193 ++++++++++++--------------------------- 1 file changed, 60 insertions(+), 133 deletions(-) diff --git a/tests/ComponentLabel.cpp b/tests/ComponentLabel.cpp index 61e243f5..9b6fde17 100644 --- a/tests/ComponentLabel.cpp +++ b/tests/ComponentLabel.cpp @@ -7,7 +7,7 @@ #include #include "common/pmmc.h" #include "analysis/analysis.h" -//#include "Domain.h" +#include "TwoPhase.h" #define NUM_AVERAGES 30 @@ -179,10 +179,18 @@ inline void ReadFromRank(char *FILENAME, DoubleArray &Phase, DoubleArray &Pressu int main(int argc, char **argv) { + // Initialize MPI + int rank,nprocs; + MPI_Init(&argc,&argv); + MPI_Comm_rank(MPI_COMM_WORLD,&rank); + MPI_Comm_size(MPI_COMM_WORLD,&nprocs); + printf("----------------------------------------------------------\n"); printf("COMPUTING TCAT ANALYSIS FOR NON-WETTING PHASE FEATURES \n"); printf("----------------------------------------------------------\n"); + if (nprocs != 1) INSIST(nprocs == 1,"Error: ComponentLabel --serial case!"); + //....................................................................... int nprocx,nprocy,nprocz,nprocs; int Nx, Ny, Nz; @@ -214,19 +222,17 @@ int main(int argc, char **argv) nprocs = nprocx*nprocy*nprocz; printf("Number of MPI ranks: %i \n", nprocs); - Nx = (nx-2)*nprocx+2; - Ny = (ny-2)*nprocy+2; - Nz = (nz-2)*nprocz+2; + 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); - DoubleArray Phase(Nx,Ny,Nz); - DoubleArray SignDist(Nx,Ny,Nz); - DoubleArray Press(Nx,Ny,Nz); - DoubleArray Vel_x(Nx,Ny,Nz); // Velocity - DoubleArray Vel_y(Nx,Ny,Nz); - DoubleArray Vel_z(Nx,Ny,Nz); - DoubleArray dPdt(Nx,Ny,Nz); + TwoPhase Averages(Dm); + // Filenames used char LocalRankString[8]; char LocalRankFilename[40]; @@ -252,8 +258,8 @@ int main(int argc, char **argv) proc = kproc*nprocx*nprocy + jproc*nprocx + iproc; - sprintf(LocalRankString,"%05d",proc); - sprintf(LocalRankFilename,"%s%s","dPdt.",LocalRankString); + // sprintf(LocalRankString,"%05d",proc); + // sprintf(LocalRankFilename,"%s%s","dPdt.",LocalRankString); // printf("Reading file %s \n",LocalRankFilename); ReadBinaryFile(LocalRankFilename, Temp, nx*ny*nz); for (k=1; k fluid_isovalue) - - int n_nw_pts=0,n_ns_pts=0,n_ws_pts=0,n_nws_pts=0; - int n_nw_tris=0, n_ns_tris=0, n_ws_tris=0, n_nws_seg=0; - - //double s,s1,s2,s3; // Triangle sides (lengths) - Point A,B,C,P; - // double area; - int cube[8][3] = {{0,0,0},{1,0,0},{0,1,0},{1,1,0},{0,0,1},{1,0,1},{0,1,1},{1,1,1}}; // cube corners - // int count_in=0,count_out=0; - // int nodx,nody,nodz; - // initialize lists for vertices for surfaces, common line - DTMutableList nw_pts(20); - DTMutableList ns_pts(20); - DTMutableList ws_pts(20); - DTMutableList nws_pts(20); - // initialize triangle lists for surfaces - IntArray nw_tris(3,20); - IntArray ns_tris(3,20); - IntArray ws_tris(3,20); - // initialize list for line segments - IntArray nws_seg(2,20); - DTMutableList tmp(20); - - // Initialize arrays for local solid surface - DTMutableList local_sol_pts(20); - int n_local_sol_pts = 0; - IntArray local_sol_tris(3,18); - int n_local_sol_tris; - DoubleArray values(20); - DTMutableList local_nws_pts(20); - int n_local_nws_pts; - - DoubleArray CubeValues(2,2,2); - DoubleArray Values(20); - DoubleArray ContactAngle(20); - DoubleArray Curvature(20); - DoubleArray DistValues(20); - DoubleArray InterfaceSpeed(20); - DoubleArray NormalVector(60); - DoubleArray van(3); - DoubleArray vaw(3); - DoubleArray vawn(3); - DoubleArray Gwn(6); - DoubleArray Gns(6); - DoubleArray Gws(6); - //........................................................................... - - printf("Execute blob identification algorithm... \n"); + Dm.CommInit(MPI_COMM_WORLD); /* **************************************************************** IDENTIFY ALL COMPONENTS FOR BOTH PHASES ****************************************************************** */ - int number_NWP_components = ComputeLocalPhaseComponent(PhaseLabel,1,NWP,true); - int number_WP_components = ComputeLocalPhaseComponent(PhaseLabel,2,WP,true); + // int number_NWP_components = ComputeLocalPhaseComponent(PhaseLabel,1,NWP,true); + //int number_WP_components = ComputeLocalPhaseComponent(PhaseLabel,2,WP,true); - printf("Number of WP components = %i \n",number_WP_components); - printf("Number of NWP components = %i \n",number_NWP_components); - - DoubleArray BlobAverages(NUM_AVERAGES,number_NWP_components); + //printf("Number of WP components = %i \n",number_WP_components); + //printf("Number of NWP components = %i \n",number_NWP_components); // Map the signed distance for the analysis for (i=0; i