LCOV - code coverage report
Current view: top level - include/actioncomponents - ActionComponent.h (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #32971 (54bef8) with base c6cf66 Lines: 13 26 50.0 %
Date: 2026-05-29 20:35:17 Functions: 9 21 42.9 %
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         824 :   const std::vector<MeshGeneratorName> & meshGeneratorNames() const { return _mg_names; }
      39             :   /// Return the name of the final mesh generator that contains this component
      40             :   /// This may not be one of the mesh generators of the component. If the component's mesh is combined
      41             :   /// with or stitched to another component, the combiner/stitcher would be the final mesh generator
      42         486 :   MeshGeneratorName getCurrentTopLevelMeshGeneratorName() const { return _top_mg_name; }
      43             :   /// Set the name of the final mesh generator that contains this component
      44         730 :   void setCurrentTopLevelMeshGeneratorName(const MeshGeneratorName & mg_name)
      45             :   {
      46         730 :     _top_mg_name = mg_name;
      47         730 :   }
      48             : 
      49             :   /// Returns the subdomains for the component mesh, if any
      50         294 :   const std::vector<SubdomainName> & blocks() const { return _blocks; }
      51             : 
      52             :   /// Return the outer surface boundaries
      53           0 :   virtual const std::vector<BoundaryName> & outerSurfaceBoundaries() const
      54             :   {
      55           0 :     mooseError("Not implemented");
      56             :   };
      57             : 
      58             :   /// Return the component volume
      59           0 :   virtual Real volume() const { mooseError("Volume routine is not implemented"); }
      60             : 
      61             :   /// Return the component outer boundary area
      62           0 :   virtual Real outerSurfaceArea() const { mooseError("Outer surface area is not implemented"); }
      63             : 
      64             :   /// Return the dimension of the component
      65         252 :   unsigned int dimension() const { return _dimension; }
      66             : 
      67             :   /// Merge another component's group into this component's group. The group is shared
      68             :   /// (via a shared_ptr) by every component in it, so a single call connects both sides.
      69             :   void addConnectedComponent(ActionComponent & component);
      70             :   /// Get all components connected to the component group of this component (including itself)
      71         126 :   const std::set<ActionComponent *> & getConnectedComponents() const
      72             :   {
      73         126 :     return *_connected_components;
      74             :   }
      75             : 
      76             : protected:
      77             :   // The default implementation of these routines will do nothing as we do not expect all Components
      78             :   // to be defining an object of every type
      79             :   // These routines are to help define a strictly geometrical component
      80           0 :   virtual void addMeshGenerators() {}
      81           0 :   virtual void addPositionsObject() {}
      82           0 :   virtual void addUserObjects() {}
      83           0 :   virtual void setupComponent() {}
      84             : 
      85             :   // These routines can help define a component that also defines a Physics
      86             :   /// Used to add variables on a component
      87           0 :   virtual void addSolverVariables() {}
      88             :   /// Used to add one or more Physics to be active on the component.
      89             :   /// We recommend using the PhysicsComponentInterface instead of overriding this directly
      90           0 :   virtual void addPhysics() {}
      91             :   /// Used to add materials or functor materials on a component
      92           0 :   virtual void addMaterials() {}
      93             :   /// Used for various checks notably:
      94             :   /// - that all ICs in a ComponentInitialConditionInterface are used
      95           0 :   virtual void checkIntegrity() {}
      96             : 
      97             :   /// Use this if registering a new task to the derived ActionComponent
      98           0 :   virtual void actOnAdditionalTasks() {}
      99             : 
     100             :   /// Add a new required task for all physics deriving from this class
     101             :   /// NOTE: This does not register the task, you still need to call registerMooseAction
     102        4172 :   void addRequiredTask(const std::string & task) { _required_tasks.insert(task); }
     103             : 
     104             :   /// Checks that tasks marked required by parent classes are indeed registered to derived classes
     105             :   void checkRequiredTasks() const;
     106             : 
     107             :   /// Get problem from action warehouse
     108         108 :   FEProblemBase & getProblem()
     109             :   {
     110             :     mooseAssert(_awh.problemBase().get(), "There should be a problem");
     111         108 :     return *_awh.problemBase().get();
     112             :   }
     113             : 
     114             :   /// Get the factory to build (often physics-related but not always) objects (for example a Positions)
     115         108 :   Factory & getFactory() const { return _factory; }
     116             : 
     117             :   /// Maximum dimension of the component
     118             :   unsigned int _dimension;
     119             : 
     120             :   /// Name(s) of the final mesh generator(s) creating the mesh for the component
     121             :   std::vector<MeshGeneratorName> _mg_names;
     122             :   /// Name of the top-most mesh generator in the hierarchy of MGs on top of the ones generating this component
     123             :   MeshGeneratorName _top_mg_name;
     124             : 
     125             :   /// Names of the blocks the component is comprised of
     126             :   std::vector<SubdomainName> _blocks;
     127             : 
     128             :   /// Names of the boundaries on the component outer surface
     129             :   std::vector<BoundaryName> _outer_boundaries;
     130             : 
     131             :   /// Whether the component setup should be verbose
     132             :   const bool _verbose;
     133             : 
     134             :   /// Manually keeps track of the tasks required by each component as tasks cannot be inherited
     135             :   std::set<std::string> _required_tasks;
     136             : 
     137             :   /// Group of components that share a common mesh after junctioning. The shared_ptr is shared by
     138             :   /// every member of the group so connectivity updates are visible from any member.
     139             :   std::shared_ptr<std::set<ActionComponent *>> _connected_components;
     140             : };

Generated by: LCOV version 1.14