From ec9d7b146f93e53af7fb900c323403f93eb7242c Mon Sep 17 00:00:00 2001 From: James E McClure Date: Wed, 24 Jan 2018 16:24:36 -0500 Subject: [PATCH] Added TestMap from ScaLBL --- tests/CMakeLists.txt | 1 + tests/TestMap.cpp | 270 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 271 insertions(+) create mode 100644 tests/TestMap.cpp diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 5a4ec2ec..f5204e49 100755 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -36,6 +36,7 @@ ADD_LBPM_TEST( pmmc_cylinder ) #ADD_LBPM_TEST( TestBubble ) ADD_LBPM_TEST( TestTorus ) ADD_LBPM_TEST( TestFluxBC ) +ADD_LBPM_TEST( TestMap ) ADD_LBPM_TEST( TestInterfaceSpeed ) ADD_LBPM_TEST( TestSphereCurvature ) #ADD_LBPM_TEST_1_2_4( TestTwoPhase ) diff --git a/tests/TestMap.cpp b/tests/TestMap.cpp new file mode 100644 index 00000000..3006879c --- /dev/null +++ b/tests/TestMap.cpp @@ -0,0 +1,270 @@ + +//************************************************************************* +// Lattice Boltzmann Simulator for Single Phase Flow in Porous Media +// James E. McCLure +//************************************************************************* +#include +#include +#include +#include "common/ScaLBL.h" +#include "common/MPI_Helpers.h" + +using namespace std; + +//*************************************************************************************** +int main(int argc, char **argv) +{ + //***************************************** + // ***** MPI STUFF **************** + //***************************************** + // Initialize MPI + int rank,nprocs; + MPI_Init(&argc,&argv); + MPI_Comm comm = MPI_COMM_WORLD; + MPI_Comm_rank(comm,&rank); + MPI_Comm_size(comm,&nprocs); + int check; + { + // parallel domain size (# of sub-domains) + int nprocx,nprocy,nprocz; + int iproc,jproc,kproc; + + + if (rank == 0){ + printf("********************************************************\n"); + printf("Running Color Model: TestColor \n"); + printf("********************************************************\n"); + } + + // BGK Model parameters + string FILENAME; + unsigned int nBlocks, nthreads; + int timestepMax, interval; + double Fx,Fy,Fz,tol; + // Domain variables + double Lx,Ly,Lz; + int nspheres; + int Nx,Ny,Nz; + int i,j,k,n; + int dim=5; + + static int D3Q19[18][3]={{1,0,0},{-1,0,0},{0,1,0},{0,-1,0},{0,0,1},{0,0,-1}, + {1,1,0},{-1,-1,0},{1,-1,0},{-1,1,0}, + {1,0,1},{-1,0,-1},{1,0,-1},{-1,0,1}, + {0,1,1},{0,-1,-1},{0,1,-1},{0,-1,1}}; + + if (rank==0){ + //....................................................................... + // Reading the domain information file + //....................................................................... + ifstream domain("Domain.in"); + if (domain.good()){ + domain >> nprocx; + domain >> nprocy; + domain >> nprocz; + domain >> Nx; + domain >> Ny; + domain >> Nz; + domain >> nspheres; + domain >> Lx; + domain >> Ly; + domain >> Lz; + } + else if (nprocs==1){ + nprocx=nprocy=nprocz=1; + Nx=Ny=Nz=5; + nspheres=0; + Lx=Ly=Lz=1; + } + else if (nprocs==2){ + nprocx=2; nprocy=1; + nprocz=1; + Nx=Ny=Nz=dim; + Nx = dim; Ny = dim; Nz = dim; + nspheres=0; + Lx=Ly=Lz=1; + } + else if (nprocs==4){ + nprocx=nprocy=2; + nprocz=1; + Nx=Ny=Nz=dim; + nspheres=0; + Lx=Ly=Lz=1; + } + else if (nprocs==8){ + nprocx=nprocy=nprocz=2; + Nx=Ny=Nz=dim; + nspheres=0; + Lx=Ly=Lz=1; + } + //....................................................................... + } + // ************************************************************** + // Broadcast simulation parameters from rank 0 to all other procs + MPI_Barrier(comm); + //................................................. + 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); + // ************************************************************** + // ************************************************************** + + if (nprocs != nprocx*nprocy*nprocz){ + printf("nprocx = %i \n",nprocx); + printf("nprocy = %i \n",nprocy); + printf("nprocz = %i \n",nprocz); + INSIST(nprocs == nprocx*nprocy*nprocz,"Fatal error in processor count!"); + } + + if (rank==0){ + printf("********************************************************\n"); + printf("Sub-domain size = %i x %i x %i\n",Nx,Ny,Nz); + printf("********************************************************\n"); + } + + MPI_Barrier(comm); + int BoundaryCondition=0; + + Domain Dm(Nx,Ny,Nz,rank,nprocx,nprocy,nprocz,Lx,Ly,Lz,BoundaryCondition); + + Nx += 2; + Ny += 2; + Nz += 2; + int N = Nx*Ny*Nz; + + //....................................................................... + int Np = 0; + for (k=1;k