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 31061266 : MooseObject::validParams() 26 : { 27 31061266 : InputParameters params = ParallelParamObject::validParams(); 28 124245064 : params.addParam<bool>("enable", true, "Set the enabled status of the MooseObject."); 29 124245064 : params.addParam<std::vector<std::string>>( 30 : "control_tags", 31 : "Adds user-defined labels for accessing object parameters via control logic."); 32 93183798 : params.addParamNamesToGroup("enable control_tags", "Advanced"); 33 62122532 : params.addPrivateParam<FEProblem *>("_fe_problem", nullptr); 34 62122532 : params.addPrivateParam<FEProblemBase *>("_fe_problem_base", nullptr); 35 62122532 : params.addPrivateParam<EigenProblem *>("_eigen_problem", nullptr); 36 62122532 : params.addPrivateParam<SubProblem *>("_subproblem", nullptr); 37 62122532 : params.addPrivateParam<SystemBase *>("_sys", nullptr); 38 62122532 : params.addPrivateParam<SystemBase *>("_nl_sys", nullptr); 39 93183798 : params.addPrivateParam<TransientBase *>("_executioner", nullptr); 40 31061266 : params.addPrivateParam<THREAD_ID>("_tid"); 41 62122532 : params.addPrivateParam<bool>("_residual_object", false); 42 31061266 : return params; 43 0 : } 44 : 45 2480586 : MooseObject::MooseObject(const InputParameters & parameters) 46 4961172 : : ParallelParamObject(parameters), _enabled(getParam<bool>("enable")) 47 : { 48 2480586 : if (Registry::isRegisteredObj(type()) && _app.getFactory().currentlyConstructing() != ¶meters) 49 0 : mooseError( 50 : "This registered object was not constructed using the Factory, which is not supported."); 51 2480586 : } 52 : 53 : namespace 54 : { 55 : const std::string not_shared_error = 56 : "MooseObject::getSharedPtr() must only be called for objects that are managed by a " 57 : "shared pointer. Make sure this object is build using Factory::create(...)."; 58 : } 59 : 60 : #ifdef MOOSE_KOKKOS_ENABLED 61 200105 : MooseObject::MooseObject(const MooseObject & object, const Moose::Kokkos::FunctorCopy &) 62 200105 : : ParallelParamObject(object), _enabled(object._enabled) 63 : { 64 200105 : } 65 : #endif 66 : 67 : std::shared_ptr<MooseObject> 68 1337 : MooseObject::getSharedPtr() 69 : { 70 : try 71 : { 72 2670 : return shared_from_this(); 73 : } 74 4 : catch (std::bad_weak_ptr &) 75 : { 76 4 : mooseError(not_shared_error); 77 4 : } 78 : } 79 : 80 : std::shared_ptr<const MooseObject> 81 0 : MooseObject::getSharedPtr() const 82 : { 83 : try 84 : { 85 0 : return shared_from_this(); 86 : } 87 0 : catch (std::bad_weak_ptr &) 88 : { 89 0 : mooseError(not_shared_error); 90 0 : } 91 : }