From 2f3e9a86ed5f4e4dc68af8ff5c49a9544eeb16ba Mon Sep 17 00:00:00 2001 From: James McClure Date: Tue, 8 Oct 2019 10:35:27 -0400 Subject: [PATCH] fix timestep / vis /analysis issues --- analysis/runAnalysis.cpp | 21 +++++++++++---------- analysis/runAnalysis.h | 8 ++++---- models/ColorModel.cpp | 8 ++++---- 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/analysis/runAnalysis.cpp b/analysis/runAnalysis.cpp index d53dba1c..72e4aa20 100644 --- a/analysis/runAnalysis.cpp +++ b/analysis/runAnalysis.cpp @@ -208,16 +208,16 @@ private: class IOWorkItem: public ThreadPool::WorkItemRet { public: - IOWorkItem( std::shared_ptr input_db_, std::vector& visData_, + IOWorkItem(int timestep_, std::shared_ptr input_db_, std::vector& visData_, SubPhase& Averages_, fillHalo& fillData_, runAnalysis::commWrapper&& comm_ ): - input_db(input_db_), visData(visData_), Averages(Averages_), fillData(fillData_), comm(std::move(comm_)) + timestep(timestep_), input_db(input_db_), visData(visData_), Averages(Averages_), fillData(fillData_), comm(std::move(comm_)) { } ~IOWorkItem() { } virtual void run() { auto color_db = input_db->getDatabase( "Color" ); auto vis_db = input_db->getDatabase( "Visualization" ); - int timestep = color_db->getWithDefault( "timestep", 0 ); + // int timestep = color_db->getWithDefault( "timestep", 0 ); PROFILE_START("Save Vis",1); @@ -763,13 +763,13 @@ AnalysisType runAnalysis::computeAnalysisType( int timestep ) /****************************************************************** * Run the analysis * ******************************************************************/ -void runAnalysis::run( std::shared_ptr input_db, TwoPhase& Averages, const double *Phi, +void runAnalysis::run(int timestep, std::shared_ptr input_db, TwoPhase& Averages, const double *Phi, double *Pressure, double *Velocity, double *fq, double *Den) { int N = d_N[0]*d_N[1]*d_N[2]; auto db = input_db->getDatabase( "Analysis" ); - int timestep = db->getWithDefault( "timestep", 0 ); + //int timestep = db->getWithDefault( "timestep", 0 ); // Check which analysis steps we need to perform auto type = computeAnalysisType( timestep ); @@ -935,15 +935,15 @@ void runAnalysis::run( std::shared_ptr input_db, TwoPhase& Averages, c /****************************************************************** * Run the analysis * ******************************************************************/ -void runAnalysis::basic( std::shared_ptr input_db, SubPhase &Averages, const double *Phi, double *Pressure, double *Velocity, double *fq, double *Den) +void runAnalysis::basic(int timestep, std::shared_ptr input_db, SubPhase &Averages, const double *Phi, double *Pressure, double *Velocity, double *fq, double *Den) { int N = d_N[0]*d_N[1]*d_N[2]; // Check which analysis steps we need to perform auto color_db = input_db->getDatabase( "Color" ); - //auto vis_db = input_db->getDatabase( "Visualization" ); + auto vis_db = input_db->getDatabase( "Visualization" ); - int timestep = color_db->getWithDefault( "timestep", 0 ); + //int timestep = color_db->getWithDefault( "timestep", 0 ); auto type = computeAnalysisType( timestep ); if ( type == AnalysisType::AnalyzeNone ) return; @@ -1012,6 +1012,7 @@ void runAnalysis::basic( std::shared_ptr input_db, SubPhase &Averages, ScaLBL_CopyToHost(cDen.get(),Den,2*d_Np*sizeof(double)); if (d_rank==0) { + color_db->putScalar("timestep",timestep); color_db->putScalar( "Restart", true ); input_db->putDatabase("Color", color_db); std::ofstream OutStream("Restart.db"); @@ -1038,12 +1039,12 @@ void runAnalysis::basic( std::shared_ptr input_db, SubPhase &Averages, PROFILE_STOP("run"); } -void runAnalysis::WriteVisData( std::shared_ptr input_db, SubPhase &Averages, const double *Phi, double *Pressure, double *Velocity, double *fq, double *Den) +void runAnalysis::WriteVisData(int timestep, std::shared_ptr input_db, SubPhase &Averages, const double *Phi, double *Pressure, double *Velocity, double *fq, double *Den) { int N = d_N[0]*d_N[1]*d_N[2]; auto color_db = input_db->getDatabase( "Color" ); auto vis_db = input_db->getDatabase( "Visualization" ); - int timestep = color_db->getWithDefault( "timestep", 0 ); + //int timestep = color_db->getWithDefault( "timestep", 0 ); // Check which analysis steps we need to perform auto type = computeAnalysisType( timestep ); diff --git a/analysis/runAnalysis.h b/analysis/runAnalysis.h index 9f18577f..ebbbdde0 100644 --- a/analysis/runAnalysis.h +++ b/analysis/runAnalysis.h @@ -24,18 +24,18 @@ class runAnalysis public: //! Constructor - runAnalysis( std::shared_ptr db, const RankInfoStruct& rank_info, + runAnalysis(int timestep, std::shared_ptr db, const RankInfoStruct& rank_info, std::shared_ptr ScaLBL_Comm, std::shared_ptr dm, int Np, bool Regular, IntArray Map ); //! Destructor ~runAnalysis(); //! Run the next analysis - void run( std::shared_ptr db, TwoPhase &Averages, const double *Phi, + void run(int timestep, std::shared_ptr db, TwoPhase &Averages, const double *Phi, double *Pressure, double *Velocity, double *fq, double *Den ); - void basic( std::shared_ptr db, SubPhase &Averages, const double *Phi, double *Pressure, double *Velocity, double *fq, double *Den ); - void WriteVisData( std::shared_ptr vis_db, SubPhase &Averages, const double *Phi, double *Pressure, double *Velocity, double *fq, double *Den); + void basic( int timestep, std::shared_ptr db, SubPhase &Averages, const double *Phi, double *Pressure, double *Velocity, double *fq, double *Den ); + void WriteVisData(int timestep, std::shared_ptr vis_db, SubPhase &Averages, const double *Phi, double *Pressure, double *Velocity, double *fq, double *Den); //! Finish all active analysis void finish(); diff --git a/models/ColorModel.cpp b/models/ColorModel.cpp index 07aa3d9b..38eba9cb 100644 --- a/models/ColorModel.cpp +++ b/models/ColorModel.cpp @@ -715,10 +715,10 @@ void ScaLBL_ColorModel::Run(){ } // Run the analysis //analysis.run( timestep, *Averages, Phi, Pressure, Velocity, fq, Den ); - color_db->putScalar("timestep",timestep); - current_db->putDatabase("Color", color_db); + //color_db->putScalar("timestep",timestep); + //current_db->putDatabase("Color", color_db); - analysis.basic( current_db, *Averages, Phi, Pressure, Velocity, fq, Den ); + analysis.basic(timestep, current_db, *Averages, Phi, Pressure, Velocity, fq, Den ); // allow initial ramp-up to get closer to steady state @@ -769,7 +769,7 @@ void ScaLBL_ColorModel::Run(){ delta_volume_target = Dm->Volume*volA *morph_delta; // set target volume change Averages->Full(); Averages->Write(timestep); - analysis.WriteVisData( current_db, *Averages, Phi, Pressure, Velocity, fq, Den ); + analysis.WriteVisData(timestep, current_db, *Averages, Phi, Pressure, Velocity, fq, Den ); analysis.finish(); if (rank==0){