Loading [MathJax]/jax/input/TeX/config.js
https://mooseframework.inl.gov
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
CreateMeshSetupActionsForComponents.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 "ActionWarehouse.h"
12 #include "ActionFactory.h"
13 #include "MooseObjectAction.h"
14 
15 registerMooseAction("MooseApp", CreateMeshSetupActionsForComponents, "meta_action_component");
16 
19 {
21  params.addClassDescription(
22  "Adds the SetupMesh-Actions to the simulation, if they are not created by the [Mesh] block.");
23 
24  return params;
25 }
26 
28  const InputParameters & params)
29  : Action(params)
30 {
31 }
32 
33 void
35 {
36  if (_current_task == "meta_action_component")
37  {
38  // Create a default SetupMeshAction. If the user wants to use Mesh parameters, then
39  // they must create a Mesh block in their input
40 
41  // Simulation already has a Mesh block, no need
42  if (_awh.hasActions("setup_mesh") && _awh.hasActions("init_mesh"))
43  return;
44 
45  // Build action parameters
46  InputParameters action_params = _action_factory.getValidParams("SetupMeshAction");
47 
48  // Build action and add it to the warehouse
49  std::shared_ptr<MooseObjectAction> action = std::static_pointer_cast<MooseObjectAction>(
50  _action_factory.create("SetupMeshAction", "Mesh", action_params));
51  _awh.addActionBlock(action);
52 
53  // Create a default SetupMeshCompleteAction
54  action = std::static_pointer_cast<MooseObjectAction>(
55  _action_factory.create("SetupMeshCompleteAction", "Mesh", action_params));
56  _awh.addActionBlock(action);
57  }
58  else
59  mooseAssert(true, "Should not reach here");
60 }
ActionWarehouse & _awh
Reference to ActionWarehouse where we store object build by actions.
Definition: Action.h:159
virtual void act() override
Method to add objects to the simulation or perform other setup tasks.
InputParameters getValidParams(const std::string &name)
Definition: ActionFactory.C:92
Action for creating the actions triggered for the [Mesh] block when the [Mesh] block is not present...
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
void addActionBlock(std::shared_ptr< Action > blk)
This method add an Action instance to the warehouse.
Base class for actions.
Definition: Action.h:33
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.
CreateMeshSetupActionsForComponents(const InputParameters &params)
bool hasActions(const std::string &task) const
Check if Actions associated with passed in task exist.
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...
registerMooseAction("MooseApp", CreateMeshSetupActionsForComponents, "meta_action_component")