www.mooseframework.org
UserObjectInterface.h
Go to the documentation of this file.
1 /****************************************************************/
2 /* DO NOT MODIFY THIS HEADER */
3 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
4 /* */
5 /* (c) 2010 Battelle Energy Alliance, LLC */
6 /* ALL RIGHTS RESERVED */
7 /* */
8 /* Prepared by Battelle Energy Alliance, LLC */
9 /* Under Contract No. DE-AC07-05ID14517 */
10 /* With the U. S. Department of Energy */
11 /* */
12 /* See COPYRIGHT for full restrictions */
13 /****************************************************************/
14 
15 #ifndef USEROBJECTINTERFACE_H
16 #define USEROBJECTINTERFACE_H
17 
18 // MOOSE includes
19 #include "FEProblemBase.h"
20 #include "MooseTypes.h"
21 
22 // Forward declarations
23 class InputParameters;
24 
29 {
30 public:
37  UserObjectInterface(const MooseObject * moose_object);
38 
44  template <class T>
45  const T & getUserObject(const std::string & name);
46 
52  template <class T>
53  const T & getUserObjectByName(const std::string & name);
54 
60  const UserObject & getUserObjectBase(const std::string & name);
61 
67  const UserObject & getUserObjectBaseByName(const std::string & name);
68 
69 private:
72 
75 
78 
80  bool isDiscreteUserObject(const UserObject & uo) const;
81 };
82 
83 template <class T>
84 const T &
85 UserObjectInterface::getUserObject(const std::string & name)
86 {
87  unsigned int tid = isDiscreteUserObject(getUserObjectBase(name)) ? _uoi_tid : 0;
88  return _uoi_feproblem.getUserObject<T>(_uoi_params.get<UserObjectName>(name), tid);
89 }
90 
91 template <class T>
92 const T &
94 {
95  unsigned int tid = isDiscreteUserObject(getUserObjectBaseByName(name)) ? _uoi_tid : 0;
96  return _uoi_feproblem.getUserObject<T>(name, tid);
97 }
98 
99 #endif // USEROBJECTINTERFACE_H
bool isDiscreteUserObject(const UserObject &uo) const
Check if the user object is a DiscreteElementUserObject.
const T & getUserObject(const std::string &name)
Get an user object with a given parameter name.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
const InputParameters & _uoi_params
Parameters of the object with this interface.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
const T & getUserObjectByName(const std::string &name)
Get an user object with a given name.
Every object that can be built by the factory should be derived from this class.
Definition: MooseObject.h:36
const UserObject & getUserObjectBaseByName(const std::string &name)
Get an user object with a given name.
Interface for objects that need to use UserObjects.
FEProblemBase & _uoi_feproblem
Reference to the FEProblemBase instance.
THREAD_ID _uoi_tid
Thread ID.
const T & getUserObject(const std::string &name, unsigned int tid=0)
Get the user object by its name.
const UserObject & getUserObjectBase(const std::string &name)
Get an user object with a given parameter name.
Base class for user-specific data.
Definition: UserObject.h:42
unsigned int THREAD_ID
Definition: MooseTypes.h:79
UserObjectInterface(const MooseObject *moose_object)