LCOV - code coverage report
Current view: top level - src/actioncomponents - THMActionComponent.C (source / functions) Hit Total Coverage
Test: idaholab/moose thermal_hydraulics: #32971 (54bef8) with base c6cf66 Lines: 34 35 97.1 %
Date: 2026-05-29 20:41:18 Functions: 7 7 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             : #include "THMActionComponent.h"
      11             : #include "Control.h"
      12             : 
      13             : InputParameters
      14          18 : THMActionComponent::validParams()
      15             : {
      16          18 :   InputParameters params = ActionComponent::validParams();
      17          18 :   return params;
      18             : }
      19             : 
      20          18 : THMActionComponent::THMActionComponent(const InputParameters & params) : ActionComponent(params) {}
      21             : 
      22             : void
      23          54 : THMActionComponent::actOnAdditionalTasks()
      24             : {
      25          54 :   if (_current_task == "THM:add_component")
      26          18 :     addTHMComponents();
      27          54 :   if (_current_task == "THM:add_closures")
      28          18 :     addClosures();
      29          54 :   if (_current_task == "THM:add_control_logic")
      30          18 :     addControlLogic();
      31          54 : }
      32             : 
      33             : THMProblem &
      34         198 : THMActionComponent::getTHMProblem()
      35             : {
      36         198 :   THMProblem * thm_problem = dynamic_cast<THMProblem *>(_problem.get());
      37         198 :   if (thm_problem)
      38         198 :     return *thm_problem;
      39             :   else
      40           0 :     mooseError("The Problem must derive from THMProblem to use THMActionComponents. Please include "
      41             :                "a [Components] block in your input file, even if empty.");
      42             : }
      43             : 
      44             : void
      45         126 : THMActionComponent::addTHMComponent(const std::string & class_name,
      46             :                                     const std::string & obj_name,
      47             :                                     InputParameters & params)
      48             : {
      49         126 :   auto & thm_problem = getTHMProblem();
      50         126 :   params.set<THMProblem *>("_thm_problem") = &thm_problem;
      51         126 :   thm_problem.addComponent(class_name, obj_name, params);
      52         126 : }
      53             : 
      54             : void
      55          18 : THMActionComponent::addClosuresObject(const std::string & class_name,
      56             :                                       const std::string & obj_name,
      57             :                                       InputParameters & params)
      58             : {
      59          18 :   auto & thm_problem = getTHMProblem();
      60          18 :   params.set<THMProblem *>("_thm_problem") = &thm_problem;
      61          18 :   params.set<Logger *>("_logger") = &(thm_problem.log());
      62          18 :   thm_problem.addClosures(class_name, obj_name, params);
      63          18 : }
      64             : 
      65             : void
      66          54 : THMActionComponent::addControlLogicObject(const std::string & class_name,
      67             :                                           const std::string & obj_name,
      68             :                                           InputParameters & params)
      69             : {
      70          54 :   auto & thm_problem = getTHMProblem();
      71          54 :   params.set<FEProblemBase *>("_fe_problem_base") = _problem.get();
      72          54 :   params.set<THMProblem *>("_thm_problem") = &thm_problem;
      73          54 :   std::shared_ptr<Control> control = _factory.create<Control>(class_name, obj_name, params);
      74         162 :   thm_problem.getControlWarehouse().addObject(control);
      75          54 : }

Generated by: LCOV version 1.14