Loading [MathJax]/extensions/tex2jax.js
https://mooseframework.inl.gov
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends
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 
16 registerMooseAction("MooseApp", AddActionComponentAction, "meta_action");
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 
44 void
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 
62 void
64  Moose::RelationshipManagerType input_rm_component_type)
65 {
66  addRelationshipManagers(input_rm_component_type, _component_params);
67 }
RelationshipManagerType
Main types of Relationship Managers.
Definition: MooseTypes.h:959
ActionWarehouse & _awh
Reference to ActionWarehouse where we store object build by actions.
Definition: Action.h:159
std::string _component_type
The Component type that is being created.
bool hasTask(const std::string &task) const
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
void applyParameters(const InputParameters &common, const std::vector< std::string > &exclude={}, const bool allow_private=false)
Method for applying common parameters.
void addActionBlock(std::shared_ptr< Action > blk)
This method add an Action instance to the warehouse.
Action for creating component actions.
registerMooseAction("MooseApp", AddActionComponentAction, "meta_action")
virtual const std::string & name() const
Get the name of the class.
Definition: MooseBase.h:57
Base class for actions.
Definition: Action.h:33
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::shared_ptr< Action > create(const std::string &action, const std::string &action_name, InputParameters &parameters)
Definition: ActionFactory.C:39
static InputParameters validParams()
Definition: Action.C:24
const std::string & _current_task
The current action (even though we have separate instances for each action)
Definition: Action.h:162
ActionFactory & _action_factory
Builds Actions.
static InputParameters validParams()
std::string blockFullpath() const
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
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...
const InputParameters & parameters() const
Get the parameters of the object.
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...
InputParameters _component_params
The parameters for the component to be created.
virtual void addRelationshipManagers(Moose::RelationshipManagerType when_type) override
Method to add a relationship manager for the objects being added to the system.
AddActionComponentAction(const InputParameters &params)
virtual void act() override
Method to add objects to the simulation or perform other setup tasks.
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...