Preventing errors if unit tests do not have a valid Domain.in file

This commit is contained in:
James E McClure 2016-01-08 12:52:01 -05:00
parent 3de7b47867
commit a043dd82c2
2 changed files with 77 additions and 21 deletions

View File

@ -149,16 +149,44 @@ int main(int argc, char **argv)
if (rank==0){ if (rank==0){
ifstream domain("Domain.in"); ifstream domain("Domain.in");
domain >> nprocx; if (domain.good()){
domain >> nprocy; domain >> nprocx;
domain >> nprocz; domain >> nprocy;
domain >> nx; domain >> nprocz;
domain >> ny; domain >> nx;
domain >> nz; domain >> ny;
domain >> nspheres; domain >> nz;
domain >> Lx; domain >> nspheres;
domain >> Ly; domain >> Lx;
domain >> Lz; domain >> Ly;
domain >> Lz;
}
else if (nprocs==1){
nprocx=nprocy=nprocz=1;
nx=ny=nz=50;
nspheres=0;
Lx=Ly=Lz=1;
}
else if (nprocs==2){
nprocx=nprocy=1;
nprocz=2;
nx=ny=nz=50;
nspheres=0;
Lx=Ly=Lz=1;
}
else if (nprocs==4){
nprocx=nprocy=2;
nprocz=1;
nx=ny=nz=50;
nspheres=0;
Lx=Ly=Lz=1;
}
else if (nprocs==8){
nprocx=nprocy=nprocz=2;
nx=ny=nz=50;
nspheres=0;
Lx=Ly=Lz=1;
}
} }
MPI_Barrier(comm); MPI_Barrier(comm);
// Computational domain // Computational domain

View File

@ -196,17 +196,45 @@ int main(int argc, char **argv)
//....................................................................... //.......................................................................
// Reading the domain information file // Reading the domain information file
//....................................................................... //.......................................................................
ifstream domain("Domain.in"); ifstream domain("Domain.in");
domain >> nprocx; if (domain.good()){
domain >> nprocy; domain >> nprocx;
domain >> nprocz; domain >> nprocy;
domain >> Nx; domain >> nprocz;
domain >> Ny; domain >> Nx;
domain >> Nz; domain >> Ny;
domain >> nspheres; domain >> Nz;
domain >> Lx; domain >> nspheres;
domain >> Ly; domain >> Lx;
domain >> Lz; domain >> Ly;
domain >> Lz;
}
else if (nprocs==1){
nprocx=nprocy=nprocz=1;
Nx=Ny=Nz=50;
nspheres=0;
Lx=Ly=Lz=1;
}
else if (nprocs==2){
nprocx=nprocy=1;
nprocz=2;
Nx=Ny=Nz=50;
nspheres=0;
Lx=Ly=Lz=1;
}
else if (nprocs==4){
nprocx=nprocy=2;
nprocz=1;
Nx=Ny=Nz=50;
nspheres=0;
Lx=Ly=Lz=1;
}
else if (nprocs==8){
nprocx=nprocy=nprocz=2;
Nx=Ny=Nz=50;
nspheres=0;
Lx=Ly=Lz=1;
}
//....................................................................... //.......................................................................
} }
// ************************************************************** // **************************************************************