From 06b517b26f2a74781b9492fc02011b584d5b47d6 Mon Sep 17 00:00:00 2001 From: wolf Date: Sun, 28 Feb 1999 19:28:47 +0000 Subject: [PATCH] Small update on data structures. git-svn-id: https://svn.dealii.org/trunk@927 0785d39b-7218-0410-832d-ea1e28bc413d --- .../deal.II/source/numerics/time_dependent.cc | 47 ++++++++++++++++--- 1 file changed, 41 insertions(+), 6 deletions(-) diff --git a/deal.II/deal.II/source/numerics/time_dependent.cc b/deal.II/deal.II/source/numerics/time_dependent.cc index bb254d13d6..179b05f93a 100644 --- a/deal.II/deal.II/source/numerics/time_dependent.cc +++ b/deal.II/deal.II/source/numerics/time_dependent.cc @@ -70,12 +70,29 @@ TimeDependent::add_timestep (TimeStepBase *new_timestep) void TimeDependent::delete_timestep (const unsigned int position) { - Assert (position<=timesteps.size(), + Assert (positionunsubscribe(); 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 ((positionset_previous_timestep ((position!=0) ? + timesteps[position-1] : + 0); }; @@ -92,7 +109,7 @@ TimeDependent::solve_primal_problem () // 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(timestepping_data_primal.look_ahead); ++look_ahead) if (step+look_ahead >= 0) timesteps[step+look_ahead]->wake_up(look_ahead); @@ -101,7 +118,7 @@ TimeDependent::solve_primal_problem () { // 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); @@ -110,16 +127,16 @@ TimeDependent::solve_primal_problem () 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(n_timesteps+timestepping_data_primal.look_back); ++step) - for (int look_back=1; + for (int look_back=0; look_back<=static_cast(timestepping_data_primal.look_back); ++look_back) if ((step-look_back>=0) && (step-look_back(n_timesteps))) timesteps[step-look_back]->sleep(look_back); @@ -212,6 +229,24 @@ TimeStepBase::solve_dual_problem () +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) { -- 2.39.5