restart from id instead of full info

This commit is contained in:
James E McClure 2018-04-06 11:07:40 -04:00
parent fbf7294a61
commit 17a6879716

View File

@ -334,6 +334,42 @@ int main(int argc, char **argv)
if (readID != size_t(N)) printf("lbpm_color_simulator: Error reading ID (rank=%i) \n",rank);
fclose(IDFILE);
// Read id from restart
if (Restart == true){
if (rank==0){
printf("Reading restart file! \n");
ifstream restart("Restart.txt");
if (restart.is_open()){
restart >> timestep;
printf("Restarting from timestep =%i \n",timestep);
}
else{
printf("WARNING:No Restart.txt file, setting timestep=0 \n");
timestep=0;
}
}
MPI_Bcast(&timestep,1,MPI_INT,0,comm);
FILE *RESTART = fopen(LocalRestartFile,"rb");
if (IDFILE==NULL) ERROR("lbpm_color_simulator: Error opening file: Restart.xxxxx");
readID=fread(id,1,N,RESTART);
if (readID != size_t(N)) printf("lbpm_color_simulator: Error reading Restart (rank=%i) \n",rank);
fclose(RESTART);
/*
// Read in the restart file to CPU buffers
double *cDen = new double[2*Np];
double *cfq = new double[19*Np];
ReadCheckpoint(LocalRestartFile, cDen, cfq, Np);
// Copy the restart data to the GPU
ScaLBL_CopyToDevice(fq,cfq,19*Np*sizeof(double));
ScaLBL_CopyToDevice(Den,cDen,2*Np*sizeof(double));
ScaLBL_DeviceBarrier();
delete [] cDen;
delete [] cfq;
*/
MPI_Barrier(comm);
}
//.......................................................................
// Compute the media porosity, assign phase labels and solid composition
//.......................................................................
@ -476,33 +512,6 @@ int main(int argc, char **argv)
ScaLBL_SetSlice_z(Phi,-1.0,Nx,Ny,Nz,Nz-3);
}
}
if (Restart == true){
if (rank==0){
printf("Reading restart file! \n");
ifstream restart("Restart.txt");
if (restart.is_open()){
restart >> timestep;
printf("Restarting from timestep =%i \n",timestep);
}
else{
printf("WARNING:No Restart.txt file, setting timestep=0 \n");
timestep=0;
}
}
MPI_Bcast(&timestep,1,MPI_INT,0,comm);
// Read in the restart file to CPU buffers
double *cDen = new double[2*Np];
double *cfq = new double[19*Np];
ReadCheckpoint(LocalRestartFile, cDen, cfq, Np);
// Copy the restart data to the GPU
ScaLBL_CopyToDevice(fq,cfq,19*Np*sizeof(double));
ScaLBL_CopyToDevice(Den,cDen,2*Np*sizeof(double));
ScaLBL_DeviceBarrier();
delete [] cDen;
delete [] cfq;
MPI_Barrier(comm);
}
//.......................................................................
// Once phase has been initialized, map solid to account for 'smeared' interface