fix restart bug, blob id bug
This commit is contained in:
parent
e2ca178e3d
commit
5014f018d5
@ -39,21 +39,24 @@ void DeleteArray( const TYPE *p )
|
||||
class WriteRestartWorkItem: public ThreadPool::WorkItemRet<void>
|
||||
{
|
||||
public:
|
||||
WriteRestartWorkItem( const char* filename_, std::shared_ptr<double> cphi_, std::shared_ptr<double> cfq_, int N_ ):
|
||||
filename(filename_), cphi(cphi_), cfq(cfq_), N(N_) {}
|
||||
WriteRestartWorkItem( const char* filename_, std::shared_ptr<double> cDen_, std::shared_ptr<double> cfq_, int N_ ):
|
||||
filename(filename_), cDen(cDen_), cfq(cfq_), N(N_) {}
|
||||
virtual void run() {
|
||||
PROFILE_START("Save Checkpoint",1);
|
||||
double value;
|
||||
ofstream File(filename,ios::binary);
|
||||
for (int n=0; n<N; n++){
|
||||
// Write the two density values
|
||||
value = cphi.get()[n];
|
||||
value = cDen.get()[n];
|
||||
File.write((char*) &value, sizeof(value));
|
||||
value = cDen.get()[N+n];
|
||||
File.write((char*) &value, sizeof(value));
|
||||
|
||||
}
|
||||
for (int n=0; n<d_Np; n++){
|
||||
for (int n=0; n<N; n++){
|
||||
// Write the distributions
|
||||
for (int q=0; q<19; q++){
|
||||
value = cfq.get()[q*d_Np+n];
|
||||
value = cfq.get()[q*N+n];
|
||||
File.write((char*) &value, sizeof(value));
|
||||
}
|
||||
}
|
||||
@ -63,7 +66,7 @@ public:
|
||||
private:
|
||||
WriteRestartWorkItem();
|
||||
const char* filename;
|
||||
std::shared_ptr<double> cfq,cphi;
|
||||
std::shared_ptr<double> cfq,cDen;
|
||||
// const DoubleArray& phase;
|
||||
//const DoubleArray& dist;
|
||||
const int N;
|
||||
@ -601,14 +604,14 @@ void runAnalysis::run( int timestep, TwoPhase& Averages, const double *Phi,
|
||||
d_ScaLBL_Comm->RegularLayout(d_Map,&Velocity[2*d_Np],Averages.Vel_z);
|
||||
PROFILE_STOP("Copy-State",1);
|
||||
}
|
||||
std::shared_ptr<double> cfq,cPhi;
|
||||
std::shared_ptr<double> cfq,cDen;
|
||||
//if ( matches(type,AnalysisType::CreateRestart) ) {
|
||||
if (timestep%d_restart_interval==0){
|
||||
// Copy restart data to the CPU
|
||||
cPhi = std::shared_ptr<double>(new double[d_Np],DeleteArray<double>);
|
||||
cDen = std::shared_ptr<double>(new double[2*d_Np],DeleteArray<double>);
|
||||
cfq = std::shared_ptr<double>(new double[19*d_Np],DeleteArray<double>);
|
||||
ScaLBL_CopyToHost(cfq.get(),fq,19*d_Np*sizeof(double));
|
||||
ScaLBL_CopyToHost(cPhi.get(),Phi,d_Np*sizeof(double));
|
||||
ScaLBL_CopyToHost(cDen.get(),Den,2*d_Np*sizeof(double));
|
||||
}
|
||||
PROFILE_STOP("Copy data to host",1);
|
||||
|
||||
@ -616,6 +619,10 @@ void runAnalysis::run( int timestep, TwoPhase& Averages, const double *Phi,
|
||||
if ( matches(type,AnalysisType::IdentifyBlobs) ) {
|
||||
phase = std::shared_ptr<DoubleArray>(new DoubleArray(d_N[0],d_N[1],d_N[2]));
|
||||
d_ScaLBL_Comm->RegularLayout(d_Map,Phi,*phase);
|
||||
if (d_regular)
|
||||
d_ScaLBL_Comm->RegularLayout(d_Map,Phi,*phase);
|
||||
else
|
||||
ScaLBL_CopyToHost(phase.get(),Phi,N*sizeof(double));
|
||||
|
||||
BlobIDstruct new_index(new std::pair<int,IntArray>(0,IntArray()));
|
||||
BlobIDstruct new_ids(new std::pair<int,IntArray>(0,IntArray()));
|
||||
@ -653,7 +660,7 @@ void runAnalysis::run( int timestep, TwoPhase& Averages, const double *Phi,
|
||||
fclose(Rst);
|
||||
}
|
||||
// Write the restart file (using a seperate thread)
|
||||
auto work = new WriteRestartWorkItem(d_restartFile.c_str(),cPhi,cfq,d_Np);
|
||||
auto work = new WriteRestartWorkItem(d_restartFile.c_str(),cDen,cfq,d_Np);
|
||||
work->add_dependency(d_wait_restart);
|
||||
d_wait_restart = d_tpool.add_work(work);
|
||||
}
|
||||
|
@ -296,9 +296,11 @@ void ScaLBL_ColorModel::Initialize(){
|
||||
double *cPhi = new double[Np];
|
||||
double *cDist = new double[19*Np];
|
||||
ifstream File(LocalRestartFile,ios::binary);
|
||||
double value;
|
||||
for (int n=0; n<Nx*Ny*Nz; n++){
|
||||
File.read((char*) &value, sizeof(value));
|
||||
double value,va,vb;
|
||||
for (int n=0; n<Np; n++){
|
||||
File.read((char*) &value, sizeof(va));
|
||||
File.read((char*) &value, sizeof(vb));
|
||||
value = (va-vb)/(va+vb);
|
||||
cPhi[n] = value;
|
||||
}
|
||||
for (int n=0; n<Np; n++){
|
||||
|
Loading…
Reference in New Issue
Block a user