[1D] Initialize number-of-steps counter at start of solve
Fixes the enforcement of the maximum number of steps constraint if solve() is called again after an exception.
This commit is contained in:
parent
233399f899
commit
4c5301d6cd
3 changed files with 12 additions and 11 deletions
|
|
@ -340,6 +340,12 @@ protected:
|
|||
//! Function called at the start of every call to #eval.
|
||||
Func1* m_interrupt;
|
||||
|
||||
//! Number of time steps taken in the current call to solve()
|
||||
int m_nsteps;
|
||||
|
||||
//! Maximum number of timesteps allowed per call to solve()
|
||||
int m_nsteps_max;
|
||||
|
||||
private:
|
||||
// statistics
|
||||
int m_nevals;
|
||||
|
|
@ -350,12 +356,6 @@ private:
|
|||
vector_int m_funcEvals;
|
||||
vector_fp m_funcElapsed;
|
||||
|
||||
//! Number of time steps taken in the current call to solve()
|
||||
int m_nsteps;
|
||||
|
||||
//! Maximum number of timesteps allowed per call to solve()
|
||||
int m_nsteps_max;
|
||||
|
||||
//! Number of time steps taken in each call to solve() (e.g. for each
|
||||
//! successive grid refinement)
|
||||
vector_int m_timeSteps;
|
||||
|
|
|
|||
|
|
@ -18,8 +18,8 @@ OneDim::OneDim()
|
|||
m_bw(0), m_size(0),
|
||||
m_init(false), m_pts(0), m_solve_time(0.0),
|
||||
m_ss_jac_age(20), m_ts_jac_age(20),
|
||||
m_interrupt(0), m_nevals(0), m_evaltime(0.0), m_nsteps(0),
|
||||
m_nsteps_max(500)
|
||||
m_interrupt(0), m_nsteps(0), m_nsteps_max(500),
|
||||
m_nevals(0), m_evaltime(0.0)
|
||||
{
|
||||
m_newt.reset(new MultiNewton(1));
|
||||
}
|
||||
|
|
@ -30,8 +30,8 @@ OneDim::OneDim(vector<Domain1D*> domains) :
|
|||
m_bw(0), m_size(0),
|
||||
m_init(false), m_solve_time(0.0),
|
||||
m_ss_jac_age(20), m_ts_jac_age(20),
|
||||
m_interrupt(0), m_nevals(0), m_evaltime(0.0), m_nsteps(0),
|
||||
m_nsteps_max(500)
|
||||
m_interrupt(0), m_nsteps(0), m_nsteps_max(500),
|
||||
m_nevals(0), m_evaltime(0.0)
|
||||
{
|
||||
// create a Newton iterator, and add each domain.
|
||||
m_newt.reset(new MultiNewton(1));
|
||||
|
|
@ -364,7 +364,7 @@ doublereal OneDim::timeStep(int nsteps, doublereal dt, doublereal* x,
|
|||
dt *= 1.5;
|
||||
}
|
||||
dt = std::min(dt, m_tmax);
|
||||
if (m_nsteps == m_nsteps_max) {
|
||||
if (m_nsteps >= m_nsteps_max) {
|
||||
throw CanteraError("OneDim::timeStep",
|
||||
"Took maximum number of timesteps allowed ({}) without "
|
||||
"reaching steady-state solution.", m_nsteps_max);
|
||||
|
|
|
|||
|
|
@ -230,6 +230,7 @@ void Sim1D::solve(int loglevel, bool refine_grid)
|
|||
int new_points = 1;
|
||||
int nsteps;
|
||||
doublereal dt = m_tstep;
|
||||
m_nsteps = 0;
|
||||
int soln_number = -1;
|
||||
finalize();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue