https://mooseframework.inl.gov
Loading...
Searching...
No Matches
AddActionComponentAction.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
10// MOOSE includes
12#include "FEProblem.h"
13#include "Factory.h"
14#include "MooseApp.h"
15
17
20{
22 params.addClassDescription("Action responsible for creating component actions. A component "
23 "action is a component derived from an Action base class");
24 params.addRequiredParam<std::string>("type",
25 "Type of the ComponentAction to create with this Action");
26 params.addParam<bool>("isObjectAction", true, "Indicates that this is a MooseObjectAction.");
27 params.addParamNamesToGroup("isObjectAction", "Advanced");
28 return params;
29}
30
32 : Action(params),
33 _component_type(getParam<std::string>("type")),
34 _component_params(_action_factory.getValidParams(_component_type))
35{
37
38 // Verify that a Mesh syntax has been passed, as we use the mesh creation tasks
39 // from SetupMeshAction, etc
40 if (!_awh.hasTask("setup_mesh") || !_awh.hasTask("init_mesh"))
41 mooseError("ActionComponents require a [Mesh] block to be defined, even if empty");
42}
43
44void
46{
47 if (_current_task == "meta_action")
48 {
49 // Set some component parameters
50 _component_params.set<bool>("_built_by_moose") = true;
51 _component_params.set<std::string>("registered_identifier") = "(AutoBuilt)";
52
54
55 // Create and add the action to the warehouse
56 auto action_component = MooseSharedNamespace::static_pointer_cast<Action>(
58 _awh.addActionBlock(action_component);
59 }
60}
61
62void
registerMooseAction("MooseApp", AddActionComponentAction, "meta_action")
std::shared_ptr< Action > create(const std::string &action, const std::string &action_name, InputParameters &parameters)
bool hasTask(const std::string &task) const
void addActionBlock(std::shared_ptr< Action > blk)
This method add an Action instance to the warehouse.
Base class for actions.
Definition Action.h:38
static InputParameters validParams()
Definition Action.C:26
const std::string & _current_task
The current action (even though we have separate instances for each action)
Definition Action.h:172
ActionWarehouse & _awh
Reference to ActionWarehouse where we store object build by actions.
Definition Action.h:169
Action for creating component actions.
virtual void addRelationshipManagers(Moose::RelationshipManagerType when_type) override
Method to add a relationship manager for the objects being added to the system.
static InputParameters validParams()
AddActionComponentAction(const InputParameters &params)
virtual void act() override
Method to add objects to the simulation or perform other setup tasks.
InputParameters _component_params
The parameters for the component to be created.
std::string _component_type
The Component type that is being created.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
void addParamNamesToGroup(const std::string &space_delim_names, const std::string group_name)
This method takes a space delimited list of parameter names and adds them to the specified group name...
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object.
void addRequiredParam(const std::string &name, const std::string &doc_string)
This method adds a parameter and documentation string to the InputParameters object that will be extr...
std::string blockFullpath() const
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.
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
void applyParameters(const InputParameters &common, const std::vector< std::string > &exclude={}, const bool allow_private=false)
Method for applying common parameters.
const InputParameters & parameters() const
Get the parameters of the object.
Definition MooseBase.h:131
const std::string & name() const
Get the name of the class.
Definition MooseBase.h:103
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type and optionally a file path to the top-level block p...
Definition MooseBase.h:271
ActionFactory & _action_factory
Builds Actions.
RelationshipManagerType
Main types of Relationship Managers.