Assign components from input file

This commit is contained in:
James E McClure
2018-02-08 22:32:27 -05:00
parent 98d86d2f94
commit 7e908ee2b5
2 changed files with 69 additions and 39 deletions

View File

@@ -201,7 +201,7 @@ void Domain::CommInit(MPI_Comm Communicator){
//jproc = (rank/nprocx)%nprocy;
//kproc = rank/(nprocx*nprocy);
MPI_Barrier(MPI_COMM_WORLD);
MPI_Barrier(Communicator);
kproc = rank/(nprocx*nprocy);
jproc = (rank-nprocx*nprocy*kproc)/nprocx;
iproc = rank-nprocx*nprocy*kproc-nprocx*jproc;
@@ -231,8 +231,9 @@ void Domain::CommInit(MPI_Comm Communicator){
rank_yZ = getRankForBlock(i,j-1,k+1);
//......................................................................................
MPI_Comm_group(Communicator,&Group);
MPI_Comm_create(Communicator,Group,&Comm);
//MPI_Comm_group(Communicator,&Group);
//MPI_Comm_create(Communicator,Group,&Comm);
MPI_Comm_dup(MPI_COMM_WORLD,&Comm);
//......................................................................................
MPI_Request req1[18], req2[18];
@@ -541,8 +542,8 @@ void Domain::AssignComponentLabels(double *phase)
vector <char> Label;
vector <double> Affinity;
// Read the labels
// if (rank==0){
/* printf("Component labels:\n");
if (rank==0){
printf("Component labels:\n");
ifstream iFILE("ComponentLabels.csv");
if (iFILE.good()){
while (!iFILE.eof()){
@@ -555,36 +556,48 @@ void Domain::AssignComponentLabels(double *phase)
}
}
else{
*/
if (rank ==0 ) {
printf("Using default labels: Solid (0 --> -1.0), NWP (1 --> 1.0), WP (2 --> -1.0)\n");
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++;
}
}
// 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);
MPI_Bcast(&NLABELS,1,MPI_INT,0,Comm);
//printf("rank=%i, NLABELS=%i \n ",rank,NLABELS);
// Copy into contiguous buffers
//char *LabelList;
//double * AffinityList;
//LabelList=new char[NLABELS];
//AffinityList=new double[NLABELS];
//MPI_Bcast(&LabelList,NLABELS,MPI_CHAR,0,Comm);
//MPI_Bcast(&AffinityList,NLABELS,MPI_DOUBLE,0,Comm);
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;
}
}
MPI_Barrier(Comm);
MPI_Bcast(LabelList,NLABELS,MPI_CHAR,0,Comm);
MPI_Bcast(AffinityList,NLABELS,MPI_DOUBLE,0,Comm);
// Assign the labels
for (int k=0;k<Nz;k++){
for (int j=0;j<Ny;j++){
@@ -593,8 +606,9 @@ void Domain::AssignComponentLabels(double *phase)
VALUE=id[n];
// Assign the affinity from the paired list
for (int idx=0; idx < NLABELS; idx++){
if (VALUE == Label[idx]){
AFFINITY=Affinity[idx];
//printf("rank=%i, idx=%i, value=%i, %i, \n",rank,idx, VALUE,LabelList[idx]);
if (VALUE == LabelList[idx]){
AFFINITY=AffinityList[idx];
idx = NLABELS;
}
}

View File

@@ -84,7 +84,7 @@ int main(int argc, char **argv)
int RESTART_INTERVAL=20000;
//int ANALYSIS_)INTERVAL=1000;
int BLOB_ANALYSIS_INTERVAL=1000;
int timestep = -1;
int timestep = 6;
if (rank==0){
//.............................................................
@@ -330,9 +330,6 @@ int main(int argc, char **argv)
//.......................................................................
sum_local=0.0;
Np=0; // number of local pore nodes
double *PhaseLabel;
PhaseLabel = new double[N];
Dm.AssignComponentLabels(PhaseLabel);
//.......................................................................
for (k=1;k<Nz-1;k++){
for (j=1;j<Ny-1;j++){
@@ -358,7 +355,10 @@ int main(int argc, char **argv)
// Initialize communication structures in averaging domain
for (i=0; i<Mask.Nx*Mask.Ny*Mask.Nz; i++) Mask.id[i] = id[i];
Mask.CommInit(comm);
double *PhaseLabel;
PhaseLabel = new double[N];
Mask.AssignComponentLabels(PhaseLabel);
//...........................................................................
if (rank==0) printf ("Create ScaLBL_Communicator \n");
// Create a communicator for the device (will use optimized layout)
@@ -600,6 +600,12 @@ int main(int argc, char **argv)
alpha, beta, Fx, Fy, Fz, Nx, Nx*Ny, 0, ScaLBL_Comm.next, Np);
ScaLBL_DeviceBarrier(); MPI_Barrier(comm);
// Run the analysis
run_analysis(timestep,RESTART_INTERVAL,rank_info,ScaLBL_Comm,*Averages,last_ids,last_index,last_id_map,
Np,Nx,Ny,Nz,pBC,beta,err,Phi,Pressure,Velocity,Map,fq,Den,
LocalRestartFile,meshData,fillData,tpool,work_ids);
// *************EVEN TIMESTEP*************
timestep++;
// Compute the Phase indicator field
@@ -667,7 +673,17 @@ int main(int argc, char **argv)
if (rank==0) printf("********************************************************\n");
// ************************************************************************
double *PHASE;
int SIZE=Nx*Ny*Nz*sizeof(double);
PHASE= new double [Nx*Ny*Nz];
ScaLBL_CopyToHost(&PHASE[0],&Phi[0],SIZE);
FILE *OUTFILE;
sprintf(LocalRankFilename,"Phase.%05i.raw",rank);
OUTFILE = fopen(LocalRankFilename,"wb");
fwrite(PHASE,8,N,OUTFILE);
fclose(OUTFILE);
PROFILE_STOP("Main");
PROFILE_SAVE("lbpm_color_simulator",1);
// ****************************************************