LCOV - code coverage report
Current view: top level - include/actions - Action.h (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #31730 (e8b711) with base e0c998 Lines: 5 5 100.0 %
Date: 2025-10-29 16:49:47 Functions: 5 6 83.3 %
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             : #pragma once
      11             : 
      12             : #include "ParallelParamObject.h"
      13             : #include "InputParameters.h"
      14             : #include "MeshMetaDataInterface.h"
      15             : #include "Registry.h"
      16             : #include "PerfGraphInterface.h"
      17             : #include "MooseObjectParameterName.h"
      18             : #include "SolutionInvalidInterface.h"
      19             : 
      20             : #include <string>
      21             : #include <ostream>
      22             : 
      23             : class ActionWarehouse;
      24             : class ActionFactory;
      25             : class MooseMesh;
      26             : class FEProblemBase;
      27             : class Executioner;
      28             : class MooseApp;
      29             : class Factory;
      30             : 
      31             : /**
      32             :  * Base class for actions.
      33             :  */
      34             : class Action : public ParallelParamObject,
      35             :                public MeshMetaDataInterface,
      36             :                public PerfGraphInterface,
      37             :                public SolutionInvalidInterface
      38             : {
      39             : public:
      40             :   /// The name of the parameter that contains the unique action name
      41             :   static const std::string unique_action_name_param;
      42             : 
      43             :   static InputParameters validParams();
      44             : 
      45             :   Action(const InputParameters & parameters);
      46             : 
      47     3126426 :   virtual ~Action() = default;
      48             : 
      49             :   /**
      50             :    * The method called externally that causes the action to act()
      51             :    */
      52             :   void timedAct();
      53             : 
      54             :   // To get warnings tracked in the SolutionInvalidityOutput
      55             :   usingCombinedWarningSolutionWarnings;
      56             : 
      57             : private:
      58             :   /**
      59             :    * Method for adding a single relationship manager
      60             :    * @param input_rm_type What relationship manager type we are currently adding
      61             :    * @param moose_object_pars The parameters of the MooseObject that requested the RM
      62             :    * @param rm_name The class type of the RM, e.g. ElementSideNeighborLayers
      63             :    * @param rm_type The RelationshipManagerType, e.g. geometric, algebraic, coupling
      64             :    * @param rm_input_parameter_func The RM callback function, typically a lambda defined in the
      65             :    *                                requesting MooseObject's validParams function
      66             :    * @param sys_type A RMSystemType that can be used to limit the systems and consequent dof_maps
      67             :    *                 that the RM can be attached to
      68             :    * @return Whether a relationship manager was added
      69             :    */
      70             :   bool
      71             :   addRelationshipManager(Moose::RelationshipManagerType input_rm_type,
      72             :                          const InputParameters & moose_object_pars,
      73             :                          std::string rm_name,
      74             :                          Moose::RelationshipManagerType rm_type,
      75             :                          Moose::RelationshipManagerInputParameterCallback rm_input_parameter_func,
      76             :                          Moose::RMSystemType sys_type = Moose::RMSystemType::NONE);
      77             : 
      78             : protected:
      79             :   /**
      80             :    * Method to add a relationship manager for the objects being added to the system. Relationship
      81             :    * managers have to be added relatively early. In many cases before the Action::act() method
      82             :    * is called.
      83             :    * @param when_type The parameter indicating the normal time for adding either Geometric or
      84             :    *        Algebraic RelationshipManagers. It may not always be possible to add your
      85             :    *        RelationshipManager as early as you'd like. In these cases, your DistributedMesh may
      86             :    *        consume more memory during the problem setup.
      87             :    * @param moose_object_pars The MooseObject to inspect for RelationshipManagers to add
      88             :    * @return Whether a relationship manager was added
      89             :    */
      90             :   bool addRelationshipManagers(Moose::RelationshipManagerType when_type,
      91             :                                const InputParameters & moose_object_pars);
      92             : 
      93             : public:
      94             :   /**
      95             :    * Method to add a relationship manager for the objects being added to the system. Relationship
      96             :    * managers have to be added relatively early. In many cases before the Action::act() method
      97             :    * is called.
      98             :    * @param when_type The parameter indicating the normal time for adding either Geometric or
      99             :    *        Algebraic RelationshipManagers. It may not always be possible to add your
     100             :    *        RelationshipManager as early as you'd like. In these cases, your DistributedMesh may
     101             :    *        consume more memory during the problem setup.
     102             :    */
     103             :   virtual void addRelationshipManagers(Moose::RelationshipManagerType when_type);
     104             : 
     105             :   /**
     106             :    * The unique name for accessing input parameters of this action in the InputParameterWarehouse
     107             :    */
     108     1478567 :   MooseObjectName uniqueActionName() const { return uniqueName(); }
     109             : 
     110     3853289 :   const std::string & specificTaskName() const { return _specific_task_name; }
     111             : 
     112     2866287 :   const std::set<std::string> & getAllTasks() const { return _all_tasks; }
     113             : 
     114     8190970 :   void appendTask(const std::string & task) { _all_tasks.insert(task); }
     115             : 
     116             : protected:
     117             :   /**
     118             :    * Method to add objects to the simulation or perform other setup tasks.
     119             :    */
     120             :   virtual void act() = 0;
     121             : 
     122             :   /**
     123             :    * Associates the object's parameters \p params with the input location from this
     124             :    * Action's parameter with the name \p param_name, if one exists.
     125             :    *
     126             :    * For example, you have a parameter in this action of type bool with name "add_mesh".
     127             :    * You then add an action within this action that creates a mesh if this param is
     128             :    * true. If you call associateWithParameter("add_mesh", action_params) where
     129             :    * action_params are the parameters for the action, we then associate that action
     130             :    * with the "add_mesh" parameter. Therefore, the resulting created mesh will also
     131             :    * be associated with the "add_mesh" param and any errors that are non-parameter errors
     132             :    * (i.e., mooseError/mooseWarning) will have the line context of the "add_mesh"
     133             :    * parameter in this action. The same goes for any errors that are produce within
     134             :    * the created action.
     135             :    */
     136             :   void associateWithParameter(const std::string & param_name, InputParameters & params) const;
     137             : 
     138             :   /**
     139             :    * The same as associateWithParameter() without \p from_params, but instead
     140             :    * allows you to associate this with another object's parameters instead of the
     141             :    * parameters from this action.
     142             :    *
     143             :    * An example here is when you want to associate the creation of an action with
     144             :    * an argument from the application.
     145             :    */
     146             :   void associateWithParameter(const InputParameters & from_params,
     147             :                               const std::string & param_name,
     148             :                               InputParameters & params) const;
     149             : 
     150             :   // The registered syntax for this block if any
     151             :   std::string _registered_identifier;
     152             : 
     153             :   /**
     154             :    * This member will only be populated if this Action instance is only designed to
     155             :    * handle one task.  This happens when an Action is registered with several pieces
     156             :    * of syntax in which case separate instances are built to handle the different
     157             :    * incoming parameter values.
     158             :    */
     159             :   std::string _specific_task_name;
     160             : 
     161             :   /**
     162             :    * A list of all the tasks that this Action will satisfy.
     163             :    * Note: That this is _not_ populated at construction time.  However, all tasks will be
     164             :    *       added prior to act().
     165             :    */
     166             :   std::set<std::string> _all_tasks;
     167             : 
     168             :   /// Reference to ActionWarehouse where we store object build by actions
     169             :   ActionWarehouse & _awh;
     170             : 
     171             :   /// The current action (even though we have separate instances for each action)
     172             :   const std::string & _current_task;
     173             : 
     174             :   std::shared_ptr<MooseMesh> & _mesh;
     175             :   std::shared_ptr<MooseMesh> & _displaced_mesh;
     176             : 
     177             :   /// Convenience reference to a problem this action works on
     178             :   std::shared_ptr<FEProblemBase> & _problem;
     179             : 
     180             :   /// Timers
     181             :   PerfID _act_timer;
     182             : 
     183             :   // Base classes have the same name for that attribute, pick one
     184             :   using MooseBase::_app;
     185             : };

Generated by: LCOV version 1.14