https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
18registerMooseAction("MooseApp", ComposeTimeStepperAction, "compose_time_stepper");
19
22{
24
26
28 "Add the composition time stepper if multiple time steppers have been created.");
29
30 return params;
31}
32
36
37void
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}
registerMooseAction("MooseApp", ComposeTimeStepperAction, "compose_time_stepper")
Base class for actions.
Definition Action.h:38
static InputParameters validParams()
Definition Action.C:26
MooseApp & _app
The MOOSE application this is associated with.
Definition MooseBase.h:375
std::shared_ptr< FEProblemBase > & _problem
Convenience reference to a problem this action works on.
Definition Action.h:178
Add the composition time stepper as final time stepper.
static InputParameters validParams()
ComposeTimeStepperAction(const InputParameters &params)
virtual void act() override
Method to add objects to the simulation or perform other setup tasks.
A TimeStepper that takes time steppers as inputs and computes the minimum time step size among all ti...
static InputParameters compositionDTParams()
InputParameters getValidParams(const std::string &name) const
Get valid parameters for the object.
Definition Factory.C:68
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
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.
void applyParameter(const InputParameters &common, const std::string &common_name, bool allow_private=false)
Apply values from a single parameter in common, to a single parameter stored in this object.
Executioner * getExecutioner() const
Retrieve the Executioner for this App.
Definition MooseApp.C:2015
const InputParameters & _pars
The object's parameters.
Definition MooseBase.h:384
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
Definition MooseBase.h:199
Factory & _factory
The Factory associated with the MooseApp.
Base class for time stepping.
Definition TimeStepper.h:23
Base class for transient executioners that use a FixedPointSolve solve object for multiapp-main app i...