https://mooseframework.inl.gov
CompositionDT.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #pragma once
11 
12 #include "TimeStepper.h"
14 
27 class CompositionDT : public TimeStepper
28 {
29 public:
38 
40 
45  struct CompareFirst
46  {
47  bool operator()(const std::pair<Real, TimeStepper *> & a,
48  const std::pair<Real, TimeStepper *> & b) const
49  {
50  return a.first < b.first;
51  }
52  };
59  Real produceCompositionDT(std::set<std::pair<Real, TimeStepper *>, CompareFirst> & dts,
60  std::set<std::pair<Real, TimeStepper *>, CompareFirst> & bound_dts);
61 
62  // Find the time point to hit at current time step
64 
69  virtual void init() override final;
70  virtual void preExecute() override final;
71  virtual void preSolve() override final;
72  virtual void postSolve() override final;
73  virtual void postExecute() override final;
74  virtual void preStep() override final;
75  virtual void postStep() override final;
76  virtual bool constrainStep(Real & dt) override final;
77 
85  virtual void step() override final;
86 
90  virtual void acceptStep() override final;
91 
95  virtual void rejectStep() override final;
96 
100  virtual bool converged() const override final;
101 
102 protected:
103  virtual Real computeDT() override final;
104  virtual Real computeInitialDT() override final;
105 
106 private:
107  template <typename Lambda>
108  void actOnTimeSteppers(Lambda && act);
109 
113  std::vector<TimeStepper *> getTimeSteppers();
114 
115  // The time step size computed by the Composition TimeStepper
116  Real _dt;
117 
118  // Whether or not has an initial time step size
119  const bool _has_initial_dt;
120 
121  // The initial time step size
122  const Real _initial_dt;
123 
124  // The time stepper(s) input as lower bound of the time stepper size
125  const std::set<std::string> _lower_bound;
126 
127  // The time stepper selected for use every time step, based on minimum time step size
129 
130  // The time stepper selected every time step as providing the lower bound
132 
133  // The time sequence stepper selected every time step as the one with the closest time to hit
135 };
TimeStepper * _largest_bound_time_stepper
static InputParameters compositionDTParams()
Definition: CompositionDT.C:22
virtual void preStep() override final
virtual void rejectStep() override final
This gets called when time step is rejected for all input time steppers.
TimeStepper * _current_time_stepper
const bool _has_initial_dt
bool operator()(const std::pair< Real, TimeStepper *> &a, const std::pair< Real, TimeStepper *> &b) const
Definition: CompositionDT.h:47
TimeSequenceStepperBase * _closest_time_sequence_stepper
const InputParameters & parameters() const
Get the parameters of the object.
Definition: MooseBase.h:127
virtual void postStep() override final
virtual void preSolve() override final
Definition: CompositionDT.C:91
void actOnTimeSteppers(Lambda &&act)
Definition: CompositionDT.C:72
Base class for time stepping.
Definition: TimeStepper.h:22
virtual void step() override final
Functions called after the current DT is computed.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
static InputParameters validParams()
Definition: CompositionDT.C:37
Comparator for sorting by the value of dt for the TimeStepper sets which stored the pairs of the dt a...
Definition: CompositionDT.h:45
A TimeStepper that takes time steppers as inputs and computes the minimum time step size among all ti...
Definition: CompositionDT.h:27
virtual bool converged() const override final
The _current_time_stepper is used to check whether convergence was reached on the time step...
Real produceCompositionDT(std::set< std::pair< Real, TimeStepper *>, CompareFirst > &dts, std::set< std::pair< Real, TimeStepper *>, CompareFirst > &bound_dts)
Find the composed time step size by selecting the minimum value and compare it with the lower bound i...
virtual void preExecute() override final
Definition: CompositionDT.C:85
virtual void acceptStep() override final
This gets called when time step is accepted for all input time steppers.
const std::set< std::string > _lower_bound
std::vector< TimeStepper * > getTimeSteppers()
Internal method for querying TheWarehouse for the currently active timesteppers.
CompositionDT(const InputParameters &parameters)
Definition: CompositionDT.C:48
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Solves the PDEs at a sequence of given time points.
Real getSequenceSteppersNextTime()
virtual Real computeDT() override final
Computes time step size after the initial time step.
virtual void postExecute() override final
virtual void init() override final
Initialize all the input time stepper(s).
Definition: CompositionDT.C:79
virtual Real computeInitialDT() override final
Computes time step size for the initial time step.
virtual bool constrainStep(Real &dt) override final
Called after computeStep() is called.
const Real _initial_dt
virtual void postSolve() override final
Definition: CompositionDT.C:97