https://mooseframework.inl.gov
MooseObject.C
Go to the documentation of this file.
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 
26 {
28  params.addParam<bool>("enable", true, "Set the enabled status of the MooseObject.");
29  params.addParam<std::vector<std::string>>(
30  "control_tags",
31  "Adds user-defined labels for accessing object parameters via control logic.");
32  params.addParamNamesToGroup("enable control_tags", "Advanced");
33  params.addPrivateParam<FEProblem *>("_fe_problem", nullptr);
34  params.addPrivateParam<FEProblemBase *>("_fe_problem_base", nullptr);
35  params.addPrivateParam<EigenProblem *>("_eigen_problem", nullptr);
36  params.addPrivateParam<SubProblem *>("_subproblem", nullptr);
37  params.addPrivateParam<SystemBase *>("_sys", nullptr);
38  params.addPrivateParam<SystemBase *>("_nl_sys", nullptr);
39  params.addPrivateParam<TransientBase *>("_executioner", nullptr);
40  params.addPrivateParam<THREAD_ID>("_tid");
41  params.addPrivateParam<bool>("_residual_object", false);
42  return params;
43 }
44 
46  : ParallelParamObject(parameters), _enabled(getParam<bool>("enable"))
47 {
49  mooseError(
50  "This registered object was not constructed using the Factory, which is not supported.");
51 }
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 std::shared_ptr<MooseObject>
62 {
63  try
64  {
65  return shared_from_this();
66  }
67  catch (std::bad_weak_ptr &)
68  {
69  mooseError(not_shared_error);
70  }
71 }
72 
73 std::shared_ptr<const MooseObject>
75 {
76  try
77  {
78  return shared_from_this();
79  }
80  catch (std::bad_weak_ptr &)
81  {
82  mooseError(not_shared_error);
83  }
84 }
const T & getParam(const std::string &name) const
Retrieve a parameter for the object.
Definition: MooseBase.h:384
void addPrivateParam(const std::string &name, const T &value)
These method add a parameter to the InputParameters object which can be retrieved like any other para...
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
Definition: FEProblem.h:20
const InputParameters & parameters() const
Get the parameters of the object.
Definition: MooseBase.h:127
MooseObject(const InputParameters &parameters)
Definition: MooseObject.C:45
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
std::shared_ptr< MooseObject > getSharedPtr()
Get another shared pointer to this object that has the same ownership group.
Definition: MooseObject.C:61
Base class for a system (of equations)
Definition: SystemBase.h:84
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
Factory & getFactory()
Retrieve a writable reference to the Factory associated with this App.
Definition: MooseApp.h:394
static InputParameters validParams()
const bool & _enabled
Reference to the "enable" InputParameters, used by Controls for toggling on/off MooseObjects.
Definition: MooseObject.h:50
const std::string & type() const
Get the type of this class.
Definition: MooseBase.h:89
Base class for transient executioners that use a FixedPointSolve solve object for multiapp-main app i...
Definition: TransientBase.h:27
MooseApp & _app
The MOOSE application this is associated with.
Definition: MooseBase.h:353
static bool isRegisteredObj(const std::string &name)
Definition: Registry.h:237
Generic class for solving transient nonlinear problems.
Definition: SubProblem.h:78
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type and optionally a file path to the top-level block p...
Definition: MooseBase.h:267
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object...
Problem for solving eigenvalue problems.
Definition: EigenProblem.h:21
static InputParameters validParams()
Definition: MooseObject.C:25
Base class shared by both Action and MooseObject.
A system that holds auxiliary variables.
const InputParameters * currentlyConstructing() const
Definition: Factory.C:254
unsigned int THREAD_ID
Definition: MooseTypes.h:209
void addParamNamesToGroup(const std::string &space_delim_names, const std::string group_name)
This method takes a space delimited list of parameter names and adds them to the specified group name...