69 (position ==
nullptr),
74 if (position ==
nullptr)
80 timesteps.back()->set_next_timestep(new_timestep);
92 timesteps[0]->set_previous_timestep(new_timestep);
101 const std::vector<SmartPointer<TimeStepBase, TimeDependent>>::iterator
110 (*(insert_position - 1))->set_next_timestep(new_timestep);
113 (*insert_position)->set_previous_timestep(new_timestep);
153 timesteps[position - 1]->set_next_timestep(
161 timesteps[position]->set_previous_timestep(
162 (position != 0) ?
timesteps[position - 1] :
213 for (
unsigned int step = 0; step <
timesteps.size(); ++step)
220 timestep->start_sweep();
231 [
this](
const unsigned int begin,
const unsigned int end) {
232 this->end_sweep(begin, end);
242 for (
unsigned int step = begin; step < end; ++step)
362 ExcMessage(
"The backward time step cannot be computed because "
363 "there is no previous time step."));
373 ExcMessage(
"The forward time step cannot be computed because "
374 "there is no next time step."));
416 return sizeof(*this);
424 ,
tria(nullptr, typeid(*this).name())
440 const RefinementFlags &refinement_flags)
442 , tria(nullptr, typeid(*this).name())
443 , coarse_grid(&coarse_grid, typeid(*this).name())
445 , refinement_flags(refinement_flags)
454 if (!
flags.delete_and_rebuild_tria)
474 if (wakeup_level ==
flags.wakeup_level_to_build_grid)
475 if (
flags.delete_and_rebuild_tria || !
tria)
485 if (sleep_level ==
flags.sleep_level_to_delete_grid)
489 if (
flags.delete_and_rebuild_tria)
530 for (
unsigned int previous_sweep = 0; previous_sweep <
refine_flags.size();
548 tria->execute_coarsening_and_refinement();
559 mirror_refinement_flags(
602 for (
unsigned int c = 0; c < new_cell->
n_children(); ++c)
603 ::mirror_refinement_flags<dim>(new_cell->
child(c),
617 bool grids_changed =
false;
620 for (
unsigned int c = 0; c < cell1->
n_children(); ++c)
622 ::adapt_grid_cells<dim>(cell1->
child(c), cell2->
child(c));
623 return grids_changed;
667 bool changed_grid =
false;
675 for (
unsigned int c = 0; c < cell1->
n_children(); ++c)
689 bool changed_grid =
false;
697 for (
unsigned int c = 0; c < cell2->
n_children(); ++c)
718 bool grids_changed =
false;
721 cell2 = tria2.
begin();
726 for (; cell1 != endc; ++cell1, ++cell2)
727 grids_changed |= ::adapt_grid_cells<dim>(cell1, cell2);
729 return grids_changed;
744 double refinement_threshold = refinement_data.refinement_threshold,
745 coarsening_threshold = refinement_data.coarsening_threshold;
759 p_coarsening_threshold =
nullptr;
780 sorted_criteria = criteria;
781 std::sort(sorted_criteria.
begin(), sorted_criteria.
end());
782 p_refinement_threshold =
784 sorted_criteria.
end(),
785 static_cast<float>(refinement_threshold));
786 p_coarsening_threshold =
787 std::upper_bound(sorted_criteria.
begin(),
788 sorted_criteria.
end(),
789 static_cast<float>(coarsening_threshold));
800 const unsigned int n_active_cells =
tria->n_active_cells();
843 for (
unsigned int loop = 0;
854 ::adapt_grids<dim>(*previous_tria, *
tria);
859 tria->prepare_coarsening_and_refinement();
884 endc = previous_tria->
end();
885 for (; cell != endc; ++cell)
886 if (cell->refine_flag_set())
888 else if (cell->coarsen_flag_set())
889 previous_cells -=
static_cast<double>(
909 double estimated_cells = n_active_cells;
910 cell =
tria->begin_active();
912 for (; cell != endc; ++cell)
913 if (cell->refine_flag_set())
915 else if (cell->coarsen_flag_set())
916 estimated_cells -=
static_cast<double>(
926 const std::vector<std::pair<unsigned int, double>> &relaxations =
930 for (
const auto &relaxation : relaxations)
931 if (n_active_cells < relaxation.first)
933 delta_up *= relaxation.second;
934 delta_down *= relaxation.second;
947 if (estimated_cells > previous_cells * (1. + delta_up))
970 estimated_cells - previous_cells * (1. + delta_up);
981 for (
unsigned int i = 0; i < delta_cells;
983 if (p_refinement_threshold != sorted_criteria.
end())
984 ++p_refinement_threshold;
1003 if (estimated_cells < previous_cells * (1. - delta_down))
1007 double delta_cells =
1008 previous_cells * (1. - delta_down) - estimated_cells;
1043 for (
unsigned int i = 0; i < delta_cells;
1045 if (p_refinement_threshold != p_coarsening_threshold)
1046 --refinement_threshold;
1047 else if (p_coarsening_threshold != sorted_criteria.
begin())
1048 --p_coarsening_threshold, --p_refinement_threshold;
1057 if (p_refinement_threshold == sorted_criteria.
end())
1059 Assert(p_coarsening_threshold != p_refinement_threshold,
1061 --p_refinement_threshold;
1064 coarsening_threshold = *p_coarsening_threshold;
1065 refinement_threshold = *p_refinement_threshold;
1067 if (coarsening_threshold >= refinement_threshold)
1068 coarsening_threshold = 0.999 * refinement_threshold;
1074 cell =
tria->begin_active();
1076 for (; cell != endc; ++cell)
1078 cell->clear_refine_flag();
1079 cell->clear_coarsen_flag();
1114 ::adapt_grids<dim>(*previous_tria, *
tria);
1117 old_cell = previous_tria->
begin(0);
1118 new_cell =
tria->begin(0);
1119 endc =
tria->end(0);
1120 for (; new_cell != endc; ++new_cell, ++old_cell)
1121 ::mirror_refinement_flags<dim>(new_cell, old_cell);
1124 tria->prepare_coarsening_and_refinement();
1132 ::adapt_grids<dim>(*previous_tria, *
tria);
1191 std::vector<std::pair<unsigned int, double>>(1,
1194 std::make_pair(0U, 0.)));
1231 const double _refinement_threshold,
1232 const double _coarsening_threshold)
1254 _coarsening_threshold :
1255 0.999 * _coarsening_threshold))
1270#include "time_dependent.inst"
RefinementCase< dim > refine_flag_set() const
TriaIterator< CellAccessor< dim, spacedim > > child(const unsigned int i) const
void set_refine_flag(const RefinementCase< dim > ref_case=RefinementCase< dim >::isotropic_refinement) const
void clear_coarsen_flag() const
bool coarsen_flag_set() const
void insert_timestep(const TimeStepBase *position, TimeStepBase *new_timestep)
virtual void start_sweep(const unsigned int sweep_no)
std::size_t memory_consumption() const
const TimeSteppingData timestepping_data_primal
std::vector< SmartPointer< TimeStepBase, TimeDependent > > timesteps
void solve_dual_problem()
void do_loop(InitFunctionObject init_function, LoopFunctionObject loop_function, const TimeSteppingData ×tepping_data, const Direction direction)
const TimeSteppingData timestepping_data_dual
void solve_primal_problem()
TimeDependent(const TimeSteppingData &data_primal, const TimeSteppingData &data_dual, const TimeSteppingData &data_postprocess)
void delete_timestep(const unsigned int position)
void add_timestep(TimeStepBase *new_timestep)
const TimeSteppingData timestepping_data_postprocess
virtual void wake_up(const unsigned int wakeup_level) override
std::vector< std::vector< bool > > coarsen_flags
virtual void sleep(const unsigned int) override
virtual std::size_t memory_consumption() const override
void refine_grid(const RefinementData data)
virtual void init_for_refinement()
SmartPointer< const Triangulation< dim, dim >, TimeStepBase_Tria< dim > > coarse_grid
typename TimeStepBase_Tria_Flags::RefinementData< dim > RefinementData
virtual void get_tria_refinement_criteria(Vector< float > &criteria) const =0
const RefinementFlags refinement_flags
virtual ~TimeStepBase_Tria() override
SmartPointer< Triangulation< dim, dim >, TimeStepBase_Tria< dim > > tria
std::vector< std::vector< bool > > refine_flags
virtual std::size_t memory_consumption() const
double get_forward_timestep() const
TimeStepBase(const double time)
virtual void wake_up(const unsigned int)
void set_timestep_no(const unsigned int step_no)
void set_previous_timestep(const TimeStepBase *previous)
const TimeStepBase * previous_timestep
virtual void postprocess_timestep()
virtual void sleep(const unsigned int)
void set_next_timestep(const TimeStepBase *next)
unsigned int get_timestep_no() const
double get_backward_timestep() const
void set_sweep_no(const unsigned int sweep_no)
virtual void solve_primal_problem()=0
virtual void init_for_postprocessing()
virtual void start_sweep()
virtual void init_for_primal_problem()
virtual void solve_dual_problem()
virtual void init_for_dual_problem()
const TimeStepBase * next_timestep
bool has_children() const
unsigned int n_children() const
bool get_anisotropic_refinement_flag() const
cell_iterator begin(const unsigned int level=0) const
unsigned int n_active_cells() const
unsigned int n_levels() const
cell_iterator end() const
virtual bool prepare_coarsening_and_refinement()
active_cell_iterator begin_active(const unsigned int level=0) const
const value_type * const_iterator
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
static ::ExceptionBase & ExcGridNotDeleted()
static ::ExceptionBase & ExcInvalidValue(double arg1)
static ::ExceptionBase & ExcNotImplemented()
#define Assert(cond, exc)
static ::ExceptionBase & ExcPureFunctionCalled()
#define AssertNothrow(cond, exc)
static ::ExceptionBase & ExcInternalError()
static ::ExceptionBase & ExcInvalidValue(double arg1)
static ::ExceptionBase & ExcMessage(std::string arg1)
static ::ExceptionBase & ExcInvalidPosition()
TriaActiveIterator< CellAccessor< dim, spacedim > > active_cell_iterator
TriaIterator< CellAccessor< dim, spacedim > > cell_iterator
#define DEAL_II_ASSERT_UNREACHABLE()
void refine(Triangulation< dim, spacedim > &tria, const Vector< Number > &criteria, const double threshold, const unsigned int max_to_mark=numbers::invalid_unsigned_int)
void coarsen(Triangulation< dim, spacedim > &tria, const Vector< Number > &criteria, const double threshold)
std::enable_if_t< std::is_fundamental_v< T >, std::size_t > memory_consumption(const T &t)
Iterator lower_bound(Iterator first, Iterator last, const T &val)
void apply_to_subranges(const Iterator &begin, const std_cxx20::type_identity_t< Iterator > &end, const Function &f, const unsigned int grainsize)
static constexpr unsigned int max_children_per_cell
const unsigned int look_ahead
const unsigned int look_back
TimeSteppingData(const unsigned int look_ahead, const unsigned int look_back)
const unsigned int wakeup_level_to_build_grid
const bool delete_and_rebuild_tria
const unsigned int sleep_level_to_delete_grid
const double refinement_threshold
const double coarsening_threshold
RefinementData(const double refinement_threshold, const double coarsening_threshold=0)
std::vector< std::vector< std::pair< unsigned int, double > > > CorrectionRelaxations
const unsigned int min_cells_for_correction
const double cell_number_corridor_top
RefinementFlags(const unsigned int max_refinement_level=0, const unsigned int first_sweep_with_correction=0, const unsigned int min_cells_for_correction=0, const double cell_number_corridor_top=(1<< dim), const double cell_number_corridor_bottom=1, const CorrectionRelaxations &correction_relaxations=CorrectionRelaxations(), const unsigned int cell_number_correction_steps=0, const bool mirror_flags_to_previous_grid=false, const bool adapt_grids=false)
const unsigned int first_sweep_with_correction
const std::vector< std::vector< std::pair< unsigned int, double > > > correction_relaxations
const unsigned int max_refinement_level
const bool mirror_flags_to_previous_grid
const unsigned int cell_number_correction_steps
static CorrectionRelaxations default_correction_relaxations
const double cell_number_corridor_bottom