Merge branch 'master' of github.com:JamesEMcClure/LBPM-WIA

This commit is contained in:
James E McClure
2015-08-12 12:45:35 -04:00
9 changed files with 278 additions and 107 deletions

View File

@@ -515,7 +515,7 @@ static int LocalToGlobalIDs( int nx, int ny, int nz, const RankInfoStruct& rank_
for (size_t i=0; i<LocalIDs.length(); i++) { for (size_t i=0; i<LocalIDs.length(); i++) {
if ( LocalIDs(i)>=0 ) { if ( LocalIDs(i)>=0 ) {
local.insert(LocalIDs(i)); local.insert(LocalIDs(i));
if ( LocalIDs(i)!=IDs(i) ) if ( LocalIDs(i)!=IDs(i) && IDs(i)>= 0)
map[LocalIDs(i)].remote_ids.insert(IDs(i)); map[LocalIDs(i)].remote_ids.insert(IDs(i));
} }
} }

View File

@@ -1,6 +1,7 @@
# Copy the examples to the install folder # Copy the examples to the install folder
INSTALL_EXAMPLE( Bubble ) INSTALL_EXAMPLE( Bubble )
INSTALL_EXAMPLE( ConstrainedBubble ) INSTALL_EXAMPLE( ConstrainedBubble )
INSTALL_EXAMPLE( Piston )
INSTALL_EXAMPLE( Sph1896 ) INSTALL_EXAMPLE( Sph1896 )
# Create unit tests for each example # Create unit tests for each example

View File

@@ -1,4 +1,4 @@
0.7 1.0
1.0e-2 0.95 -0.7 1.0e-2 0.95 -0.7
0.7 0.7
0.0 0.0 0.0 0.0 0.0 0.0

View File

@@ -1,4 +1,4 @@
1 1 4 1 1 10
100 100 100 40 40 40
229 229
1.0 1.0 1.0 1.0 1.0 1.0

48
example/Piston/Piston.sh Normal file → Executable file
View File

@@ -1,27 +1,37 @@
#!/bin/bash #!/bin/bash
# This runscript is for the Virginia Tech supercomputer HokieSpeed # Lines assigning various pressure BC for Color.in
#PBS -l walltime=72:00:00 echo "0 1 1.01 0.99" > Color.in.pressures
# Set the number of nodes, and the number of processors per node (generally should be 6) echo "0 1 1.0125 0.9875" >> Color.in.pressures
#PBS -l nodes=1:ppn=12 echo "0 1 1.015 0.985" >> Color.in.pressures
##PBS -l nodes=hs195 echo "0 1 1.02 0.98" >> Color.in.pressures
#PBS -A arcadm echo "0 1 1.025 0.975" >> Color.in.pressures
# Access group, queue, and accounting project echo "0 1 1.03 0.97" >> Color.in.pressures
#PBS -W group_list=arcadm
#PBS -q large_q
module purge for i in `seq 1 6`; do
module load gcc cuda mvapich2/1.9rc1 # Set up cases for each boundary pressure pair
dir="Case"$i
echo $dir
mkdir -p $dir
# copy the domain file
cp Domain.in $dir
cd $PBS_O_WORKDIR # set up each case -- parameters are fixed in Color.in, with multiple cases to set the boundary pressure
sed -n '1p' Color.in > $dir/Color.in
sed -n '2p' Color.in >> $dir/Color.in
sed -n '3p' Color.in >> $dir/Color.in
sed -n '4p' Color.in >> $dir/Color.in
# sed -n '5p' Color.in >> $dir/Color.in
# print the pressure values into the input file
sed -n "${i}p" Color.in.pressures >> $dir/Color.in
sed -n '6p' Color.in >> $dir/Color.in
cat $PBS_NODEFILE > hostfile done
echo "------------------------------------------" # simulations should be run using the following syntax
echo "Running LBM using MPI!" # PRE-PROCESSOR - set the radius to 18 voxel lengths
echo "Number of processors = " $PBS_NP #mpirun -np 10 ~/install-LBPM-WIA/bin/lbpm_captube_pp 18 1
echo "------------------------------------------" # RUN THE SIMULAUTION
#mpirun -np 10 ~/install-LBPM-WIA/bin/lbpm_color_simulator
mpirun -np 4 ~/install-LBPM-WIA/bin/lb2_Color_wia_mpi >
exit; exit;

View File

@@ -0,0 +1,8 @@
# This test case sets up a piston displacment example
# The case is intended to:
1. Verify that the interface and common curve are computed accurately.
2. Measure the dynamic contact angle and compare to known relationships
Example input files are provided.

View File

@@ -7,6 +7,7 @@ INSTALL_LBPM_EXE( lbpm_random_pp )
INSTALL_LBPM_EXE( lbpm_segmented_pp ) INSTALL_LBPM_EXE( lbpm_segmented_pp )
INSTALL_LBPM_EXE( lbpm_segmented_decomp ) INSTALL_LBPM_EXE( lbpm_segmented_decomp )
INSTALL_LBPM_EXE( lbpm_disc_pp ) INSTALL_LBPM_EXE( lbpm_disc_pp )
INSTALL_LBPM_EXE( lbpm_captube_pp )
INSTALL_LBPM_EXE( lbpm_BlobAnalysis ) INSTALL_LBPM_EXE( lbpm_BlobAnalysis )
INSTALL_LBPM_EXE( TestBubble ) INSTALL_LBPM_EXE( TestBubble )
INSTALL_LBPM_EXE( BasicSimulator ) INSTALL_LBPM_EXE( BasicSimulator )

217
tests/lbpm_captube_pp.cpp Normal file
View File

@@ -0,0 +1,217 @@
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <iostream>
#include <exception>
#include <stdexcept>
#include <fstream>
#include "ScaLBL.h"
#include "Communication.h"
#include "TwoPhase.h"
#include "common/MPI_Helpers.h"
int main(int argc, char **argv)
{
//*****************************************
// ***** MPI STUFF ****************
//*****************************************
// Initialize MPI
int rank,nprocs;
MPI_Init(&argc,&argv);
MPI_Comm_rank(MPI_COMM_WORLD,&rank);
MPI_Comm_size(MPI_COMM_WORLD,&nprocs);
// parallel domain size (# of sub-domains)
int nprocx,nprocy,nprocz;
int iproc,jproc,kproc;
int sendtag,recvtag;
//*****************************************
// MPI ranks for all 18 neighbors
//**********************************
int rank_x,rank_y,rank_z,rank_X,rank_Y,rank_Z;
int rank_xy,rank_XY,rank_xY,rank_Xy;
int rank_xz,rank_XZ,rank_xZ,rank_Xz;
int rank_yz,rank_YZ,rank_yZ,rank_Yz;
//**********************************
MPI_Request req1[18],req2[18];
MPI_Status stat1[18],stat2[18];
double TubeRadius =15.0;
int BC;
TubeRadius=strtod(argv[1],NULL);
BC=atoi(argv[2]);
if (rank == 0){
printf("********************************************************\n");
printf("Generate 3D cylindrical capillary tube geometry with radius = %f voxels \n",TubeRadius);
printf("********************************************************\n");
}
// Variables that specify the computational domain
string FILENAME;
int Nx,Ny,Nz; // local sub-domain size
int nspheres; // number of spheres in the packing
double Lx,Ly,Lz; // Domain length
int i,j,k,n;
// pmmc threshold values
double fluid_isovalue,solid_isovalue;
fluid_isovalue = 0.0;
solid_isovalue = 0.0;
if (rank==0){
//.......................................................................
// Reading the domain information file
//.......................................................................
ifstream domain("Domain.in");
domain >> nprocx;
domain >> nprocy;
domain >> nprocz;
domain >> Nx;
domain >> Ny;
domain >> Nz;
domain >> nspheres;
domain >> Lx;
domain >> Ly;
domain >> Lz;
//.......................................................................
}
// **************************************************************
// Broadcast simulation parameters from rank 0 to all other procs
MPI_Barrier(MPI_COMM_WORLD);
// Computational domain
MPI_Bcast(&Nx,1,MPI_INT,0,MPI_COMM_WORLD);
MPI_Bcast(&Ny,1,MPI_INT,0,MPI_COMM_WORLD);
MPI_Bcast(&Nz,1,MPI_INT,0,MPI_COMM_WORLD);
MPI_Bcast(&nprocx,1,MPI_INT,0,MPI_COMM_WORLD);
MPI_Bcast(&nprocy,1,MPI_INT,0,MPI_COMM_WORLD);
MPI_Bcast(&nprocz,1,MPI_INT,0,MPI_COMM_WORLD);
MPI_Bcast(&nspheres,1,MPI_INT,0,MPI_COMM_WORLD);
MPI_Bcast(&Lx,1,MPI_DOUBLE,0,MPI_COMM_WORLD);
MPI_Bcast(&Ly,1,MPI_DOUBLE,0,MPI_COMM_WORLD);
MPI_Bcast(&Lz,1,MPI_DOUBLE,0,MPI_COMM_WORLD);
//.................................................
MPI_Barrier(MPI_COMM_WORLD);
// **************************************************************
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",Nz,Nz,Nz);
printf("Parallel domain size = %i x %i x %i\n",nprocx,nprocy,nprocz);
printf("********************************************************\n");
}
// Initialized domain and averaging framework for Two-Phase Flow
Domain Dm(Nx,Ny,Nz,rank,nprocx,nprocy,nprocz,Lx,Ly,Lz,BC);
Dm.CommInit(MPI_COMM_WORLD);
TwoPhase Averages(Dm);
InitializeRanks( rank, nprocx, nprocy, nprocz, iproc, jproc, kproc,
rank_x, rank_y, rank_z, rank_X, rank_Y, rank_Z,
rank_xy, rank_XY, rank_xY, rank_Xy, rank_xz, rank_XZ, rank_xZ, rank_Xz,
rank_yz, rank_YZ, rank_yZ, rank_Yz );
MPI_Barrier(MPI_COMM_WORLD);
Nz += 2;
Nx = Ny = Nz; // Cubic domain
int N = Nx*Ny*Nz;
int dist_mem_size = N*sizeof(double);
//.......................................................................
// Filenames used
char LocalRankString[8];
char LocalRankFilename[40];
char LocalRestartFile[40];
char tmpstr[10];
sprintf(LocalRankString,"%05d",rank);
sprintf(LocalRankFilename,"%s%s","ID.",LocalRankString);
sprintf(LocalRestartFile,"%s%s","Restart.",LocalRankString);
// printf("Local File Name = %s \n",LocalRankFilename);
// .......... READ THE INPUT FILE .......................................
// char value;
char *id;
id = new char[N];
int sum = 0;
double sum_local;
double iVol_global = 1.0/(1.0*(Nx-2)*(Ny-2)*(Nz-2)*nprocs);
//if (pBC) iVol_global = 1.0/(1.0*(Nx-2)*nprocx*(Ny-2)*nprocy*((Nz-2)*nprocz-6));
double porosity, pore_vol;
// Initializes a constrained bubble test
double BubbleBot = 20.0; // How big to make the NWP bubble
double BubbleTop = 60.0; // How big to make the NWP bubble
//double TubeRadius = 15.5; // Radius of the capillary tube
sum=0;
for (k=0;k<Nz;k++){
for (j=0;j<Ny;j++){
for (i=0;i<Nx;i++){
n = k*Nx*Ny + j*Nz + i;
// Cylindrical capillary tube aligned with the z direction
Averages.SDs(i,j,k) = TubeRadius-sqrt(1.0*((i-Nx/2)*(i-Nx/2)
+ (j-Ny/2)*(j-Ny/2)));
// Initialize phase positions field
if (Averages.SDs(i,j,k) < 0.0){
id[n] = 0;
}
/* else if (k<BubbleBot){
id[n] = 2;
sum++;
}
else if (k<BubbleTop && rank == 0 && pBC == 0){
id[n] = 1;
sum++;
}
*/
else{
id[n] = 2;
sum++;
}
}
}
}
porosity = double(sum)/double(1.0*N);
// Compute the pore volume
sum_local = 0.0;
for ( k=1;k<Nz-1;k++){
for ( j=1;j<Ny-1;j++){
for ( i=1;i<Nx-1;i++){
n = k*Nx*Ny+j*Nx+i;
if (id[n] > 0){
sum_local += 1.0;
}
}
}
}
MPI_Allreduce(&sum_local,&pore_vol,1,MPI_DOUBLE,MPI_SUM,MPI_COMM_WORLD);
//.........................................................
// don't perform computations at the eight corners
id[0] = id[Nx-1] = id[(Ny-1)*Nx] = id[(Ny-1)*Nx + Nx-1] = 0;
id[(Nz-1)*Nx*Ny] = id[(Nz-1)*Nx*Ny+Nx-1] = id[(Nz-1)*Nx*Ny+(Ny-1)*Nx] = id[(Nz-1)*Nx*Ny+(Ny-1)*Nx + Nx-1] = 0;
//.........................................................
sprintf(LocalRankFilename,"SignDist.%05i",rank);
FILE *DIST = fopen(LocalRankFilename,"wb");
fwrite(Averages.SDs.get(),8,Averages.SDs.length(),DIST);
fclose(DIST);
sprintf(LocalRankFilename,"ID.%05i",rank);
FILE *ID = fopen(LocalRankFilename,"wb");
fwrite(id,1,N,ID);
fclose(ID);
// ****************************************************
MPI_Barrier(MPI_COMM_WORLD);
MPI_Finalize();
// ****************************************************
}

View File

@@ -144,7 +144,7 @@ int main(int argc, char **argv)
MeanFilter(Averages.SDs); MeanFilter(Averages.SDs);
if (rank==0) printf("Initialized solid phase -- Converting to Signed Distance function \n"); if (rank==0) printf("Initialized solid phase -- Converting to Signed Distance function \n");
SSO(Averages.SDs,id,Dm,20); SSO(Averages.SDs,id,Dm,25);
sprintf(LocalRankFilename,"SignDist.%05i",rank); sprintf(LocalRankFilename,"SignDist.%05i",rank);
FILE *DIST = fopen(LocalRankFilename,"wb"); FILE *DIST = fopen(LocalRankFilename,"wb");
@@ -175,18 +175,13 @@ int main(int argc, char **argv)
MeanFilter(Averages.Phase); MeanFilter(Averages.Phase);
if (rank==0) printf("Initialized non-wetting phase -- Converting to Signed Distance function \n"); if (rank==0) printf("Initialized non-wetting phase -- Converting to Signed Distance function \n");
SSO(Averages.Phase,id,Dm,20); SSO(Averages.Phase,id,Dm,25);
sprintf(LocalRankFilename,"Phase.%05i",rank);
FILE *PHASE = fopen(LocalRankFilename,"wb");
fwrite(Averages.Phase.get(),8,Averages.Phase.length(),PHASE);
fclose(PHASE);
/*
for (k=0;k<nz;k++){ for (k=0;k<nz;k++){
for (j=0;j<ny;j++){ for (j=0;j<ny;j++){
for (i=0;i<nx;i++){ for (i=0;i<nx;i++){
n=k*nx*ny+j*nx+i; n=k*nx*ny+j*nx+i;
Averages.Phase(i,j,k) += 1.0; Averages.Phase(i,j,k) -= 1.0;
if (Averages.SDs(i,j,k) > 0.0){ if (Averages.SDs(i,j,k) > 0.0){
if (Averages.Phase(i,j,k) > 0.0){ if (Averages.Phase(i,j,k) > 0.0){
Dm.id[n] = 2; Dm.id[n] = 2;
@@ -200,7 +195,7 @@ int main(int argc, char **argv)
} }
// Initialize distance to +/- 1 // Initialize distance to +/- 1
// Dilation of the non-wetting phase // Dilation of the non-wetting phase
Averages.SDn(i,j,k) = Averages.Phase(i,j,k)+1.0; Averages.SDn(i,j,k) = -Averages.Phase(i,j,k);
Averages.Phase(i,j,k) = Averages.SDn(i,j,k); Averages.Phase(i,j,k) = Averages.SDn(i,j,k);
Averages.Phase_tplus(i,j,k) = Averages.SDn(i,j,k); Averages.Phase_tplus(i,j,k) = Averages.SDn(i,j,k);
Averages.Phase_tminus(i,j,k) = Averages.SDn(i,j,k); Averages.Phase_tminus(i,j,k) = Averages.SDn(i,j,k);
@@ -213,91 +208,30 @@ int main(int argc, char **argv)
} }
} }
sprintf(LocalRankFilename,"Phase.%05i",rank);
FILE *PHASE = fopen(LocalRankFilename,"wb");
fwrite(Averages.Phase.get(),8,Averages.Phase.length(),PHASE);
fclose(PHASE);
double vF,vS; double vF,vS;
vF = vS = 0.0; vF = vS = 0.0;
double beta = 0.95; double beta = 0.95;
if (rank==0) printf("initializing the system \n"); if (rank==0) printf("initializing the system \n");
Averages.SetupCubes(Dm);
Averages.UpdateSolid(); Averages.UpdateSolid();
Averages.Initialize();
Averages.UpdateMeshValues(); Averages.UpdateMeshValues();
Dm.CommunicateMeshHalo(Averages.Phase); Dm.CommunicateMeshHalo(Averages.Phase);
Dm.CommunicateMeshHalo(Averages.SDn); Dm.CommunicateMeshHalo(Averages.SDn);
Dm.CommunicateMeshHalo(Averages.SDs);
if (rank==0) printf("computing blobs \n"); int timestep=5;
// int nblobs_global = ComputeGlobalBlobIDs(Dm.Nx-2,Dm.Ny-2,Dm.Nz-2,Dm.rank_info, Averages.Initialize();
// Averages.Phase,Averages.SDs,vF,vS,Averages.BlobLabel); if (rank==0) printf("computing phase components \n");
// if (Dm.rank==0) printf("Number of blobs is %i \n",nblobs_global); Averages.ComponentAverages();
if (rank==0) printf("sorting phase components \n");
// int nblobs_global = ComputeGlobalBlobIDs(Dm.Nx-2,Dm.Ny-2,Dm.Nz-2,Dm.rank_info, Averages.SortBlobs();
// Averages.SDn,Averages.SDs,vF,vS,Averages.BlobLabel); Averages.PrintComponents(timestep);
if (rank==0) printf("computing local averages \n");
Averages.ComputeLocalBlob();
if (rank==0) printf("reducing averages \n");
Averages.Reduce();
if (rank==0) printf("Writing blobs \n");
// Write the local blob ids
sprintf(LocalRankFilename,"BlobLabel.%05i",rank);
FILE *BLOBLOCAL = fopen(LocalRankFilename,"wb");
fwrite(Averages.BlobLabel.get(),4,Averages.BlobLabel.length(),BLOBLOCAL);
fclose(BLOBLOCAL);
printf("Wrote BlobLabel.%05i \n",rank);
if (rank==0) printf("Sorting averages \n");
// Blobs.Set(Averages.BlobAverages.NBLOBS);
int dimx = (int)Averages.BlobAverages.size(0);
int dimy = (int)Averages.BlobAverages.size(1);
int TotalBlobInfoSize=dimx*dimy;
// BlobContainer Blobs;
DoubleArray RecvBuffer(dimx);
// MPI_Allreduce(&Averages.BlobAverages.get(),&Blobs.get(),1,MPI_DOUBLE,MPI_SUM,Dm.Comm);
MPI_Barrier(MPI_COMM_WORLD);
if (rank==0) printf("Number of components is %i \n",dimy);
for (int b=0; b<dimy; b++){
MPI_Allreduce(&Averages.BlobAverages(0,b),&RecvBuffer(0),dimx,MPI_DOUBLE,MPI_SUM,MPI_COMM_WORLD);
for (int idx=0; idx<dimx-1; idx++) Averages.BlobAverages(idx,b)=RecvBuffer(idx);
MPI_Barrier(MPI_COMM_WORLD);
if (Averages.BlobAverages(0,b) > 0.0){
double Vn,pn,awn,ans,Jwn,Kwn,lwns,cwns,trawn,trJwn;
Vn = Averages.BlobAverages(1,b);
pn = Averages.BlobAverages(2,b)/Averages.BlobAverages(0,b);
awn = Averages.BlobAverages(3,b);
ans = Averages.BlobAverages(4,b);
if (awn != 0.0){
Jwn = Averages.BlobAverages(5,b)/Averages.BlobAverages(3,b);
Kwn = Averages.BlobAverages(6,b)/Averages.BlobAverages(3,b);
}
else Jwn=Kwn=0.0;
trawn = Averages.BlobAverages(12,b);
if (trawn != 0.0){
trJwn = Averages.BlobAverages(13,b)/trawn;
}
else trJwn=0.0;
lwns = Averages.BlobAverages(7,b);
if (lwns != 0.0) cwns = Averages.BlobAverages(8,b)/Averages.BlobAverages(7,b);
else cwns=0.0;
Averages.BlobAverages(2,b) = pn;
Averages.BlobAverages(5,b) = trJwn;
Averages.BlobAverages(6,b) = Kwn;
Averages.BlobAverages(8,b) = cwns;
// Averages.BlobAverages(13,b) = trJwn;
}
}
if (rank==0) printf("Sorting blobs by volume \n");
Averages.SortBlobs();
if (rank==0) WriteBlobs(Averages);
*/
MPI_Barrier(MPI_COMM_WORLD); MPI_Barrier(MPI_COMM_WORLD);
MPI_Finalize(); MPI_Finalize();