From 0ef08df33ae529c69d988d5e1b4ea9631e28c250 Mon Sep 17 00:00:00 2001 From: bangerth Date: Sun, 24 Oct 2010 19:47:27 +0000 Subject: [PATCH] Add a file forgotten in r22461. git-svn-id: https://svn.dealii.org/trunk@22464 0785d39b-7218-0410-832d-ea1e28bc413d --- .../numerics/time_dependent.all_dimensions.cc | 403 ++++++++++++++++++ 1 file changed, 403 insertions(+) create mode 100644 deal.II/deal.II/source/numerics/time_dependent.all_dimensions.cc diff --git a/deal.II/deal.II/source/numerics/time_dependent.all_dimensions.cc b/deal.II/deal.II/source/numerics/time_dependent.all_dimensions.cc new file mode 100644 index 0000000000..77be7a637d --- /dev/null +++ b/deal.II/deal.II/source/numerics/time_dependent.all_dimensions.cc @@ -0,0 +1,403 @@ +//--------------------------------------------------------------------------- +// $Id: time_dependent.all_dimensions.cc 21627 2010-08-09 05:10:10Z bangerth $ +// Version: $Name$ +// +// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2008, 2009, 2010 by the deal.II authors +// +// This file is subject to QPL and may not be distributed +// without copyright and license information. Please refer +// to the file deal.II/doc/license.html for the text and +// further information on this license. +// +//--------------------------------------------------------------------------- + + +#include +#include +#include + +#include +#include +#include + +DEAL_II_NAMESPACE_OPEN + +TimeDependent::TimeSteppingData::TimeSteppingData (const unsigned int look_ahead, + const unsigned int look_back) + : + look_ahead (look_ahead), + look_back (look_back) +{} + + +TimeDependent::TimeDependent (const TimeSteppingData &data_primal, + const TimeSteppingData &data_dual, + const TimeSteppingData &data_postprocess): + sweep_no (numbers::invalid_unsigned_int), + timestepping_data_primal (data_primal), + timestepping_data_dual (data_dual), + timestepping_data_postprocess (data_postprocess) +{} + + +TimeDependent::~TimeDependent () +{ + while (timesteps.size() != 0) + delete_timestep (0); +} + + +void +TimeDependent::insert_timestep (const TimeStepBase *position, + TimeStepBase *new_timestep) +{ + Assert ((std::find(timesteps.begin(), timesteps.end(), position) != timesteps.end()) || + (position == 0), + ExcInvalidPosition()); + // first insert the new time step + // into the doubly linked list + // of timesteps + if (position == 0) + { + // at the end + new_timestep->set_next_timestep (0); + if (timesteps.size() > 0) + { + timesteps.back()->set_next_timestep (new_timestep); + new_timestep->set_previous_timestep (timesteps.back()); + } + else + new_timestep->set_previous_timestep (0); + } + else + if (position == timesteps[0]) + { + // at the beginning + new_timestep->set_previous_timestep (0); + if (timesteps.size() > 0) + { + timesteps[0]->set_previous_timestep (new_timestep); + new_timestep->set_next_timestep (timesteps[0]); + } + else + new_timestep->set_next_timestep (0); + } + else + { + // inner time step + std::vector >::iterator insert_position + = std::find(timesteps.begin(), timesteps.end(), position); + + (*(insert_position-1))->set_next_timestep (new_timestep); + new_timestep->set_previous_timestep (*(insert_position-1)); + new_timestep->set_next_timestep (*insert_position); + (*insert_position)->set_previous_timestep (new_timestep); + }; + + // finally enter it into the + // array + timesteps.insert ((position == 0 ? + timesteps.end() : + std::find(timesteps.begin(), timesteps.end(), position)), + new_timestep); +} + + +void +TimeDependent::add_timestep (TimeStepBase *new_timestep) +{ + insert_timestep (0, new_timestep); +} + + +void TimeDependent::delete_timestep (const unsigned int position) +{ + Assert (positionset_next_timestep ((position()); + + // same for "previous" pointer of next + // time step + if (positionset_previous_timestep ((position!=0) ? + timesteps[position-1] : + /*null*/SmartPointer()); +} + + +void +TimeDependent::solve_primal_problem () +{ + do_loop (std::mem_fun(&TimeStepBase::init_for_primal_problem), + std::mem_fun(&TimeStepBase::solve_primal_problem), + timestepping_data_primal, + forward); +} + + +void +TimeDependent::solve_dual_problem () +{ + do_loop (std::mem_fun(&TimeStepBase::init_for_dual_problem), + std::mem_fun(&TimeStepBase::solve_dual_problem), + timestepping_data_dual, + backward); +} + + +void +TimeDependent::postprocess () +{ + do_loop (std::mem_fun(&TimeStepBase::init_for_postprocessing), + std::mem_fun(&TimeStepBase::postprocess_timestep), + timestepping_data_postprocess, + forward); +} + + + +void TimeDependent::start_sweep (const unsigned int s) +{ + sweep_no = s; + + // reset the number each + // time step has, since some time + // steps might have been added since + // the last time we visited them + // + // also set the sweep we will + // process in the sequel + for (unsigned int step=0; stepset_timestep_no (step); + timesteps[step]->set_sweep_no (sweep_no); + }; + + for (unsigned int step=0; stepstart_sweep (); +} + + + +void TimeDependent::end_sweep (const unsigned int n_threads) +{ + if (DEAL_II_USE_MT && (n_threads > 1)) + { + const unsigned int stride = timesteps.size() / n_threads; + Threads::ThreadGroup<> threads; + void (TimeDependent::*p) (const unsigned int, const unsigned int) + = &TimeDependent::end_sweep; + for (unsigned int i=0; iend_sweep (); +} + + + +unsigned int TimeDependent::memory_consumption () const +{ + unsigned int mem = (MemoryConsumption::memory_consumption (timesteps) + + MemoryConsumption::memory_consumption (sweep_no) + + sizeof(timestepping_data_primal) + + sizeof(timestepping_data_dual) + + sizeof(timestepping_data_postprocess)); + for (unsigned int i=0; itime; +} + + + +double +TimeStepBase::get_forward_timestep () const +{ + Assert (next_timestep != 0, ExcCantComputeTimestep()); + return next_timestep->time - time; +} + + + +void +TimeStepBase::set_previous_timestep (const TimeStepBase *previous) +{ + previous_timestep = previous; +} + + + +void +TimeStepBase::set_next_timestep (const TimeStepBase *next) +{ + next_timestep = next; +} + + + +void +TimeStepBase::set_timestep_no (const unsigned int step_no) +{ + timestep_no = step_no; +} + + + +void +TimeStepBase::set_sweep_no (const unsigned int sweep) +{ + sweep_no = sweep; +} + + + +unsigned int +TimeStepBase::memory_consumption () const +{ + // only simple data types + return sizeof(*this); +} + + +DEAL_II_NAMESPACE_CLOSE -- 2.39.5