Loading [MathJax]/extensions/tex2jax.js
https://mooseframework.inl.gov
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
ComposeTimeStepperAction.C
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 
11 #include "TimeStepper.h"
12 #include "FEProblemBase.h"
13 #include "CompositionDT.h"
14 #include "Factory.h"
15 #include "MooseApp.h"
16 #include "Transient.h"
17 
18 registerMooseAction("MooseApp", ComposeTimeStepperAction, "compose_time_stepper");
19 
22 {
24 
26 
27  params.addClassDescription(
28  "Add the composition time stepper if multiple time steppers have been created.");
29 
30  return params;
31 }
32 
34 {
35 }
36 
37 void
39 {
40  // Get all of the timesteppers that have been added so far
41  std::vector<const TimeStepper *> timesteppers;
42  _problem->theWarehouse().query().condition<AttribSystem>("TimeStepper").queryInto(timesteppers);
43 
44  for (const auto ts : timesteppers)
45  if (dynamic_cast<const CompositionDT *>(ts))
46  ts->mooseError(
47  "You cannot construct a ", ts->type(), "; this object is for internal use only");
48 
49  // The user added multiple timesteppers in [TimeSteppers] block, so
50  // create a composition timestepper to compute final time step size
51  if (timesteppers.size() > 1)
52  {
53  const auto final_timestepper = "CompositionDT";
54  auto new_params = _factory.getValidParams(final_timestepper);
55 
56  // Apply all custom parameters to CompositionDT that are
57  // provided in Executioner/TimeSteppers/*
58  for (const auto & param_name_value : CompositionDT::compositionDTParams())
59  if (isParamValid(param_name_value.first))
60  new_params.applyParameter(_pars, param_name_value.first);
61 
62  TransientBase * transient = dynamic_cast<TransientBase *>(_app.getExecutioner());
63  mooseAssert(transient, "The transient executioner does not exist");
64  new_params.set<TransientBase *>("_executioner") = transient;
65 
66  _problem->addObject<TimeStepper>(
67  final_timestepper, final_timestepper, new_params, /* threaded = */ false);
68  }
69 }
Add the composition time stepper as final time stepper.
static InputParameters compositionDTParams()
Definition: CompositionDT.C:22
InputParameters getValidParams(const std::string &name) const
Get valid parameters for the object.
Definition: Factory.C:68
Base class for time stepping.
Definition: TimeStepper.h:22
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
Base class for actions.
Definition: Action.h:33
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
Factory & _factory
The Factory associated with the MooseApp.
static InputParameters validParams()
Definition: Action.C:24
virtual void act() override
Method to add objects to the simulation or perform other setup tasks.
registerMooseAction("MooseApp", ComposeTimeStepperAction, "compose_time_stepper")
Base class for transient executioners that use a FixedPointSolve solve object for multiapp-main app i...
Definition: TransientBase.h:26
MooseApp & _app
The MOOSE application this is associated with.
Definition: MooseBase.h:84
Executioner * getExecutioner() const
Retrieve the Executioner for this App.
Definition: MooseApp.C:2047
ComposeTimeStepperAction(const InputParameters &params)
const InputParameters & _pars
Parameters of this object, references the InputParameters stored in the InputParametersWarehouse.
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump...
std::shared_ptr< FEProblemBase > & _problem
Convenience reference to a problem this action works on.
Definition: Action.h:168
static InputParameters validParams()
void applyParameter(const InputParameters &common, const std::string &common_name, bool allow_private=false, bool override_default=false)
Apply values from a single parameter in common, to a single parameter stored in this object...