Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #414 GOMC prints console headers twice when printing every step #415

Merged
merged 1 commit into from
Jan 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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