From 9f06e9cafaaabb9057faf1698a212926f07e6fb6 Mon Sep 17 00:00:00 2001 From: James E McClure Date: Sat, 26 May 2018 08:38:32 -0400 Subject: [PATCH] input database for lbpm_segmented_pp --- tests/lbpm_segmented_pp.cpp | 71 +++++++++++-------------------------- 1 file changed, 20 insertions(+), 51 deletions(-) diff --git a/tests/lbpm_segmented_pp.cpp b/tests/lbpm_segmented_pp.cpp index aea481b4..f70a6841 100644 --- a/tests/lbpm_segmented_pp.cpp +++ b/tests/lbpm_segmented_pp.cpp @@ -131,63 +131,32 @@ int main(int argc, char **argv) // char fluidValue,solidValue; int MAXTIME=1000; int READ_FROM_BLOCK=0; - if (argc > 1){ - MAXTIME=atoi(argv[1]); - } - if (argc > 2){ - READ_FROM_BLOCK=atoi(argv[2]); - } - std::vector solidValues; - std::vector nwpValues; - std::string line; + string filename; + if (argc > 1) filename=argv[1]; + else ERROR("No input database provided\n"); + // read the input database + auto db = std::make_shared( filename ); + auto domain_db = db->getDatabase( "Domain" ); - if (rank==0){ - ifstream domain("Domain.in"); - domain >> nprocx; - domain >> nprocy; - domain >> nprocz; - domain >> nx; - domain >> ny; - domain >> nz; - domain >> nspheres; - domain >> Lx; - domain >> Ly; - domain >> Lz; + // Read domain parameters + auto L = domain_db->getVector( "L" ); + auto size = domain_db->getVector( "n" ); + auto nproc = domain_db->getVector( "nproc" ); + auto ReadValues = domain_db->getVector( "ReadValues" ); + auto WriteValues = domain_db->getVector( "WriteValues" ); - } - MPI_Barrier(comm); - // Computational domain - MPI_Bcast(&nx,1,MPI_INT,0,comm); - MPI_Bcast(&ny,1,MPI_INT,0,comm); - MPI_Bcast(&nz,1,MPI_INT,0,comm); - MPI_Bcast(&nprocx,1,MPI_INT,0,comm); - MPI_Bcast(&nprocy,1,MPI_INT,0,comm); - MPI_Bcast(&nprocz,1,MPI_INT,0,comm); - MPI_Bcast(&nspheres,1,MPI_INT,0,comm); - MPI_Bcast(&Lx,1,MPI_DOUBLE,0,comm); - MPI_Bcast(&Ly,1,MPI_DOUBLE,0,comm); - MPI_Bcast(&Lz,1,MPI_DOUBLE,0,comm); - //................................................. - MPI_Barrier(comm); - - // 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); - fflush(stdout); - - } - if ( nprocs < nprocx*nprocy*nprocz ){ - ERROR("Insufficient number of processors"); - } - - char LocalRankFilename[40]; + nx = size[0]; + ny = size[1]; + nz = size[2]; + nprocx = nproc[0]; + nprocy = nproc[1]; + nprocz = nproc[2]; int N = (nx+2)*(ny+2)*(nz+2); - std::shared_ptr Dm (new Domain(nx,ny,nz,rank,nprocx,nprocy,nprocz,Lx,Ly,Lz,BC)); + std::shared_ptr Dm (new Domain(db,comm)); + // std::shared_ptr Dm (new Domain(nx,ny,nz,rank,nprocx,nprocy,nprocz,Lx,Ly,Lz,BC)); for (n=0; nid[n]=1; Dm->CommInit(); std::shared_ptr Averages( new TwoPhase(Dm) );