From ed6853345cdaf4fb35406c9914518e594a03ed6a Mon Sep 17 00:00:00 2001 From: James E McClure Date: Tue, 6 Aug 2019 13:02:24 -0400 Subject: [PATCH] refactor lbpm_serial_decomp --- common/Domain.cpp | 550 +++++++++++++++++------------------ tests/lbpm_serial_decomp.cpp | 331 +-------------------- 2 files changed, 276 insertions(+), 605 deletions(-) diff --git a/common/Domain.cpp b/common/Domain.cpp index 3d912305..42761ef8 100644 --- a/common/Domain.cpp +++ b/common/Domain.cpp @@ -231,7 +231,8 @@ void Domain::Decomp(std::shared_ptr domain_db ) //....................................................................... // Reading the domain information file //....................................................................... - int rank_offset = 0; + int rank_offset = 0; + int rank = 0; int nprocs, nprocx, nprocy, nprocz, nx, ny, nz; int64_t global_Nx,global_Ny,global_Nz; int64_t i,j,k,n; @@ -248,301 +249,298 @@ void Domain::Decomp(std::shared_ptr domain_db ) outlet_layers_y = 0; outlet_layers_z = 0; checkerSize = 32; - - // read the input database - //auto db = std::make_shared( filename ); - //auto domain_db = db->getDatabase( "Domain" ); - // Read domain parameters - auto Filename = domain_db->getScalar( "Filename" ); - //auto L = domain_db->getVector( "L" ); - auto size = domain_db->getVector( "n" ); - auto SIZE = domain_db->getVector( "N" ); - auto nproc = domain_db->getVector( "nproc" ); - if (domain_db->keyExists( "offset" )){ - auto offset = domain_db->getVector( "offset" ); - xStart = offset[0]; - yStart = offset[1]; - zStart = offset[2]; - } - if (domain_db->keyExists( "InletLayers" )){ - auto InletCount = domain_db->getVector( "InletLayers" ); - inlet_layers_x = InletCount[0]; - inlet_layers_y = InletCount[1]; - inlet_layers_z = InletCount[2]; - } - if (domain_db->keyExists( "OutletLayers" )){ - auto OutletCount = domain_db->getVector( "OutletLayers" ); - outlet_layers_x = OutletCount[0]; - outlet_layers_y = OutletCount[1]; - outlet_layers_z = OutletCount[2]; - } - if (domain_db->keyExists( "checkerSize" )){ - checkerSize = domain_db->getScalar( "checkerSize" ); - } - else { - checkerSize = SIZE[0]; - } - auto ReadValues = domain_db->getVector( "ReadValues" ); - auto WriteValues = domain_db->getVector( "WriteValues" ); - auto ReadType = domain_db->getScalar( "ReadType" ); - if (ReadType == "8bit"){ - } - else if (ReadType == "16bit"){ - } - else{ - printf("INPUT ERROR: Valid ReadType are 8bit, 16bit \n"); - ReadType = "8bit"; - } - - nx = size[0]; - ny = size[1]; - nz = size[2]; - nprocx = nproc[0]; - nprocy = nproc[1]; - nprocz = nproc[2]; - global_Nx = SIZE[0]; - global_Ny = SIZE[1]; - global_Nz = SIZE[2]; - - printf("Input media: %s\n",Filename.c_str()); - printf("Relabeling %lu values\n",ReadValues.size()); - for (int idx=0; idxgetScalar( "Filename" ); + //auto L = domain_db->getVector( "L" ); + auto size = domain_db->getVector( "n" ); + auto SIZE = domain_db->getVector( "N" ); + auto nproc = domain_db->getVector( "nproc" ); + if (domain_db->keyExists( "offset" )){ + auto offset = domain_db->getVector( "offset" ); + xStart = offset[0]; + yStart = offset[1]; + zStart = offset[2]; + } + if (domain_db->keyExists( "InletLayers" )){ + auto InletCount = domain_db->getVector( "InletLayers" ); + inlet_layers_x = InletCount[0]; + inlet_layers_y = InletCount[1]; + inlet_layers_z = InletCount[2]; + } + if (domain_db->keyExists( "OutletLayers" )){ + auto OutletCount = domain_db->getVector( "OutletLayers" ); + outlet_layers_x = OutletCount[0]; + outlet_layers_y = OutletCount[1]; + outlet_layers_z = OutletCount[2]; + } + if (domain_db->keyExists( "checkerSize" )){ + checkerSize = domain_db->getScalar( "checkerSize" ); + } + else { + checkerSize = SIZE[0]; + } + auto ReadValues = domain_db->getVector( "ReadValues" ); + auto WriteValues = domain_db->getVector( "WriteValues" ); + auto ReadType = domain_db->getScalar( "ReadType" ); if (ReadType == "8bit"){ - printf("Reading 8-bit input data \n"); - FILE *SEGDAT = fopen(Filename.c_str(),"rb"); - if (SEGDAT==NULL) ERROR("Domain.cpp: Error reading segmented data"); - size_t ReadSeg; - ReadSeg=fread(SegData,1,SIZE,SEGDAT); - if (ReadSeg != size_t(SIZE)) printf("Domain.cpp: Error reading segmented data \n"); - fclose(SEGDAT); } else if (ReadType == "16bit"){ - printf("Reading 16-bit input data \n"); - short int *InputData; - InputData = new short int[SIZE]; - FILE *SEGDAT = fopen(Filename.c_str(),"rb"); - if (SEGDAT==NULL) ERROR("Domain.cpp: Error reading segmented data"); - size_t ReadSeg; - ReadSeg=fread(InputData,2,SIZE,SEGDAT); - if (ReadSeg != size_t(SIZE)) printf("Domain.cpp: Error reading segmented data \n"); - fclose(SEGDAT); - for (int n=0; n 0){ - // use checkerboard pattern - printf("Checkerboard pattern at x inlet for %i layers \n",inlet_layers_x); - for (int k = 0; k 0){ - printf("Checkerboard pattern at y inlet for %i layers \n",inlet_layers_y); - // use checkerboard pattern - for (int k = 0; k 0){ - printf("Checkerboard pattern at z inlet for %i layers \n",inlet_layers_z); - // use checkerboard pattern - for (int k = zStart; k < zStart+inlet_layers_z; k++){ - for (int j = 0; j 0){ - // use checkerboard pattern - printf("Checkerboard pattern at x outlet for %i layers \n",outlet_layers_x); - for (int k = 0; k 0){ - printf("Checkerboard pattern at y outlet for %i layers \n",outlet_layers_y); - // use checkerboard pattern - for (int k = 0; k 0){ - printf("Checkerboard pattern at z outlet for %i layers \n",outlet_layers_z); - // use checkerboard pattern - for (int k = zStart + nz*nprocz - outlet_layers_z; k < zStart + nz*nprocz; k++){ - for (int j = 0; j LabelCount(ReadValues.size(),0); - // Set up the sub-domains - if (rank()==0){ - printf("Distributing subdomains across %i processors \n",nprocs); - printf("Process grid: %i x %i x %i \n",nprocx,nprocy,nprocz); - printf("Subdomain size: %i x %i x %i \n",nx,ny,nz); - printf("Size of transition region: %ld \n", z_transition_size); - - for (int kp=0; kp 0){ + // use checkerboard pattern + printf("Checkerboard pattern at x inlet for %i layers \n",inlet_layers_x); + for (int k = 0; k 0){ + printf("Checkerboard pattern at y inlet for %i layers \n",inlet_layers_y); + // use checkerboard pattern + for (int k = 0; k 0){ + printf("Checkerboard pattern at z inlet for %i layers \n",inlet_layers_z); + // use checkerboard pattern + for (int k = zStart; k < zStart+inlet_layers_z; k++){ + for (int j = 0; j 0){ + // use checkerboard pattern + printf("Checkerboard pattern at x outlet for %i layers \n",outlet_layers_x); + for (int k = 0; k 0){ + printf("Checkerboard pattern at y outlet for %i layers \n",outlet_layers_y); + // use checkerboard pattern + for (int k = 0; k 0){ + printf("Checkerboard pattern at z outlet for %i layers \n",outlet_layers_z); + // use checkerboard pattern + for (int k = zStart + nz*nprocz - outlet_layers_z; k < zStart + nz*nprocz; k++){ + for (int j = 0; j LabelCount(ReadValues.size(),0); + // Set up the sub-domains + if (rank==0){ + printf("Distributing subdomains across %i processors \n",nprocs); + printf("Process grid: %i x %i x %i \n",nprocx,nprocy,nprocz); + printf("Subdomain size: %i x %i x %i \n",nx,ny,nz); + printf("Size of transition region: %ld \n", z_transition_size); + + for (int kp=0; kp 3){ - rank_offset = atoi(argv[3]); - } - else{ - MULTINPUT=true; - rank_offset=0; - } - */ string filename; if (argc > 1) filename=argv[1]; @@ -44,320 +25,12 @@ int main(int argc, char **argv) } int rank_offset=0; - //....................................................................... - // Reading the domain information file - //....................................................................... - int nprocs, nprocx, nprocy, nprocz, nx, ny, nz, nspheres; - double Lx, Ly, Lz; - int64_t Nx,Ny,Nz; - int64_t i,j,k,n; - int BC=0; - int64_t xStart,yStart,zStart; - int checkerSize; - int inlet_count_x, inlet_count_y, inlet_count_z; - int outlet_count_x, outlet_count_y, outlet_count_z; - // char fluidValue,solidValue; - - xStart=yStart=zStart=0; - inlet_count_x = 0; - inlet_count_y = 0; - inlet_count_z = 0; - outlet_count_x = 0; - outlet_count_y = 0; - outlet_count_z = 0; - checkerSize = 32; // read the input database auto db = std::make_shared( filename ); auto domain_db = db->getDatabase( "Domain" ); - - // Read domain parameters - auto Filename = domain_db->getScalar( "Filename" ); - //auto L = domain_db->getVector( "L" ); - auto size = domain_db->getVector( "n" ); - auto SIZE = domain_db->getVector( "N" ); - auto nproc = domain_db->getVector( "nproc" ); - if (domain_db->keyExists( "offset" )){ - auto offset = domain_db->getVector( "offset" ); - xStart = offset[0]; - yStart = offset[1]; - zStart = offset[2]; - } - if (domain_db->keyExists( "InletLayers" )){ - auto InletCount = domain_db->getVector( "InletLayers" ); - inlet_count_x = InletCount[0]; - inlet_count_y = InletCount[1]; - inlet_count_z = InletCount[2]; - } - if (domain_db->keyExists( "OutletLayers" )){ - auto OutletCount = domain_db->getVector( "OutletLayers" ); - outlet_count_x = OutletCount[0]; - outlet_count_y = OutletCount[1]; - outlet_count_z = OutletCount[2]; - } - if (domain_db->keyExists( "checkerSize" )){ - checkerSize = domain_db->getScalar( "checkerSize" ); - } - else { - checkerSize = SIZE[0]; - } - auto ReadValues = domain_db->getVector( "ReadValues" ); - auto WriteValues = domain_db->getVector( "WriteValues" ); - auto ReadType = domain_db->getScalar( "ReadType" ); - if (ReadType == "8bit"){ - } - else if (ReadType == "16bit"){ - } - else{ - printf("INPUT ERROR: Valid ReadType are 8bit, 16bit \n"); - ReadType = "8bit"; - } - - nx = size[0]; - ny = size[1]; - nz = size[2]; - nprocx = nproc[0]; - nprocy = nproc[1]; - nprocz = nproc[2]; - Nx = SIZE[0]; - Ny = SIZE[1]; - Nz = SIZE[2]; - - printf("Input media: %s\n",Filename.c_str()); - printf("Relabeling %lu values\n",ReadValues.size()); - for (int idx=0; idx 0){ - // use checkerboard pattern - printf("Checkerboard pattern at x inlet for %i layers \n",inlet_count_x); - for (int k = 0; k 0){ - printf("Checkerboard pattern at y inlet for %i layers \n",inlet_count_y); - // use checkerboard pattern - for (int k = 0; k Dm (new Domain(domain_db,comm)); - if (inlet_count_z > 0){ - printf("Checkerboard pattern at z inlet for %i layers \n",inlet_count_z); - // use checkerboard pattern - for (int k = zStart; k < zStart+inlet_count_z; k++){ - for (int j = 0; jDecomp(domain_db); - if (outlet_count_x > 0){ - // use checkerboard pattern - printf("Checkerboard pattern at x outlet for %i layers \n",outlet_count_x); - for (int k = 0; k 0){ - printf("Checkerboard pattern at y outlet for %i layers \n",outlet_count_y); - // use checkerboard pattern - for (int k = 0; k 0){ - printf("Checkerboard pattern at z outlet for %i layers \n",outlet_count_z); - // use checkerboard pattern - for (int k = zStart + nz*nprocz - outlet_count_z; k < zStart + nz*nprocz; k++){ - for (int j = 0; j LabelCount(ReadValues.size(),0); - // Set up the sub-domains - if (rank==0){ - printf("Distributing subdomains across %i processors \n",nprocs); - printf("Process grid: %i x %i x %i \n",nprocx,nprocy,nprocz); - printf("Subdomain size: %i x %i x %i \n",nx,ny,nz); - printf("Size of transition region: %ld \n", z_transition_size); - - for (int kp=0; kp