Skip to content

Commit

Permalink
Merge pull request #415 from GOMC-WSU/console-output
Browse files Browse the repository at this point in the history
Fix #414 GOMC prints console headers twice when printing every step
  • Loading branch information
LSchwiebert authored Jan 17, 2022
2 parents ab813cb + d15d0f0 commit a18336b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
17 changes: 9 additions & 8 deletions src/ConsoleOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ along with this program, also can be found at <http://www.gnu.org/licenses/>.
void ConsoleOutput::DoOutput(const ulong step)
{
GOMC_EVENT_START(1, GomcProfileEvent::CONSOLE_OUTPUT);
if (step == 0) {
if (WriteConsoleHeaders) {
std::cout << std::endl << "################################################################################" << std::endl;
std::cout << "########################## INITIAL SIMULATION ENERGY ###########################" << std::endl << std::endl;

PrintEnergyTitle();
std::cout << std::endl;

for (uint b = 0; b < BOX_TOTAL; b++) {
PrintEnergy(b, var->energyRef[b], -1);
PrintEnergy(b, var->energyRef[b], step-1);
std::cout << std::endl;
}

Expand All @@ -37,7 +37,7 @@ void ConsoleOutput::DoOutput(const ulong step)
std::cout << std::endl;

for (uint b = 0; b < BOX_TOTAL; b++) {
PrintStatistic(b, -1);
PrintStatistic(b, step-1);
std::cout << std::endl;
}
}
Expand All @@ -60,7 +60,9 @@ void ConsoleOutput::DoOutput(const ulong step)
PrintStatisticTitle();
std::cout << std::endl;
}
} else {
WriteConsoleHeaders = false;
}
else {
for(uint b = 0; b < BOX_TOTAL; b++) {
if(!forceOutput) {
PrintMove(b, step);
Expand All @@ -83,7 +85,6 @@ void ConsoleOutput::DoOutput(const ulong step)
}

}

}
GOMC_EVENT_STOP(1, GomcProfileEvent::CONSOLE_OUTPUT);
}
Expand Down Expand Up @@ -476,14 +477,14 @@ void ConsoleOutput::PrintMoveTitle()
}

void ConsoleOutput::printElement(const double t, const int width,
uint percision) const
uint precision) const
{
const char separator = ' ';
if(std::abs(t) > 1e99) {
std::cout << std::right << std::scientific << std::setprecision(percision - 1) <<
std::cout << std::right << std::scientific << std::setprecision(precision - 1) <<
std::setw(width) << std::setfill(separator) << t;
} else {
std::cout << std::right << std::scientific << std::setprecision(percision) <<
std::cout << std::right << std::scientific << std::setprecision(precision) <<
std::setw(width) << std::setfill(separator) << t;
}

Expand Down
8 changes: 5 additions & 3 deletions src/ConsoleOutput.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ struct ConsoleOutput : OutputableBase {
enableSurfTension) {
enableStat = true;
}
WriteConsoleHeaders = true;
DoOutput(0);
}
virtual void DoOutput(const ulong step);
Expand All @@ -70,6 +71,7 @@ struct ConsoleOutput : OutputableBase {
const static int elementWidth = 16;
bool enableEnergy, enablePressure, enableDens, enableVolume, enableMol;
bool enableSurfTension, enableStat;
bool WriteConsoleHeaders;
void PrintMove(const uint box, const ulong step) const;
void PrintMoveStat(const uint box, const ulong step) const;
void PrintStatistic(const uint box, const ulong step) const;
Expand All @@ -78,9 +80,9 @@ struct ConsoleOutput : OutputableBase {
void PrintEnergyTitle();
void PrintStatisticTitle();
void PrintMoveTitle();
void printElement (const double t, const int width, uint percision = 4) const;
void printElement (const uint t, const int width) const;
void printElement (const std::string t, const int width) const;
void printElement(const double t, const int width, uint precision = 4) const;
void printElement(const uint t, const int width) const;
void printElement(const std::string t, const int width) const;

template <typename T> void printElementStep ( const T t, const ulong step,
const int width) const;
Expand Down

0 comments on commit a18336b

Please sign in to comment.