36 const unsigned int look_back)
37 : look_ahead(look_ahead)
38 , look_back(look_back)
70 (position ==
nullptr),
75 if (position ==
nullptr)
102 const std::vector<SmartPointer<TimeStepBase, TimeDependent>>::iterator
114 (*insert_position)->set_previous_timestep(
new_timestep);
162 timesteps[position]->set_previous_timestep(
163 (position != 0) ?
timesteps[position - 1] :
214 for (
unsigned int step = 0; step <
timesteps.size(); ++step)
232 [
this](
const unsigned int begin,
const unsigned int end) {
233 this->end_sweep(begin, end);
243 for (
unsigned int step = begin; step < end; ++step)
271 , sweep_no(
numbers::invalid_unsigned_int)
272 , timestep_no(
numbers::invalid_unsigned_int)
274 , next_action(
numbers::invalid_unsigned_int)
363 ExcMessage(
"The backward time step cannot be computed because "
364 "there is no previous time step."));
374 ExcMessage(
"The forward time step cannot be computed because "
375 "there is no next time step."));
417 return sizeof(*this);
428 , refinement_flags(0)
441 const RefinementFlags & refinement_flags)
444 , coarse_grid(&coarse_grid,
typeid(*
this).name())
446 , refinement_flags(refinement_flags)
455 if (!flags.delete_and_rebuild_tria)
464 coarse_grid =
nullptr;
476 if (flags.delete_and_rebuild_tria || !
tria)
486 if (
sleep_level == flags.sleep_level_to_delete_grid)
490 if (flags.delete_and_rebuild_tria)
509 refine_flags.emplace_back();
510 coarsen_flags.emplace_back();
511 tria->save_refine_flags(refine_flags.back());
512 tria->save_coarsen_flags(coarsen_flags.back());
527 tria->copy_triangulation(*coarse_grid);
549 tria->execute_coarsening_and_refinement();
603 for (
unsigned int c = 0; c <
new_cell->n_children(); ++c)
616 if (
cell2->has_children() &&
cell1->has_children())
621 for (
unsigned int c = 0; c <
cell1->n_children(); ++c)
628 if (!
cell1->has_children() && !
cell2->has_children())
634 if (
cell1->refine_flag_set() &&
cell2->coarsen_flag_set())
636 cell2->clear_coarsen_flag();
639 else if (
cell1->coarsen_flag_set() &&
cell2->refine_flag_set())
641 cell1->clear_coarsen_flag();
649 if (
cell1->has_children() && !
cell2->has_children())
669 if (
cell2->coarsen_flag_set())
671 cell2->clear_coarsen_flag();
675 if (!
cell2->refine_flag_set())
676 for (
unsigned int c = 0; c <
cell1->n_children(); ++c)
677 if (
cell1->child(c)->refine_flag_set() ||
678 cell1->child(c)->has_children())
680 cell2->set_refine_flag();
687 if (!
cell1->has_children() &&
cell2->has_children())
691 if (
cell1->coarsen_flag_set())
693 cell1->clear_coarsen_flag();
697 if (!
cell1->refine_flag_set())
698 for (
unsigned int c = 0; c <
cell2->n_children(); ++c)
699 if (
cell2->child(c)->refine_flag_set() ||
700 cell2->child(c)->has_children())
702 cell1->set_refine_flag();
740 get_tria_refinement_criteria(
criteria);
777 if ((timestep_no != 0) &&
778 (sweep_no >= refinement_flags.first_sweep_with_correction) &&
779 (refinement_flags.cell_number_correction_steps > 0))
786 static_cast<float>(refinement_threshold));
790 static_cast<float>(coarsening_threshold));
801 const unsigned int n_active_cells =
tria->n_active_cells();
842 if ((timestep_no != 0) &&
843 (sweep_no >= refinement_flags.first_sweep_with_correction))
844 for (
unsigned int loop = 0;
845 loop < refinement_flags.cell_number_correction_steps;
854 if (refinement_flags.adapt_grids)
860 tria->prepare_coarsening_and_refinement();
886 for (; cell !=
endc; ++cell)
887 if (cell->refine_flag_set())
889 else if (cell->coarsen_flag_set())
911 cell =
tria->begin_active();
913 for (; cell !=
endc; ++cell)
914 if (cell->refine_flag_set())
916 else if (cell->coarsen_flag_set())
924 double delta_up = refinement_flags.cell_number_corridor_top,
925 delta_down = refinement_flags.cell_number_corridor_bottom;
927 const std::vector<std::pair<unsigned int, double>> &
relaxations =
928 (sweep_no >= refinement_flags.correction_relaxations.size() ?
929 refinement_flags.correction_relaxations.back() :
930 refinement_flags.correction_relaxations[sweep_no]);
932 if (n_active_cells < relaxation.first)
1035 if (loop != refinement_flags.cell_number_correction_steps - 1)
1047 --refinement_threshold;
1068 if (coarsening_threshold >= refinement_threshold)
1069 coarsening_threshold = 0.999 * refinement_threshold;
1075 cell =
tria->begin_active();
1077 for (; cell !=
endc; ++cell)
1079 cell->clear_refine_flag();
1080 cell->clear_coarsen_flag();
1096 if ((timestep_no >= 1) && (refinement_flags.adapt_grids))
1113 if (refinement_flags.mirror_flags_to_previous_grid)
1125 tria->prepare_coarsening_and_refinement();
1143 next_action = grid_refinement;
1154 sizeof(refinement_flags) +
1163 : delete_and_rebuild_tria(
false)
1164 , wakeup_level_to_build_grid(0)
1165 , sleep_level_to_delete_grid(0)
1174 const bool delete_and_rebuild_tria,
1175 const unsigned int wakeup_level_to_build_grid,
1176 const unsigned int sleep_level_to_delete_grid)
1177 : delete_and_rebuild_tria(delete_and_rebuild_tria)
1178 , wakeup_level_to_build_grid(wakeup_level_to_build_grid)
1179 , sleep_level_to_delete_grid(sleep_level_to_delete_grid)
1192 std::vector<std::pair<unsigned int, double>>(1,
1195 std::make_pair(0U, 0.)));
1200 const unsigned int max_refinement_level,
1201 const unsigned int first_sweep_with_correction,
1202 const unsigned int min_cells_for_correction,
1203 const double cell_number_corridor_top,
1204 const double cell_number_corridor_bottom,
1206 const unsigned int cell_number_correction_steps,
1207 const bool mirror_flags_to_previous_grid,
1208 const bool adapt_grids)
1209 : max_refinement_level(max_refinement_level)
1210 , first_sweep_with_correction(first_sweep_with_correction)
1211 , min_cells_for_correction(min_cells_for_correction)
1212 , cell_number_corridor_top(cell_number_corridor_top)
1213 , cell_number_corridor_bottom(cell_number_corridor_bottom)
1214 , correction_relaxations(correction_relaxations.size() != 0 ?
1215 correction_relaxations :
1216 default_correction_relaxations)
1217 , cell_number_correction_steps(cell_number_correction_steps)
1218 , mirror_flags_to_previous_grid(mirror_flags_to_previous_grid)
1219 , adapt_grids(adapt_grids)
1271#include "time_dependent.inst"
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
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()
typename TimeStepBase_Tria_Flags::RefinementData< dim > RefinementData
virtual ~TimeStepBase_Tria() override
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 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
const value_type * const_iterator
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
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()
TriaIterator< CellAccessor< dim, spacedim > > cell_iterator
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< T >::value, std::size_t > memory_consumption(const T &t)
VectorType::value_type * begin(VectorType &V)
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)
TimeSteppingData(const unsigned int look_ahead, const unsigned int look_back)
const double refinement_threshold
const double coarsening_threshold
RefinementData(const double refinement_threshold, const double coarsening_threshold=0)
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)
std::vector< std::vector< std::pair< unsigned int, double > > > CorrectionRelaxations
static CorrectionRelaxations default_correction_relaxations
const double cell_number_corridor_bottom
const ::Triangulation< dim, spacedim > & tria