void TimeDependent::delete_timestep (const unsigned int position)
{
- Assert (position<=timesteps.size(),
+ Assert (position<timesteps.size(),
ExcInvalidPosition(position, timesteps.size()));
timesteps[position]->unsubscribe();
delete timesteps[position];
timesteps.erase (×teps[position]);
+
+ // reset "next" pointer of previous
+ // time step if possible
+ //
+ // note that if now position==size,
+ // then we deleted the last time step
+ if (position != 0)
+ timesteps[position-1]->set_next_timestep ((position<timesteps.size()) ?
+ timesteps[position] :
+ 0);
+
+ // same for "previous" pointer of next
+ // time step
+ if (position<timesteps.size())
+ timesteps[position]->set_previous_timestep ((position!=0) ?
+ timesteps[position-1] :
+ 0);
};
// wake up the first few time levels
for (int step=-timestepping_data_primal.look_ahead; step<0; ++step)
- for (int look_ahead=1;
+ for (int look_ahead=0;
look_ahead<=static_cast<int>(timestepping_data_primal.look_ahead); ++look_ahead)
if (step+look_ahead >= 0)
timesteps[step+look_ahead]->wake_up(look_ahead);
{
// first thing: wake up the
// timesteps ahead as necessary
- for (unsigned int look_ahead=1;
+ for (unsigned int look_ahead=0;
look_ahead<=timestepping_data_primal.look_ahead; ++look_ahead)
if (step+look_ahead < n_timesteps)
timesteps[step+look_ahead]->wake_up(look_ahead);
timesteps[step]->solve_primal_problem ();
// let the timesteps behind sleep
- for (unsigned int look_back=1;
+ for (unsigned int look_back=0;
look_back<=timestepping_data_primal.look_back; ++look_back)
if (step>=look_back)
timesteps[step-look_back]->sleep(look_back);
};
- // make the last few sweeps sleep
+ // make the last few timesteps sleep
for (int step=n_timesteps;
step<static_cast<int>(n_timesteps+timestepping_data_primal.look_back); ++step)
- for (int look_back=1;
+ for (int look_back=0;
look_back<=static_cast<int>(timestepping_data_primal.look_back); ++look_back)
if ((step-look_back>=0) && (step-look_back<static_cast<int>(n_timesteps)))
timesteps[step-look_back]->sleep(look_back);
+double
+TimeStepBase::get_backward_timestep () const
+{
+ Assert (previous_timestep != 0, ExcCantComputeTimestep());
+ return time - previous_timestep->time;
+};
+
+
+
+double
+TimeStepBase::get_forward_timestep () const
+{
+ Assert (next_timestep != 0, ExcCantComputeTimestep());
+ return next_timestep->time - time;
+};
+
+
+
void
TimeStepBase::set_previous_timestep (const TimeStepBase *previous)
{