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

This commit is contained in:
James E McClure
2018-06-17 20:52:28 -04:00
11 changed files with 142 additions and 88 deletions

View File

@@ -321,7 +321,9 @@ runAnalysis::runAnalysis( std::shared_ptr<Database> db,
d_restartFile = restart_file + "." + rankString;
d_rank = MPI_WORLD_RANK();
writeIDMap(ID_map_struct(),0,id_map_filename);
// Create the MeshDataStruct
// Initialize IO for silo
IO::initialize("","silo","false");
// Create the MeshDataStruct
d_meshData.resize(1);
d_meshData[0].meshName = "domain";
d_meshData[0].mesh = std::make_shared<IO::DomainMesh>( Dm->rank_info,Dm->Nx-2,Dm->Ny-2,Dm->Nz-2,Dm->Lx,Dm->Ly,Dm->Lz );
@@ -447,7 +449,7 @@ AnalysisType runAnalysis::computeAnalysisType( int timestep )
AnalysisType type = AnalysisType::AnalyzeNone;
if ( timestep%d_analysis_interval + 8 == d_analysis_interval ) {
// Copy the phase indicator field for the earlier timestep
printf("Copy phase indicator,timestep=%i\n",timestep);
// printf("Copy phase indicator,timestep=%i\n",timestep);
type |= AnalysisType::CopyPhaseIndicator;
}
if ( timestep%d_blobid_interval == 0 ) {
@@ -464,13 +466,13 @@ AnalysisType runAnalysis::computeAnalysisType( int timestep )
#endif */
if ( timestep%d_analysis_interval + 4 == d_analysis_interval ) {
// Copy the averages to the CPU (and identify blobs)
printf("Copy sim state, timestep=%i \n",timestep);
//printf("Copy sim state, timestep=%i \n",timestep);
type |= AnalysisType::CopySimState;
type |= AnalysisType::IdentifyBlobs;
}
if ( timestep%d_analysis_interval == 0 ) {
// Run the analysis
printf("Compute averages, timestep=%i \n",timestep);
//printf("Compute averages, timestep=%i \n",timestep);
type |= AnalysisType::ComputeAverages;
}
if (timestep%d_restart_interval == 0) {

View File

@@ -404,7 +404,7 @@ int ScaLBL_Communicator::MemoryOptimizedLayoutAA(IntArray &Map, int *neighborLis
Map(i,j,k) = -1;
// Local index
n = k*Nx*Ny+j*Nx+i;
if (id[n] != 0){
if (id[n] > 0){
// Counts for the six faces
if (i==1) Map(n)=idx++;
else if (j==1) Map(n)=idx++;
@@ -430,7 +430,7 @@ int ScaLBL_Communicator::MemoryOptimizedLayoutAA(IntArray &Map, int *neighborLis
for (i=2; i<Nx-2; i++){
// Local index (regular layout)
n = k*Nx*Ny + j*Nx + i;
if (id[n] != 0 ){
if (id[n] > 0 ){
Map(n) = idx++;
//neighborList[idx++] = n; // index of self in regular layout
}
@@ -440,6 +440,7 @@ int ScaLBL_Communicator::MemoryOptimizedLayoutAA(IntArray &Map, int *neighborLis
last_interior=idx;
Np = (last_interior/16 + 1)*16;
//printf(" Np=%i \n",Np);
// Now use Map to determine the neighbors for each lattice direction
for (k=1;k<Nz-1;k++){
@@ -1544,6 +1545,9 @@ void ScaLBL_Communicator::RegularLayout(IntArray map, const double *data, Double
int Ny = map.size(1);
int Nz = map.size(2);
// initialize the array
regdata.fill(-1.f);
double *TmpDat;
double value;
TmpDat = new double [N];

View File

@@ -16,6 +16,8 @@ Color {
tol = 1e-5;
das = 0.1
dbs = 0.9
ComponentLabels = 0, 1, 2
ComponentAffinity = -1.0, 1.0, -1.0
}
Domain {

View File

@@ -3,6 +3,7 @@ INSTALL_EXAMPLE (NonNewtonianChannelFlow )
INSTALL_EXAMPLE( Bubble )
INSTALL_EXAMPLE( ConstrainedBubble )
INSTALL_EXAMPLE( Piston )
INSTALL_EXAMPLE( Plates )
INSTALL_EXAMPLE( InkBottle )
INSTALL_EXAMPLE( Sph1896 )
INSTALL_EXAMPLE( drainage )

View File

@@ -0,0 +1,8 @@
#!/bin/bash
LBPM_DIR=../../tests
python ParallelPlates.py
mpirun -np 1 $LBPM_DIR/lbpm_serial_decomp input.db
mpirun -np 4 $LBPM_DIR/lbpm_segmented_pp input.db
mpirun -np 4 $LBPM_DIR/lbpm_color_simulator input.db

View File

@@ -0,0 +1,33 @@
import numpy
nx=96
ny=24
nz=24
N=nx*ny*nz
mesh=(nx,ny,nz)
data=numpy.ones(mesh,dtype=numpy.int8)
LabelTop=-1
LabelBottom=-2
#print(data)
print("Writing parllel plates")
print("Mesh size: "+repr(mesh))
print("Top label: "+repr(LabelTop))
print("Bottom label: "+repr(LabelBottom))
# assign a bubble in the middle
for x in range(12,72):
for y in range(0,ny):
for z in range(0,nz):
data[x,y,z]=2
# solid walls with different component labels
for x in range(0,nx):
for y in range(0,ny):
data[x,y,0]=LabelBottom
data[x,y,nz-1]=LabelTop
data.tofile("ParallelPlates.raw")

46
example/Plates/input.db Normal file
View File

@@ -0,0 +1,46 @@
Color {
tauA = 1.0;
tauB = 1.0;
rhoA = 1.0;
rhoB = 1.0;
alpha = 5e-3;
beta = 0.95;
F = 0, 0, 0
Restart = false
pBC = 0
din = 1.0
dout = 1.0
timestepMax = 3000
interval = 1000
tol = 1e-5;
das = 0.1
dbs = 0.9
flux = 0.0
ComponentLabels = -2, -1
ComponentAffinity = -3.0, -2.0
}
Domain {
Filename = "ParallelPlates.raw"
nproc = 1, 1, 4 // Number of processors (Npx,Npy,Npz)
n = 24, 24, 24 // Size of local domain (Nx,Ny,Nz)
N = 24, 24, 96 // size of the input image
n_spheres = 1 // Number of spheres
L = 1, 1, 1 // Length of domain (x,y,z)
BC = 0 // Boundary condition type
ReadValues = -2, -1, 1, 2
WriteValues = -2, -1, 1, 2
}
Analysis {
blobid_interval = 1000 // Frequency to perform blob identification
analysis_interval = 1000 // Frequency to perform analysis
restart_interval = 1000 // Frequency to write restart data
visualization_interval = 1000 // Frequency to write visualization data
restart_file = "Restart" // Filename to use for restart file (will append rank)
N_threads = 4 // Number of threads to use
load_balance = "independent" // Load balance method to use: "none", "default", "independent"
}

View File

@@ -84,17 +84,17 @@ void ScaLBL_ColorModel::SetDomain(){
MPI_Barrier(comm);
Dm->CommInit();
MPI_Barrier(comm);
rank = Dm->rank();
}
void ScaLBL_ColorModel::ReadInput(){
int rank=Dm->rank();
size_t readID;
//.......................................................................
if (rank == 0) printf("Read input media... \n");
//.......................................................................
Mask->ReadIDs();
sprintf(LocalRankString,"%05d",Dm->rank());
sprintf(LocalRankString,"%05d",rank);
sprintf(LocalRankFilename,"%s%s","ID.",LocalRankString);
sprintf(LocalRestartFile,"%s%s","Restart.",LocalRankString);
@@ -110,8 +110,7 @@ void ScaLBL_ColorModel::ReadInput(){
// Read restart file
if (Restart == true){
if (Dm->rank()==0){
size_t readID;
if (rank==0){
printf("Reading restart file! \n");
ifstream restart("Restart.txt");
if (restart.is_open()){
@@ -135,72 +134,26 @@ void ScaLBL_ColorModel::ReadInput(){
}
void ScaLBL_ColorModel::AssignComponentLabels(double *phase)
{
int rank=Dm->rank();
int NLABELS=0;
size_t NLABELS=0;
char VALUE=0;
double AFFINITY=0.f;
vector <char> Label;
vector <double> Affinity;
// Read the labels
if (rank==0){
printf("Component labels:\n");
ifstream iFILE("ComponentLabels.csv");
if (iFILE.good()){
int value;
while (!iFILE.eof()){
iFILE>>value;
iFILE>>AFFINITY;
VALUE=char(value);
Label.push_back(value);
Affinity.push_back(AFFINITY);
NLABELS++;
printf("%i %f\n",VALUE,AFFINITY);
}
}
else{
printf("Using default labels: Solid (0 --> -1.0), NWP (1 --> 1.0), WP (2 --> -1.0)\n");
// Set default values
VALUE=0; AFFINITY=-1.0;
Label.push_back(VALUE);
Affinity.push_back(AFFINITY);
NLABELS++;
VALUE=1; AFFINITY=1.0;
Label.push_back(VALUE);
Affinity.push_back(AFFINITY);
NLABELS++;
VALUE=2; AFFINITY=-1.0;
Label.push_back(VALUE);
Affinity.push_back(AFFINITY);
NLABELS++;
}
}
MPI_Barrier(comm);
// Broadcast the list
MPI_Bcast(&NLABELS,1,MPI_INT,0,comm);
//printf("rank=%i, NLABELS=%i \n ",rank(),NLABELS);
auto LabelList = color_db->getVector<char>( "ComponentLabels" );
auto AffinityList = color_db->getVector<double>( "ComponentAffinity" );
// Copy into contiguous buffers
char *LabelList;
double * AffinityList;
LabelList=new char[NLABELS];
AffinityList=new double[NLABELS];
if (rank==0){
for (int idx=0; idx < NLABELS; idx++){
VALUE=Label[idx];
AFFINITY=Affinity[idx];
printf("rank=%i, idx=%i, value=%d, affinity=%f \n",rank,idx,VALUE,AFFINITY);
LabelList[idx]=VALUE;
AffinityList[idx]=AFFINITY;
}
NLABELS=LabelList.size();
if (NLABELS != AffinityList.size()){
ERROR("Error: ComponentLabels and ComponentAffinity must be the same length! \n");
}
MPI_Barrier(comm);
MPI_Bcast(LabelList,NLABELS,MPI_CHAR,0,comm);
MPI_Bcast(AffinityList,NLABELS,MPI_DOUBLE,0,comm);
if (rank==0){
printf("Components labels: %lu \n",NLABELS);
for (unsigned int idx=0; idx<NLABELS; idx++){
VALUE=LabelList[idx];
AFFINITY=AffinityList[idx];
printf(" label=%i, affinity=%f\n",int(VALUE),AFFINITY);
}
}
// Assign the labels
for (int k=0;k<Nz;k++){
for (int j=0;j<Ny;j++){
@@ -208,7 +161,7 @@ void ScaLBL_ColorModel::AssignComponentLabels(double *phase)
int n = k*Nx*Ny+j*Nx+i;
VALUE=Mask->id[n];
// Assign the affinity from the paired list
for (int idx=0; idx < NLABELS; idx++){
for (unsigned int idx=0; idx < NLABELS; idx++){
//printf("rank=%i, idx=%i, value=%i, %i, \n",rank(),idx, VALUE,LabelList[idx]);
if (VALUE == LabelList[idx]){
AFFINITY=AffinityList[idx];
@@ -226,7 +179,6 @@ void ScaLBL_ColorModel::Create(){
/*
* This function creates the variables needed to run a LBM
*/
int rank=Dm->rank();
//.........................................................
// don't perform computations at the eight corners
//id[0] = id[Nx-1] = id[(Ny-1)*Nx] = id[(Ny-1)*Nx + Nx-1] = 0;
@@ -244,7 +196,7 @@ void ScaLBL_ColorModel::Create(){
ScaLBL_Comm = std::shared_ptr<ScaLBL_Communicator>(new ScaLBL_Communicator(Mask));
int Npad=(Np/16 + 2)*16;
if (rank==0) printf ("Set up memory efficient layout \n");
if (rank==0) printf ("Set up memory efficient layout, %i | %i | %i \n", Np, Npad, N);
Map.resize(Nx,Ny,Nz); Map.fill(-2);
auto neighborList= new int[18*Npad];
Np = ScaLBL_Comm->MemoryOptimizedLayoutAA(Map,neighborList,Mask->id,Np);
@@ -256,8 +208,8 @@ void ScaLBL_ColorModel::Create(){
// LBM variables
if (rank==0) printf ("Allocating distributions \n");
//......................device distributions.................................
int dist_mem_size = Np*sizeof(double);
int neighborSize=18*(Np*sizeof(int));
dist_mem_size = Np*sizeof(double);
neighborSize=18*(Np*sizeof(int));
//...........................................................................
ScaLBL_AllocateDeviceMemory((void **) &NeighborList, neighborSize);
@@ -326,9 +278,9 @@ void ScaLBL_ColorModel::AssignSolidPotential(){
double phi_x = 0.f;
double phi_y = 0.f;
double phi_z = 0.f;
for (int kk=0; kk<5; kk++){
for (int jj=0; jj<5; jj++){
for (int ii=0; ii<5; ii++){
for (int kk=1; kk<4; kk++){
for (int jj=1; jj<4; jj++){
for (int ii=1; ii<4; ii++){
int index = kk*25+jj*5+ii;
double distval= Dst[index];
@@ -401,6 +353,8 @@ void ScaLBL_ColorModel::Initialize(){
/*
* This function initializes model
*/
AssignSolidPotential();
int rank=Dm->rank();
double count_wet=0.f;
double *PhaseLabel;
@@ -436,7 +390,6 @@ void ScaLBL_ColorModel::Initialize(){
void ScaLBL_ColorModel::Run(){
int nprocs=nprocx*nprocy*nprocz;
int rank=Dm->rank();
const RankInfoStruct rank_info(rank,nprocx,nprocy,nprocz);
if (rank==0) printf("********************************************************\n");

View File

@@ -83,6 +83,8 @@ public:
private:
MPI_Comm comm;
int dist_mem_size;
int neighborSize;
// filenames
char LocalRankString[8];
char LocalRankFilename[40];

View File

@@ -14,15 +14,18 @@ cmake \
-D CUDA_FLAGS="-arch sm_35" \
-D CUDA_HOST_COMPILER="/usr/bin/gcc" \
-D USE_NETCDF=0 \
-D HDF5_DIRECTORY="/usr/local/visit/2.9.2/linux-x86_64" \
-D HDF5_DIRECTORY="/home/mcclurej/TPL/hdf5/" \
-D HDF5_LIB="/home/mcclurej/TPL/hdf5/lib/libhdf5.a" \
-D SILO_LIB="/home/mcclurej/TPL/silo/lib/libsiloh5.a" \
-D SILO_DIRECTORY="/home/mcclurej/TPL/silo/" \
-D NETCDF_DIRECTORY="/apps/netcdf/" \
-D USE_SILO=1 \
-D SILO_LIB="/usr/local/visit/2.9.2/linux-x86_64/lib/libsiloh5.a" \
-D SILO_DIRECTORY="/usr/local/visit/2.9.2/linux-x86_64/include/silo" \
-D USE_CUDA=0 \
-D USE_TIMER=0 \
${HOME}/Programs/LBPM-WIA
# -D SILO_LIB="/usr/local/visit/2.9.2/linux-x86_64/lib/libsiloh5.a" \
# -D SILO_DIRECTORY="/usr/local/visit/2.9.2/linux-x86_64/include/silo" \

View File

@@ -57,7 +57,7 @@ ADD_LBPM_TEST( TestSphereCurvature )
#ADD_LBPM_TEST_1_2_4( TestTwoPhase )
ADD_LBPM_TEST_1_2_4( TestBlobIdentify )
#ADD_LBPM_TEST_PARALLEL( TestTwoPhase 8 )
ADD_LBPM_TEST_PARALLEL( TestBlobAnalyze 8 )
#ADD_LBPM_TEST_PARALLEL( TestBlobAnalyze 8 )
ADD_LBPM_TEST_PARALLEL( TestSegDist 8 )
#ADD_LBPM_TEST_PARALLEL( TestCommD3Q19 8 )
#ADD_LBPM_TEST_PARALLEL( TestMassConservationD3Q7 1 )
@@ -72,8 +72,11 @@ ENDIF()
# Sample test that will run with 1, 2, and 4 processors, failing with 4 or more procs
ADD_LBPM_TEST_1_2_4( hello_world )
ADD_LBPM_TEST_1_2_4( TestColorBubble ../example/Bubble/input.db)
ADD_LBPM_TEST_1_2_4( TestColorSquareTube ../example/Bubble/input.db)
ADD_LBPM_TEST( TestColorBubble ../example/Bubble/input.db)
ADD_LBPM_TEST( TestColorSquareTube ../example/Bubble/input.db)
#ADD_LBPM_TEST_1_2_4( TestColorBubble ../example/Bubble/input.db)
#ADD_LBPM_TEST_1_2_4( TestColorSquareTube ../example/Bubble/input.db)
SET_TESTS_PROPERTIES( hello_world PROPERTIES ENVIRONMENT "MPICH_RDMA_ENABLED_CUDA=0")
IF ( USE_MPI )
@@ -81,12 +84,9 @@ IF ( USE_MPI )
SET_TESTS_PROPERTIES( hello_world_4procs PROPERTIES ENVIRONMENT "MPICH_RDMA_ENABLED_CUDA=0")
ENDIF()
# Add CPU/GPU specific test
IF ( USE_CUDA )
ADD_SUBDIRECTORY( gpu )
ELSE()
ADD_SUBDIRECTORY( cpu )
ENDIF()