fixed issue cloning db

This commit is contained in:
JamesEMcclure 2020-03-31 16:12:24 -04:00
parent d4c0824865
commit c4f15d8727

View File

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