From 1ba427456cc34b8f594470ad7a837cbc36934a32 Mon Sep 17 00:00:00 2001 From: James E McClure Date: Tue, 15 May 2018 14:34:32 -0400 Subject: [PATCH 1/4] refactor TestPressVel --- tests/TestPressVel.cpp | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/tests/TestPressVel.cpp b/tests/TestPressVel.cpp index bdd67aec..7e352c99 100644 --- a/tests/TestPressVel.cpp +++ b/tests/TestPressVel.cpp @@ -155,25 +155,20 @@ int main(int argc, char **argv) printf("Reduced domain size = %i \n",Np); } - // LBM variables - if (rank==0) printf ("Allocating distributions \n"); - - int neighborSize=18*Np*sizeof(int); + if (rank==0) printf ("Set up the neighborlist \n"); + int Npad=Np+32; + int neighborSize=18*Npad*sizeof(int); int *neighborList; IntArray Map(Nx,Ny,Nz); - - neighborList= new int[18*Np]; - ScaLBL_Comm.MemoryOptimizedLayoutAA(Map,neighborList,Dm.id,Np); - // ScaLBL_Comm.MemoryDenseLayoutFull(Map,neighborList,Dm.id,Np); // this was how I tested for correctness - + neighborList= new int[18*Npad]; + Np = ScaLBL_Comm.MemoryOptimizedLayoutAA(Map,neighborList,Dm.id,Np); MPI_Barrier(comm); //......................device distributions................................. + if (rank==0) printf ("Allocating distributions \n"); int dist_mem_size = Np*sizeof(double); - int *NeighborList; - // double *f_even,*f_odd; double * dist; double * Velocity; //........................................................................... @@ -187,7 +182,6 @@ int main(int argc, char **argv) * AA Algorithm begins here * */ - //ScaLBL_D3Q19_Init(ID, dist, &dist[10*Np], Np, 1, 1); double *DIST; DIST = new double [19*Np]; double VALUE=0.1; @@ -215,7 +209,6 @@ int main(int argc, char **argv) DIST[17*Np + n] = 1.0; DIST[18*Np + n] = 1.0; } - ScaLBL_CopyToDevice(dist, DIST, 19*Np*sizeof(double)); From 2288dd7bd98db3debc6114b1eb244970ec70e860 Mon Sep 17 00:00:00 2001 From: James E McClure Date: Tue, 15 May 2018 14:40:38 -0400 Subject: [PATCH 2/4] refactor TestPressVel --- tests/TestPressVel.cpp | 40 +++++++++------------------------------- 1 file changed, 9 insertions(+), 31 deletions(-) diff --git a/tests/TestPressVel.cpp b/tests/TestPressVel.cpp index 7e352c99..db19ba2c 100644 --- a/tests/TestPressVel.cpp +++ b/tests/TestPressVel.cpp @@ -10,21 +10,6 @@ #include "common/MPI_Helpers.h" -std::shared_ptr loadInputs( int nprocs ) -{ - auto db = std::make_shared( "Domain.in" ); - const int dim = 50; - db->putScalar( "BC", 0 ); - if ( nprocs == 1 ){ - db->putVector( "nproc", { 1, 1, 1 } ); - db->putVector( "n", { 4, 4, 4 } ); - db->putScalar( "nspheres", 0 ); - db->putVector( "L", { 1, 1, 1 } ); - } - return db; -} - - //*************************************************************************************** int main(int argc, char **argv) { @@ -59,14 +44,15 @@ int main(int argc, char **argv) Fz = 1.0e-4; // Load inputs - auto db = loadInputs( nprocs ); - int Nx = db->getVector( "n" )[0]; - int Ny = db->getVector( "n" )[1]; - int Nz = db->getVector( "n" )[2]; - int nprocx = db->getVector( "nproc" )[0]; - int nprocy = db->getVector( "nproc" )[1]; - int nprocz = db->getVector( "nproc" )[2]; - + if (rank==0) printf("Loading input database \n"); + auto db = std::make_shared(FILENAME); + auto domain_db= db-> getDatabase("Domain"); + int Nx = domain_db->getVector( "n" )[0]; + int Ny = domain_db->getVector( "n" )[1]; + int Nz = domain_db->getVector( "n" )[2]; + int nprocx = domain_db->getVector( "nproc" )[0]; + int nprocy = domain_db->getVector( "nproc" )[1]; + int nprocz = domain_db->getVector( "nproc" )[2]; if (rank==0){ printf("********************************************************\n"); printf("Sub-domain size = %i x %i x %i\n",Nx,Ny,Nz); @@ -91,7 +77,6 @@ int main(int argc, char **argv) Domain Dm(db); - Nx += 2; Ny += 2; Nz += 2; @@ -104,12 +89,6 @@ int main(int argc, char **argv) sprintf(LocalRankString,"%05d",rank); char LocalRankFilename[40]; sprintf(LocalRankFilename,"ID.%05i",rank); - /* - FILE *IDFILE = fopen(LocalRankFilename,"rb"); - if (IDFILE==NULL) ERROR("Error opening file: ID.xxxxx"); - fread(Dm.id,1,N,IDFILE); - fclose(IDFILE); - */ Dm.CommInit(comm); @@ -211,7 +190,6 @@ int main(int argc, char **argv) } ScaLBL_CopyToDevice(dist, DIST, 19*Np*sizeof(double)); - double *Vz; Vz= new double [Np]; size_t SIZE=Np*sizeof(double); From 820a173a48bd6483bcaa384698d82f37cfcd3dca Mon Sep 17 00:00:00 2001 From: James E McClure Date: Tue, 15 May 2018 15:00:26 -0400 Subject: [PATCH 3/4] refatoring tests --- tests/CMakeLists.txt | 6 +++--- tests/TestForceMoments.cpp | 24 +++++++++++------------- tests/TestInterfaceSpeed.cpp | 21 ++++----------------- tests/TestPoiseuille.cpp | 3 +-- tests/TestPressVel.cpp | 4 ++-- 5 files changed, 21 insertions(+), 37 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 2121a88b..e43d7ee1 100755 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -46,13 +46,13 @@ ADD_LBPM_TEST( TestColorGrad ) ADD_LBPM_TEST( TestBubbleDFH ) ADD_LBPM_TEST( TestColorGradDFH ) ADD_LBPM_TEST( TestColorMassBounceback ) -ADD_LBPM_TEST( TestPressVel ) +ADD_LBPM_TEST( TestPressVel ../example/Piston/input.db) ADD_LBPM_TEST( TestPoiseuille ../example/Piston/input.db) -ADD_LBPM_TEST( TestForceMoments ) +ADD_LBPM_TEST( TestForceMoments ../example/Piston/input.db) ADD_LBPM_TEST( TestForceD3Q19 ) ADD_LBPM_TEST( TestMomentsD3Q19 ) -ADD_LBPM_TEST( TestInterfaceSpeed ) +ADD_LBPM_TEST( TestInterfaceSpeed ../example/Piston/input.db) ADD_LBPM_TEST( TestSphereCurvature ) #ADD_LBPM_TEST_1_2_4( TestTwoPhase ) ADD_LBPM_TEST_1_2_4( TestBlobIdentify ) diff --git a/tests/TestForceMoments.cpp b/tests/TestForceMoments.cpp index fe842dc7..ed917730 100644 --- a/tests/TestForceMoments.cpp +++ b/tests/TestForceMoments.cpp @@ -11,8 +11,6 @@ using namespace std; - - extern void PrintNeighborList(int * neighborList, int Np, int rank) { if (rank == 0) { int n; @@ -63,7 +61,6 @@ int main(int argc, char **argv) // parallel domain size (# of sub-domains) int iproc,jproc,kproc; - if (rank == 0){ printf("********************************************************\n"); printf("Running Unit Test: TestForceMoments \n"); @@ -71,7 +68,6 @@ int main(int argc, char **argv) } // BGK Model parameters - string FILENAME; unsigned int nBlocks, nthreads; int timestepMax, interval; double tau,Fx,Fy,Fz,tol; @@ -88,16 +84,18 @@ int main(int argc, char **argv) Fx = Fy = 1.0; Fz = 1.0; - // Load inputs - auto db = loadInputs( nprocs ); - int Nx = db->getVector( "n" )[0]; - int Ny = db->getVector( "n" )[1]; - int Nz = db->getVector( "n" )[2]; - int nprocx = db->getVector( "nproc" )[0]; - int nprocy = db->getVector( "nproc" )[1]; - int nprocz = db->getVector( "nproc" )[2]; - + string FILENAME = argv[1]; + // Load inputs + if (rank==0) printf("Loading input database \n"); + auto db = std::make_shared(FILENAME); + auto domain_db= db-> getDatabase("Domain"); + int Nx = domain_db->getVector( "n" )[0]; + int Ny = domain_db->getVector( "n" )[1]; + int Nz = domain_db->getVector( "n" )[2]; + int nprocx = domain_db->getVector( "nproc" )[0]; + int nprocy = domain_db->getVector( "nproc" )[1]; + int nprocz = domain_db->getVector( "nproc" )[2]; if (rank==0){ printf("********************************************************\n"); printf("Sub-domain size = %i x %i x %i\n",Nx,Ny,Nz); diff --git a/tests/TestInterfaceSpeed.cpp b/tests/TestInterfaceSpeed.cpp index 53cc55ae..4bf47688 100644 --- a/tests/TestInterfaceSpeed.cpp +++ b/tests/TestInterfaceSpeed.cpp @@ -15,20 +15,6 @@ #define SPEED -1 #define PI 3.14159 - -std::shared_ptr loadInputs( int nprocs ) -{ - auto db = std::make_shared( ); - const int dim = 50; - db->putScalar( "BC", 0 ); - db->putVector( "nproc", { 1, 1, 1 } ); - db->putVector( "n", { N, N, N } ); - db->putScalar( "nspheres", 0 ); - db->putVector( "L", { 1, 1, 1 } ); - return db; -} - - int main (int argc, char *argv[]) { // Initialize MPI @@ -39,10 +25,11 @@ int main (int argc, char *argv[]) MPI_Comm_size(comm,&nprocs); int i,j,k,n; - // Load inputs - auto db = loadInputs( nprocs ); + // Load inputs + string FILENAME = argv[1]; + auto db = loadInputs( FILENAME ); - Domain Dm(db); + Domain Dm(db); for (i=0; i(FILENAME); @@ -159,7 +159,6 @@ int main(int argc, char **argv) printf("Reduced domain size = %i \n",Np); } - // LBM variables if (rank==0) printf ("Allocating distributions \n"); if (rank==0) printf ("Set up the neighborlist \n"); diff --git a/tests/TestPressVel.cpp b/tests/TestPressVel.cpp index db19ba2c..164e498f 100644 --- a/tests/TestPressVel.cpp +++ b/tests/TestPressVel.cpp @@ -29,9 +29,8 @@ int main(int argc, char **argv) printf("Running Unit Test: TestPressVel \n"); printf("********************************************************\n"); } - + // BGK Model parameters - string FILENAME; unsigned int nBlocks, nthreads; int timestepMax, interval; double tau,Fx,Fy,Fz,tol; @@ -44,6 +43,7 @@ int main(int argc, char **argv) Fz = 1.0e-4; // Load inputs + string FILENAME = argv[1]; if (rank==0) printf("Loading input database \n"); auto db = std::make_shared(FILENAME); auto domain_db= db-> getDatabase("Domain"); From 7528a3497205285e9356f26956570e83fe8ca170 Mon Sep 17 00:00:00 2001 From: James E McClure Date: Tue, 15 May 2018 15:06:28 -0400 Subject: [PATCH 4/4] refactr --- tests/TestInterfaceSpeed.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/TestInterfaceSpeed.cpp b/tests/TestInterfaceSpeed.cpp index 4bf47688..92082ab6 100644 --- a/tests/TestInterfaceSpeed.cpp +++ b/tests/TestInterfaceSpeed.cpp @@ -27,8 +27,16 @@ int main (int argc, char *argv[]) int i,j,k,n; // Load inputs string FILENAME = argv[1]; - auto db = loadInputs( FILENAME ); - + // Load inputs + if (rank==0) printf("Loading input database \n"); + auto db = std::make_shared(FILENAME); + auto domain_db= db-> getDatabase("Domain"); + int Nx = domain_db->getVector( "n" )[0]; + int Ny = domain_db->getVector( "n" )[1]; + int Nz = domain_db->getVector( "n" )[2]; + int nprocx = domain_db->getVector( "nproc" )[0]; + int nprocy = domain_db->getVector( "nproc" )[1]; + int nprocz = domain_db->getVector( "nproc" )[2]; Domain Dm(db); for (i=0; i