LCOV - code coverage report
Current view: top level - src/actions - AddActionComponentAction.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 25 27 92.6 %
Date: 2025-07-17 01:28:37 Functions: 4 4 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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
      11             : #include "AddActionComponentAction.h"
      12             : #include "FEProblem.h"
      13             : #include "Factory.h"
      14             : #include "MooseApp.h"
      15             : 
      16             : registerMooseAction("MooseApp", AddActionComponentAction, "meta_action");
      17             : 
      18             : InputParameters
      19         387 : AddActionComponentAction::validParams()
      20             : {
      21         387 :   InputParameters params = Action::validParams();
      22         387 :   params.addClassDescription("Action responsible for creating component actions. A component "
      23             :                              "action is a component derived from an Action base class");
      24         387 :   params.addRequiredParam<std::string>("type",
      25             :                                        "Type of the ComponentAction to create with this Action");
      26         387 :   params.addParam<bool>("isObjectAction", true, "Indicates that this is a MooseObjectAction.");
      27         387 :   params.addParamNamesToGroup("isObjectAction", "Advanced");
      28         387 :   return params;
      29           0 : }
      30             : 
      31         184 : AddActionComponentAction::AddActionComponentAction(const InputParameters & params)
      32             :   : Action(params),
      33         184 :     _component_type(getParam<std::string>("type")),
      34         368 :     _component_params(_action_factory.getValidParams(_component_type))
      35             : {
      36         184 :   _component_params.blockFullpath() = params.blockFullpath();
      37             : 
      38             :   // Verify that a Mesh syntax has been passed, as we use the mesh creation tasks
      39             :   // from SetupMeshAction, etc
      40         184 :   if (!_awh.hasTask("setup_mesh") || !_awh.hasTask("init_mesh"))
      41           0 :     mooseError("ActionComponents require a [Mesh] block to be defined, even if empty");
      42         184 : }
      43             : 
      44             : void
      45         176 : AddActionComponentAction::act()
      46             : {
      47         176 :   if (_current_task == "meta_action")
      48             :   {
      49             :     // Set some component parameters
      50         176 :     _component_params.set<bool>("_built_by_moose") = true;
      51         176 :     _component_params.set<std::string>("registered_identifier") = "(AutoBuilt)";
      52             : 
      53         176 :     _component_params.applyParameters(parameters());
      54             : 
      55             :     // Create and add the action to the warehouse
      56             :     auto action_component = MooseSharedNamespace::static_pointer_cast<Action>(
      57         176 :         _action_factory.create(_component_type, name(), _component_params));
      58         168 :     _awh.addActionBlock(action_component);
      59         168 :   }
      60         168 : }
      61             : 
      62             : void
      63         488 : AddActionComponentAction::addRelationshipManagers(
      64             :     Moose::RelationshipManagerType input_rm_component_type)
      65             : {
      66         488 :   addRelationshipManagers(input_rm_component_type, _component_params);
      67         488 : }

Generated by: LCOV version 1.14