Skip to content

Commit

Permalink
Add message checking lifted from AmrLevel. (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
esclapez authored Mar 9, 2022
1 parent 511f77e commit 8cbf143
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
2 changes: 2 additions & 0 deletions Source/PeleLM.H
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ class PeleLM : public amrex::AmrCore {
// I/O
void WritePlotFile();
bool writePlotNow();
bool checkMessage();
void WriteCheckPointFile();
void ReadCheckPointFile();
bool writeCheckNow();
Expand Down Expand Up @@ -920,6 +921,7 @@ class PeleLM : public amrex::AmrCore {
int m_plotStateSpec = 0;
int m_plot_int = 0;
int m_check_int = 0;
int m_message_int = 10;
int m_evaluatePlotVarCount = 0;
amrex::Vector<std::string> m_evaluatePlotVars;

Expand Down
32 changes: 29 additions & 3 deletions Source/PeleLMEvolve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,24 @@ void PeleLM::Evolve() {
writeTemporals();
}

// Check message
bool dump_and_stop = checkMessage();

// Check for plot file
if (writePlotNow()) {
if (writePlotNow() || dump_and_stop) {
WritePlotFile();
plt_justDidIt = 1;
}

if (writeCheckNow()) {
if (writeCheckNow() || dump_and_stop) {
WriteCheckPointFile();
chk_justDidIt = 1;
}

// Check for the end of the simulation
do_not_evolve = ( (m_max_step >= 0 && m_nstep >= m_max_step) ||
(m_stop_time >= 0.0 && m_cur_time >= m_stop_time - 1.0e-12 * m_dt) );
(m_stop_time >= 0.0 && m_cur_time >= m_stop_time - 1.0e-12 * m_dt) ||
dump_and_stop );

}

Expand Down Expand Up @@ -103,3 +107,25 @@ PeleLM::doTemporalsNow()

return write_now;
}

bool
PeleLM::checkMessage()
{
bool dump_and_stop = false;
if (m_nstep % m_message_int == 0) {
int dumpclose = 0;
if (ParallelDescriptor::IOProcessor()) {
FILE *fp;
if ( (fp=fopen("dump_and_stop","r")) != 0 ) {
remove("dump_and_stop");
dumpclose = 1;
fclose(fp);
}
}
int packed_data[1];
packed_data[0] = dumpclose;
ParallelDescriptor::Bcast(packed_data, 1, ParallelDescriptor::IOProcessorNumber());
dump_and_stop = packed_data[0];
}
return dump_and_stop;
}
1 change: 1 addition & 0 deletions Source/PeleLMSetup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ void PeleLM::readParameters() {
ParmParse ppa("amr");
ppa.query("max_step", m_max_step);
ppa.query("stop_time", m_stop_time);
ppa.query("message_int", m_message_int);
ppa.query("fixed_dt", m_fixed_dt);
ppa.query("cfl", m_cfl);
ppa.query("dt_shrink", m_dtshrink);
Expand Down

0 comments on commit 8cbf143

Please sign in to comment.