LCOV - code coverage report
Current view: top level - src/actioncomponents - ActionComponent.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 31 43 72.1 %
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 "ActionComponent.h"
      12             : #include "ActionFactory.h"
      13             : 
      14             : InputParameters
      15        3093 : ActionComponent::validParams()
      16             : {
      17        3093 :   InputParameters params = Action::validParams();
      18        3093 :   params.addClassDescription("Base class for components that are defined using actions.");
      19        3093 :   params.addParam<bool>("verbose", false, "Whether the component setup should be verbose");
      20             : 
      21             :   // These parameters should not appear. Let's suppress them for now
      22        3093 :   params.suppressParameter<std::vector<std::string>>("active");
      23        3093 :   params.suppressParameter<std::vector<std::string>>("inactive");
      24             : 
      25        3093 :   return params;
      26           0 : }
      27             : 
      28         176 : ActionComponent::ActionComponent(const InputParameters & params)
      29             :   : Action(params),
      30             :     InputParametersChecksUtils<ActionComponent>(this),
      31         176 :     _dimension(libMesh::invalid_uint),
      32         176 :     _verbose(getParam<bool>("verbose"))
      33             : {
      34         176 : }
      35             : 
      36             : void
      37         652 : ActionComponent::act()
      38             : {
      39             :   // This is inspired by the PhysicsBase definition of act(). We register components to the
      40             :   // task they use, and the base class calls the appropriate virtual member functions
      41         652 :   mooseDoOnce(checkRequiredTasks());
      42             : 
      43             :   // These tasks are conceptually what we imagine a mostly-geometrical component should do
      44         652 :   if (_current_task == "add_mesh_generator")
      45         168 :     addMeshGenerators();
      46         484 :   else if (_current_task == "add_positions")
      47           0 :     addPositionsObject();
      48         484 :   else if (_current_task == "add_user_object")
      49           0 :     addUserObjects();
      50         484 :   else if (_current_task == "setup_component")
      51           0 :     setupComponent();
      52             :   // If we define the Physics in a Physics block. See PhysicsComponentBase
      53         484 :   else if (_current_task == "init_component_physics")
      54         168 :     addPhysics();
      55             :   // These tasks are there to match what the current combined Physics + Component do
      56             :   // These combined components will likely still exist in the future, when it makes more
      57             :   // sense to include the physics than to split it off into its own block
      58         316 :   else if (_current_task == "add_variable")
      59           0 :     addSolverVariables();
      60             :   // Useful for declaring materials on a component, which helps keep the input of local material
      61             :   // properties on the component
      62         316 :   else if (_current_task == "add_material")
      63         164 :     addMaterials();
      64         152 :   else if (_current_task == "check_integrity")
      65         152 :     checkIntegrity();
      66             :   else
      67             :     // For a new task that isn't registered to ActionComponent in the framework
      68           0 :     actOnAdditionalTasks();
      69         644 : }
      70             : 
      71             : void
      72         100 : ActionComponent::checkRequiredTasks() const
      73             : {
      74         100 :   const auto registered_tasks = _action_factory.getTasksByAction(type());
      75             : 
      76             :   // Check for missing tasks
      77         500 :   for (const auto & required_task : _required_tasks)
      78         400 :     if (!registered_tasks.count(required_task))
      79           0 :       mooseWarning(
      80           0 :           "Task '" + required_task +
      81           0 :           "' has been declared as required by a Component parent class of derived class '" +
      82           0 :           type() +
      83             :           "' but this task is not registered to the derived class. Registered tasks for "
      84           0 :           "this Component are: " +
      85           0 :           Moose::stringify(registered_tasks));
      86         100 : }

Generated by: LCOV version 1.14