LCOV - code coverage report
Current view: top level - include/actioncomponents - ActionComponent.h (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 6 19 31.6 %
Date: 2025-07-17 01:28:37 Functions: 5 17 29.4 %
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             : // MOOSE includes
      13             : #include "Action.h"
      14             : #include "ActionWarehouse.h"
      15             : #include "InputParametersChecksUtils.h"
      16             : 
      17             : class PhysicsBase;
      18             : class FEProblemBase;
      19             : 
      20             : #define registerActionComponent(app_name, component_name)                                          \
      21             :   registerMooseAction(app_name, component_name, "list_component")
      22             : 
      23             : /**
      24             :  * Base class for components that are defined using an action
      25             :  */
      26             : class ActionComponent : public Action, public InputParametersChecksUtils<ActionComponent>
      27             : {
      28             : public:
      29             :   static InputParameters validParams();
      30             : 
      31             :   ActionComponent(const InputParameters & params);
      32             : 
      33             :   virtual void act() override final;
      34             : 
      35             :   /// Get the name(s) of the mesh generator(s) created by this component that generates the mesh for it
      36             :   /// - this could be a mesh generator in the [Mesh] block
      37             :   /// - or a mesh generator created by the component
      38         504 :   const std::vector<MeshGeneratorName> & meshGeneratorNames() const { return _mg_names; }
      39             : 
      40             :   /// Returns the subdomains for the component mesh, if any
      41         312 :   const std::vector<SubdomainName> & blocks() const { return _blocks; }
      42             : 
      43             :   /// Return the outer surface boundaries
      44           0 :   virtual const std::vector<BoundaryName> & outerSurfaceBoundaries() const
      45             :   {
      46           0 :     mooseError("Not implemented");
      47             :   };
      48             : 
      49             :   /// Return the component volume
      50           0 :   virtual Real volume() const { mooseError("Volume routine is not implemented"); }
      51             : 
      52             :   /// Return the component outer boundary area
      53           0 :   virtual Real outerSurfaceArea() const { mooseError("Outer surface area is not implemented"); }
      54             : 
      55             :   /// Return the dimension of the component
      56             :   unsigned int dimension() const { return _dimension; }
      57             : 
      58             : protected:
      59             :   // The default implementation of these routines will do nothing as we do not expect all Components
      60             :   // to be defining an object of every type
      61             :   // These routines are to help define a strictly geometrical component
      62           0 :   virtual void addMeshGenerators() {}
      63           0 :   virtual void addPositionsObject() {}
      64           0 :   virtual void addUserObjects() {}
      65           0 :   virtual void setupComponent() {}
      66             : 
      67             :   // These routines can help define a component that also defines a Physics
      68             :   /// Used to add variables on a component
      69           0 :   virtual void addSolverVariables() {}
      70             :   /// Used to add one or more Physics to be active on the component.
      71             :   /// We recommend using the PhysicsComponentInterface instead of overriding this directly
      72           0 :   virtual void addPhysics() {}
      73             :   /// Used to add materials or functor materials on a component
      74           0 :   virtual void addMaterials() {}
      75             :   /// Used for various checks notably:
      76             :   /// - that all ICs in a ComponentInitialConditionInterface are used
      77           0 :   virtual void checkIntegrity() {}
      78             : 
      79             :   /// Use this if registering a new task to the derived ActionComponent
      80           0 :   virtual void actOnAdditionalTasks() {}
      81             : 
      82             :   /// Add a new required task for all physics deriving from this class
      83             :   /// NOTE: This does not register the task, you still need to call registerMooseAction
      84        1344 :   void addRequiredTask(const std::string & task) { _required_tasks.insert(task); }
      85             : 
      86             :   /// Checks that tasks marked required by parent classes are indeed registered to derived classes
      87             :   void checkRequiredTasks() const;
      88             : 
      89             :   /// Get problem from action warehouse
      90         112 :   FEProblemBase & getProblem()
      91             :   {
      92             :     mooseAssert(_awh.problemBase().get(), "There should be a problem");
      93         112 :     return *_awh.problemBase().get();
      94             :   }
      95             : 
      96             :   /// Get the factory to build (often physics-related but not always) objects (for example a Positions)
      97         112 :   Factory & getFactory() const { return _factory; }
      98             : 
      99             :   /// Maximum dimension of the component
     100             :   unsigned int _dimension;
     101             : 
     102             :   /// Name(s) of the final mesh generator(s) creating the mesh for the component
     103             :   std::vector<MeshGeneratorName> _mg_names;
     104             : 
     105             :   /// Names of the blocks the component is comprised of
     106             :   std::vector<SubdomainName> _blocks;
     107             : 
     108             :   /// Names of the boundaries on the component outer surface
     109             :   std::vector<BoundaryName> _outer_boundaries;
     110             : 
     111             :   /// Whether the component setup should be verbose
     112             :   const bool _verbose;
     113             : 
     114             :   /// Manually keeps track of the tasks required by each component as tasks cannot be inherited
     115             :   std::set<std::string> _required_tasks;
     116             : };

Generated by: LCOV version 1.14