https://mooseframework.inl.gov
Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
DistributionInterface Class Reference

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

#include <DistributionInterface.h>

Inheritance diagram for DistributionInterface:
[legend]

Public Member Functions

 DistributionInterface (const MooseObject *moose_object)
 
 DistributionInterface (const DistributionInterface &object, const Moose::Kokkos::FunctorCopy &key)
 Special constructor used for Kokkos functor copy during parallel dispatch. More...
 
const DistributiongetDistribution (const std::string &name) const
 Get a distribution with a given name. More...
 
template<typename T >
const T & getDistribution (const std::string &name) const
 
const DistributiongetDistributionByName (const DistributionName &name) const
 Get a distribution with a given name. More...
 
template<typename T >
const T & getDistributionByName (const std::string &name) const
 

Static Public Member Functions

static InputParameters validParams ()
 

Private Attributes

const InputParameters_dni_params
 Parameters of the object with this interface. More...
 
FEProblemBase_dni_feproblem
 Reference to FEProblemBase instance. More...
 
const MooseObject *const _dni_moose_object_ptr
 Pointer to the MooseObject. More...
 

Detailed Description

Interface for objects that need to use distributions.

Inherit from this class at a very low level to make the getDistribution method available.

Definition at line 25 of file DistributionInterface.h.

Constructor & Destructor Documentation

◆ DistributionInterface() [1/2]

DistributionInterface::DistributionInterface ( const MooseObject moose_object)

Definition at line 23 of file DistributionInterface.C.

24  : _dni_params(moose_object->parameters()),
26  _dni_moose_object_ptr(moose_object)
27 {
28 }
const InputParameters & parameters() const
Get the parameters of the object.
Definition: MooseBase.h:131
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...
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
FEProblemBase & _dni_feproblem
Reference to FEProblemBase instance.
const InputParameters & _dni_params
Parameters of the object with this interface.
const MooseObject *const _dni_moose_object_ptr
Pointer to the MooseObject.

◆ DistributionInterface() [2/2]

DistributionInterface::DistributionInterface ( const DistributionInterface object,
const Moose::Kokkos::FunctorCopy key 
)

Special constructor used for Kokkos functor copy during parallel dispatch.

Definition at line 31 of file DistributionInterface.C.

33  : _dni_params(object._dni_params),
36 {
37 }
FEProblemBase & _dni_feproblem
Reference to FEProblemBase instance.
const InputParameters & _dni_params
Parameters of the object with this interface.
const MooseObject *const _dni_moose_object_ptr
Pointer to the MooseObject.

Member Function Documentation

◆ getDistribution() [1/2]

const Distribution & DistributionInterface::getDistribution ( const std::string &  name) const

Get a distribution with a given name.

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

Definition at line 41 of file DistributionInterface.C.

Referenced by getDistribution(), and getDistributionByName().

42 {
43  DistributionName dist_name = _dni_params.get<DistributionName>(name);
44  return _dni_feproblem.getDistribution(dist_name);
45 }
std::string name(const ElemQuality q)
virtual Distribution & getDistribution(const std::string &name)
std::vector< std::pair< R1, R2 > > get(const std::string &param1, const std::string &param2) const
Combine two vector parameters into a single vector of pairs.
FEProblemBase & _dni_feproblem
Reference to FEProblemBase instance.
const InputParameters & _dni_params
Parameters of the object with this interface.

◆ getDistribution() [2/2]

template<typename T >
const T & DistributionInterface::getDistribution ( const std::string &  name) const

Definition at line 77 of file DistributionInterface.h.

78 {
79  try
80  {
81  const T & dist = dynamic_cast<const T &>(getDistribution(name));
82  return dist;
83  }
84  catch (std::bad_cast & exception)
85  {
86  DistributionName dist_name = _dni_params.get<DistributionName>(name);
87  mooseError("The '",
89  "' object failed to retrieve '",
90  dist_name,
91  "' distribution with the desired type.");
92  }
93 }
std::string name(const ElemQuality q)
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:323
std::vector< std::pair< R1, R2 > > get(const std::string &param1, const std::string &param2) const
Combine two vector parameters into a single vector of pairs.
const std::string & name() const
Get the name of the class.
Definition: MooseBase.h:103
const Distribution & getDistribution(const std::string &name) const
Get a distribution with a given name.
const InputParameters & _dni_params
Parameters of the object with this interface.
const MooseObject *const _dni_moose_object_ptr
Pointer to the MooseObject.

◆ getDistributionByName() [1/2]

const Distribution & DistributionInterface::getDistributionByName ( const DistributionName &  name) const

Get a distribution with a given name.

Parameters
nameThe name of the distribution to retrieve
Returns
The distribution with name 'name'

Definition at line 48 of file DistributionInterface.C.

Referenced by RandomIC::RandomIC().

49 {
50  return _dni_feproblem.getDistribution(name);
51 }
virtual Distribution & getDistribution(const std::string &name)
FEProblemBase & _dni_feproblem
Reference to FEProblemBase instance.

◆ getDistributionByName() [2/2]

template<typename T >
const T & DistributionInterface::getDistributionByName ( const std::string &  name) const

Definition at line 97 of file DistributionInterface.h.

98 {
99  try
100  {
101  const T & dist = dynamic_cast<const T &>(getDistribution(name));
102  return dist;
103  }
104  catch (std::bad_cast & exception)
105  {
106  mooseError("The '",
108  "' object failed to retrieve '",
109  name,
110  "' distribution with the desired type.");
111  }
112 }
std::string name(const ElemQuality q)
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:323
const std::string & name() const
Get the name of the class.
Definition: MooseBase.h:103
const Distribution & getDistribution(const std::string &name) const
Get a distribution with a given name.
const MooseObject *const _dni_moose_object_ptr
Pointer to the MooseObject.

◆ validParams()

InputParameters DistributionInterface::validParams ( )
static

Definition at line 17 of file DistributionInterface.C.

Referenced by RandomIC::validParams(), Sampler::validParams(), and FVInterfaceKernel::validParams().

18 {
20  return params;
21 }
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
InputParameters emptyInputParameters()

Member Data Documentation

◆ _dni_feproblem

FEProblemBase& DistributionInterface::_dni_feproblem
private

Reference to FEProblemBase instance.

Definition at line 69 of file DistributionInterface.h.

Referenced by getDistribution(), and getDistributionByName().

◆ _dni_moose_object_ptr

const MooseObject* const DistributionInterface::_dni_moose_object_ptr
private

Pointer to the MooseObject.

Definition at line 72 of file DistributionInterface.h.

Referenced by getDistribution(), and getDistributionByName().

◆ _dni_params

const InputParameters& DistributionInterface::_dni_params
private

Parameters of the object with this interface.

Definition at line 66 of file DistributionInterface.h.

Referenced by getDistribution().


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