https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
16class FEProblem;
17class FEProblemBase;
18class EigenProblem;
19class SubProblem;
20class SystemBase;
21class AuxiliarySystem;
22class 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
48 _enabled(getParam<bool>("enable"))
49{
52 "This registered object was not constructed using the Factory, which is not supported.");
53}
54
55namespace
56{
57const 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
67#endif
68
69std::shared_ptr<MooseObject>
71{
72 try
73 {
74 return shared_from_this();
75 }
76 catch (std::bad_weak_ptr &)
77 {
78 mooseError(not_shared_error);
79 }
80}
81
82std::shared_ptr<const MooseObject>
84{
85 try
86 {
87 return shared_from_this();
88 }
89 catch (std::bad_weak_ptr &)
90 {
91 mooseError(not_shared_error);
92 }
93}
unsigned int THREAD_ID
Definition MooseTypes.h:237
A system that holds auxiliary variables.
Problem for solving eigenvalue problems.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
Definition FEProblem.h:21
const InputParameters * currentlyConstructing() const
Definition Factory.C:278
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
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...
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.
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...
Factory & getFactory()
Retrieve a writable reference to the Factory associated with this App.
Definition MooseApp.h:407
const InputParameters & parameters() const
Get the parameters of the object.
Definition MooseBase.h:131
const std::string & type() const
Get the type of this class.
Definition MooseBase.h:93
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:271
const T & getParam(const std::string &name) const
Retrieve a parameter for the object.
Definition MooseBase.h:406
Every object that can be built by the factory should be derived from this class.
Definition MooseObject.h:31
const bool & _enabled
Reference to the "enable" InputParameters, used by Controls for toggling on/off MooseObjects.
Definition MooseObject.h:71
MooseObject(const InputParameters &parameters)
Definition MooseObject.C:45
static InputParameters validParams()
Definition MooseObject.C:25
std::shared_ptr< MooseObject > getSharedPtr()
Get another shared pointer to this object that has the same ownership group.
Definition MooseObject.C:70
MooseApp & _app
The MOOSE application this is associated with.
Definition MooseBase.h:375
Base class shared by both Action and MooseObject.
static InputParameters validParams()
static bool isRegisteredObj(const std::string &name)
Definition Registry.h:265
An interface that allows the marking of invalid solutions during a solve.
Generic class for solving transient nonlinear problems.
Definition SubProblem.h:79
Base class for a system (of equations)
Definition SystemBase.h:87
Base class for transient executioners that use a FixedPointSolve solve object for multiapp-main app i...