www.mooseframework.org
Public Member Functions | Private Member Functions | Private Attributes | List of all members
UserObjectInterface Class Reference

Interface for objects that need to use UserObjects. More...

#include <UserObjectInterface.h>

Inheritance diagram for UserObjectInterface:
[legend]

Public Member Functions

 UserObjectInterface (const MooseObject *moose_object)
 
template<class T >
const T & getUserObject (const std::string &name)
 Get an user object with a given parameter name. More...
 
template<class T >
const T & getUserObjectByName (const std::string &name)
 Get an user object with a given name. More...
 
const UserObjectgetUserObjectBase (const std::string &name)
 Get an user object with a given parameter name. More...
 
const UserObjectgetUserObjectBaseByName (const std::string &name)
 Get an user object with a given name. More...
 

Private Member Functions

bool needThreadedCopy (const UserObject &uo) const
 Check if the threaded copy of the user object is needed. More...
 

Private Attributes

const InputParameters_uoi_params
 Parameters of the object with this interface. More...
 
FEProblemBase_uoi_feproblem
 Reference to the FEProblemBase instance. More...
 
THREAD_ID _uoi_tid
 Thread ID. More...
 

Detailed Description

Interface for objects that need to use UserObjects.

Definition at line 24 of file UserObjectInterface.h.

Constructor & Destructor Documentation

◆ UserObjectInterface()

UserObjectInterface::UserObjectInterface ( const MooseObject moose_object)
Parameters
paramsThe parameters used by the object being instantiated. This class needs them so it can get the user object named in the input file, but the object calling getUserObject only needs to use the name on the left hand side of the statement "user_object = user_object_name"

Definition at line 16 of file UserObjectInterface.C.

17  : _uoi_params(moose_object->parameters()),
19  _uoi_tid(_uoi_params.have_parameter<THREAD_ID>("_tid") ? _uoi_params.get<THREAD_ID>("_tid") : 0)
20 {
21 }
T getCheckedPointerParam(const std::string &name, const std::string &error_string="") const
Verifies that the requested parameter exists and is not NULL and returns it to the caller...
const InputParameters & _uoi_params
Parameters of the object with this interface.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
const InputParameters & parameters() const
Get the parameters of the object.
Definition: MooseObject.h:57
FEProblemBase & _uoi_feproblem
Reference to the FEProblemBase instance.
THREAD_ID _uoi_tid
Thread ID.
unsigned int THREAD_ID
Definition: MooseTypes.h:97

Member Function Documentation

◆ getUserObject()

template<class T >
const T & UserObjectInterface::getUserObject ( const std::string &  name)

Get an user object with a given parameter name.

Parameters
nameThe name of the parameter key of the user object to retrieve
Returns
The user object with name associated with the parameter 'name'

Definition at line 81 of file UserObjectInterface.h.

82 {
83  unsigned int tid = needThreadedCopy(getUserObjectBase(name)) ? _uoi_tid : 0;
84  return _uoi_feproblem.getUserObject<T>(_uoi_params.get<UserObjectName>(name), tid);
85 }
T & getUserObject(const std::string &name, unsigned int tid=0) const
Get the user object by its name.
const InputParameters & _uoi_params
Parameters of the object with this interface.
FEProblemBase & _uoi_feproblem
Reference to the FEProblemBase instance.
THREAD_ID _uoi_tid
Thread ID.
const UserObject & getUserObjectBase(const std::string &name)
Get an user object with a given parameter name.
bool needThreadedCopy(const UserObject &uo) const
Check if the threaded copy of the user object is needed.

◆ getUserObjectBase()

const UserObject & UserObjectInterface::getUserObjectBase ( const std::string &  name)

Get an user object with a given parameter name.

Parameters
nameThe name of the parameter key of the user object to retrieve
Returns
The user object with name associated with the parameter 'name'

Definition at line 24 of file UserObjectInterface.C.

Referenced by getUserObject(), InitialConditionBase::getUserObjectBase(), and AuxKernel::getUserObjectBase().

25 {
26  return _uoi_feproblem.getUserObjectBase(_uoi_params.get<UserObjectName>(name));
27 }
const UserObject & getUserObjectBase(const std::string &name) const
Get the user object by its name.
const InputParameters & _uoi_params
Parameters of the object with this interface.
FEProblemBase & _uoi_feproblem
Reference to the FEProblemBase instance.

◆ getUserObjectBaseByName()

const UserObject & UserObjectInterface::getUserObjectBaseByName ( const std::string &  name)

Get an user object with a given name.

Parameters
nameThe name of the user object to retrieve
Returns
The user object with the name

Definition at line 30 of file UserObjectInterface.C.

Referenced by getUserObjectByName().

31 {
32  return _uoi_feproblem.getUserObjectBase(name);
33 }
const UserObject & getUserObjectBase(const std::string &name) const
Get the user object by its name.
FEProblemBase & _uoi_feproblem
Reference to the FEProblemBase instance.

◆ getUserObjectByName()

template<class T >
const T & UserObjectInterface::getUserObjectByName ( const std::string &  name)

Get an user object with a given name.

Parameters
nameThe name of the user object to retrieve
Returns
The user object with the name

Definition at line 89 of file UserObjectInterface.h.

90 {
91  unsigned int tid = needThreadedCopy(getUserObjectBaseByName(name)) ? _uoi_tid : 0;
92  return _uoi_feproblem.getUserObject<T>(name, tid);
93 }
T & getUserObject(const std::string &name, unsigned int tid=0) const
Get the user object by its name.
const UserObject & getUserObjectBaseByName(const std::string &name)
Get an user object with a given name.
FEProblemBase & _uoi_feproblem
Reference to the FEProblemBase instance.
THREAD_ID _uoi_tid
Thread ID.
bool needThreadedCopy(const UserObject &uo) const
Check if the threaded copy of the user object is needed.

◆ needThreadedCopy()

bool UserObjectInterface::needThreadedCopy ( const UserObject uo) const
private

Check if the threaded copy of the user object is needed.

Definition at line 36 of file UserObjectInterface.C.

Referenced by getUserObject(), and getUserObjectByName().

37 {
38  return (dynamic_cast<const DiscreteElementUserObject *>(&uo) != NULL) ||
39  (dynamic_cast<const ThreadedGeneralUserObject *>(&uo) != NULL);
40 }
An instance of this object type has one copy per thread that runs on each thread. ...

Member Data Documentation

◆ _uoi_feproblem

FEProblemBase& UserObjectInterface::_uoi_feproblem
private

Reference to the FEProblemBase instance.

Definition at line 70 of file UserObjectInterface.h.

Referenced by getUserObject(), getUserObjectBase(), getUserObjectBaseByName(), and getUserObjectByName().

◆ _uoi_params

const InputParameters& UserObjectInterface::_uoi_params
private

Parameters of the object with this interface.

Definition at line 67 of file UserObjectInterface.h.

Referenced by getUserObject(), and getUserObjectBase().

◆ _uoi_tid

THREAD_ID UserObjectInterface::_uoi_tid
private

Thread ID.

Definition at line 73 of file UserObjectInterface.h.

Referenced by getUserObject(), and getUserObjectByName().


The documentation for this class was generated from the following files: