LCOV - code coverage report
Current view: top level - src/base - MooseObject.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #31706 (f8ed4a) with base bb0a08 Lines: 27 34 79.4 %
Date: 2025-11-03 17:23:24 Functions: 4 5 80.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 "MooseObject.h"
      12             : #include "MooseApp.h"
      13             : #include "MooseUtils.h"
      14             : #include "Factory.h"
      15             : 
      16             : class FEProblem;
      17             : class FEProblemBase;
      18             : class EigenProblem;
      19             : class SubProblem;
      20             : class SystemBase;
      21             : class AuxiliarySystem;
      22             : class TransientBase;
      23             : 
      24             : InputParameters
      25    31424895 : MooseObject::validParams()
      26             : {
      27    31424895 :   InputParameters params = ParallelParamObject::validParams();
      28   125699580 :   params.addParam<bool>("enable", true, "Set the enabled status of the MooseObject.");
      29   125699580 :   params.addParam<std::vector<std::string>>(
      30             :       "control_tags",
      31             :       "Adds user-defined labels for accessing object parameters via control logic.");
      32    94274685 :   params.addParamNamesToGroup("enable control_tags", "Advanced");
      33    62849790 :   params.addPrivateParam<FEProblem *>("_fe_problem", nullptr);
      34    62849790 :   params.addPrivateParam<FEProblemBase *>("_fe_problem_base", nullptr);
      35    62849790 :   params.addPrivateParam<EigenProblem *>("_eigen_problem", nullptr);
      36    62849790 :   params.addPrivateParam<SubProblem *>("_subproblem", nullptr);
      37    62849790 :   params.addPrivateParam<SystemBase *>("_sys", nullptr);
      38    62849790 :   params.addPrivateParam<SystemBase *>("_nl_sys", nullptr);
      39    94274685 :   params.addPrivateParam<TransientBase *>("_executioner", nullptr);
      40    31424895 :   params.addPrivateParam<THREAD_ID>("_tid");
      41    62849790 :   params.addPrivateParam<bool>("_residual_object", false);
      42    31424895 :   return params;
      43           0 : }
      44             : 
      45     2487908 : MooseObject::MooseObject(const InputParameters & parameters)
      46             :   : ParallelParamObject(parameters),
      47             :     SolutionInvalidInterface(this, parameters),
      48     4975816 :     _enabled(getParam<bool>("enable"))
      49             : {
      50     2487908 :   if (Registry::isRegisteredObj(type()) && _app.getFactory().currentlyConstructing() != &parameters)
      51           0 :     mooseError(
      52             :         "This registered object was not constructed using the Factory, which is not supported.");
      53     2487908 : }
      54             : 
      55             : namespace
      56             : {
      57             : const std::string not_shared_error =
      58             :     "MooseObject::getSharedPtr() must only be called for objects that are managed by a "
      59             :     "shared pointer. Make sure this object is build using Factory::create(...).";
      60             : }
      61             : 
      62             : #ifdef MOOSE_KOKKOS_ENABLED
      63      223399 : MooseObject::MooseObject(const MooseObject & object, const Moose::Kokkos::FunctorCopy &)
      64             :   : ParallelParamObject(object),
      65             :     SolutionInvalidInterface(this, object.parameters()),
      66      223399 :     _enabled(object._enabled)
      67             : {
      68      223399 : }
      69             : #endif
      70             : 
      71             : std::shared_ptr<MooseObject>
      72        3109 : MooseObject::getSharedPtr()
      73             : {
      74             :   try
      75             :   {
      76        6214 :     return shared_from_this();
      77             :   }
      78           4 :   catch (std::bad_weak_ptr &)
      79             :   {
      80           4 :     mooseError(not_shared_error);
      81           4 :   }
      82             : }
      83             : 
      84             : std::shared_ptr<const MooseObject>
      85           0 : MooseObject::getSharedPtr() const
      86             : {
      87             :   try
      88             :   {
      89           0 :     return shared_from_this();
      90             :   }
      91           0 :   catch (std::bad_weak_ptr &)
      92             :   {
      93           0 :     mooseError(not_shared_error);
      94           0 :   }
      95             : }

Generated by: LCOV version 1.14