cloning databse for restart

This commit is contained in:
James McClure
2020-03-31 15:55:05 -04:00
parent 7258867983
commit d4c0824865

View File

@@ -907,10 +907,11 @@ void runAnalysis::run(int timestep, std::shared_ptr<Database> input_db, TwoPhase
// Spawn a thread to write the restart file
// if ( matches(type,AnalysisType::CreateRestart) ) {
if (timestep%d_restart_interval==0){
auto Restart_db = input_db->clone();
input_db->putScalar<bool>( "Restart", true );
if (d_rank==0) {
std::ofstream OutStream("Restart.db");
input_db->print(OutStream, "");
Restart_db->print(OutStream, "");
OutStream.close();
}
// Write the restart file (using a seperate thread)
@@ -1008,22 +1009,21 @@ void runAnalysis::basic(int timestep, std::shared_ptr<Database> input_db, SubPha
cfq = std::shared_ptr<double>(new double[19*d_Np],DeleteArray<double>);
ScaLBL_CopyToHost(cfq.get(),fq,19*d_Np*sizeof(double));
ScaLBL_CopyToHost(cDen.get(),Den,2*d_Np*sizeof(double));
color_db->putScalar<int>("timestep",timestep);
color_db->putScalar<bool>( "Restart", true );
input_db->putDatabase("Color", color_db);
// clone the input database to avoid modifying shared data
auto Restart_db = input_db->clone();
auto tmp_color_db = Restart_db.getDatabase( "Color" );
tmp_color_db.putScalar<int>("timestep",timestep);
tmp_color_db.putScalar<bool>( "Restart", true );
Restart_db.putDatabase("Color", tmp_color_db);
if (d_rank==0) {
std::ofstream OutStream("Restart.db");
input_db->print(OutStream, "");
Restart_db.print(OutStream, "");
OutStream.close();
}
// Write the restart file (using a seperate thread)
auto work1 = new WriteRestartWorkItem(d_restartFile.c_str(),cDen,cfq,d_Np);
work1->add_dependency(d_wait_restart);
d_wait_restart = d_tpool.add_work(work1);
}
if (timestep%d_visualization_interval==0){