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

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

#include <FunctionInterface.h>

Inheritance diagram for FunctionInterface:
[legend]

Public Member Functions

 FunctionInterface (const MooseObject *moose_object)
 
 FunctionInterface (const FunctionInterface &object, const Moose::Kokkos::FunctorCopy &key)
 Special constructor used for Kokkos functor copy during parallel dispatch. More...
 
const FunctiongetFunction (const std::string &name) const
 Get a function with a given name. More...
 
const FunctiongetFunctionByName (const FunctionName &name) const
 Get a function with a given name. More...
 
bool hasFunction (const std::string &param_name) const
 Determine if the function exists. More...
 
bool hasFunctionByName (const FunctionName &name) const
 Determine if the function exists. More...
 
Moose::Kokkos::Function getKokkosFunction (const std::string &name) const
 Get a Kokkos function of an abstract type with a given name Calling this function will error out currently if Kokkos was configured with GPU. More...
 
Moose::Kokkos::Function getKokkosFunctionByName (const FunctionName &name) const
 Get a Kokkos function of an abstract type with a given name Calling this function will error out currently if Kokkos was configured with GPU. More...
 
template<typename T >
const T & getKokkosFunction (const std::string &name) const
 Get a Kokkos function of a concrete type with a given name. More...
 
template<typename T >
const T & getKokkosFunctionByName (const FunctionName &name) const
 Get a Kokkos function of a concrete type with a given name. More...
 
bool hasKokkosFunction (const std::string &param_name) const
 Determine if the Kokkos function exists. More...
 
bool hasKokkosFunctionByName (const FunctionName &name) const
 Determine if the Kokkos function exists. More...
 

Static Public Member Functions

static InputParameters validParams ()
 

Private Member Functions

const Moose::FunctionBasegetKokkosFunctionByNameHelper (const FunctionName &name) const
 Helper function to retrieve a Kokkos function. More...
 

Private Attributes

const MooseObject_fni_object
 Reference to the object. More...
 
const InputParameters_fni_params
 Parameters of the object with this interface. More...
 
FEProblemBase_fni_feproblem
 Reference to FEProblemBase instance. More...
 
const THREAD_ID _fni_tid
 Thread ID. More...
 

Detailed Description

Interface for objects that need to use functions.

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

Definition at line 46 of file FunctionInterface.h.

Constructor & Destructor Documentation

◆ FunctionInterface() [1/2]

FunctionInterface::FunctionInterface ( const MooseObject moose_object)

Definition at line 22 of file FunctionInterface.C.

23  :
24 #ifdef MOOSE_KOKKOS_ENABLED
25  _fni_object(*moose_object),
26 #endif
27  _fni_params(moose_object->parameters()),
30 {
31 }
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 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...
const MooseObject & _fni_object
Reference to the object.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
const THREAD_ID _fni_tid
Thread ID.
FEProblemBase & _fni_feproblem
Reference to FEProblemBase instance.
const InputParameters & _fni_params
Parameters of the object with this interface.
bool have_parameter(std::string_view name) const
A wrapper around the Parameters base class method.
unsigned int THREAD_ID
Definition: MooseTypes.h:237

◆ FunctionInterface() [2/2]

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

Special constructor used for Kokkos functor copy during parallel dispatch.

Member Function Documentation

◆ getFunction()

const Function & FunctionInterface::getFunction ( const std::string &  name) const

Get a function with a given name.

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

Definition at line 34 of file FunctionInterface.C.

Referenced by FunctionDT::FunctionDT(), and Output::Output().

35 {
36  return getFunctionByName(_fni_params.get<FunctionName>(name));
37 }
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 InputParameters & _fni_params
Parameters of the object with this interface.
const Function & getFunctionByName(const FunctionName &name) const
Get a function with a given name.

◆ getFunctionByName()

const Function & FunctionInterface::getFunctionByName ( const FunctionName &  name) const

◆ getKokkosFunction() [1/2]

Moose::Kokkos::Function FunctionInterface::getKokkosFunction ( const std::string &  name) const

Get a Kokkos function of an abstract type with a given name Calling this function will error out currently if Kokkos was configured with GPU.

Parameters
nameThe name of the parameter key of the Kokkos function to retrieve
Returns
The copy of the Kokkos function of the abstract type with name associated with the parameter 'name'

◆ getKokkosFunction() [2/2]

template<typename T >
const T & FunctionInterface::getKokkosFunction ( const std::string &  name) const

Get a Kokkos function of a concrete type with a given name.

Template Parameters
TThe Kokkos function type
Parameters
nameThe name of the parameter key of the Kokkos function to retrieve
Returns
The reference of the Kokkos function of the concrete type with name associated with the parameter 'name'. Always store it in a reference wrapper if to be used on GPU.

Definition at line 165 of file FunctionInterface.h.

166 {
167  return getKokkosFunctionByName<T>(_fni_params.get<FunctionName>(name));
168 }
std::string name(const ElemQuality q)
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 InputParameters & _fni_params
Parameters of the object with this interface.

◆ getKokkosFunctionByName() [1/2]

Moose::Kokkos::Function FunctionInterface::getKokkosFunctionByName ( const FunctionName &  name) const

Get a Kokkos function of an abstract type with a given name Calling this function will error out currently if Kokkos was configured with GPU.

Parameters
nameThe name of the Kokkos function to retrieve
Returns
The copy of the Kokkos function of the abstract type with name 'name'

◆ getKokkosFunctionByName() [2/2]

template<typename T >
const T & FunctionInterface::getKokkosFunctionByName ( const FunctionName &  name) const

Get a Kokkos function of a concrete type with a given name.

Template Parameters
TThe Kokkos function type
Parameters
nameThe name of the Kokkos function to retrieve
Returns
The reference of the Kokkos function of the concrete type with name 'name'. Always store it in a reference wrapper if to be used on GPU.

Definition at line 172 of file FunctionInterface.h.

173 {
174  auto function = dynamic_cast<const T *>(getKokkosFunctionByNameHelper(name));
175 
176  if (!function)
178  "Kokkos function '", name, "' is not of type '", MooseUtils::prettyCppType<T>(), "'");
179 
180  return *function;
181 }
const MooseObject & _fni_object
Reference to the object.
const Moose::FunctionBase * getKokkosFunctionByNameHelper(const FunctionName &name) const
Helper function to retrieve a Kokkos function.
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:281

◆ getKokkosFunctionByNameHelper()

const Moose::FunctionBase* FunctionInterface::getKokkosFunctionByNameHelper ( const FunctionName &  name) const
private

Helper function to retrieve a Kokkos function.

Referenced by getKokkosFunctionByName().

◆ hasFunction()

bool FunctionInterface::hasFunction ( const std::string &  param_name) const

Determine if the function exists.

Parameters
param_nameThe name of the function parameter
indexThe index of the function
Returns
True if the function exists

Definition at line 46 of file FunctionInterface.C.

47 {
48  return hasFunctionByName(_fni_params.get<FunctionName>(param_name));
49 }
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.
bool hasFunctionByName(const FunctionName &name) const
Determine if the function exists.
const InputParameters & _fni_params
Parameters of the object with this interface.

◆ hasFunctionByName()

bool FunctionInterface::hasFunctionByName ( const FunctionName &  name) const

Determine if the function exists.

Parameters
nameThe name of the function
Returns
True if the function exists

Definition at line 52 of file FunctionInterface.C.

Referenced by hasFunction().

53 {
54  return _fni_feproblem.hasFunction(name, _fni_tid);
55 }
const THREAD_ID _fni_tid
Thread ID.
FEProblemBase & _fni_feproblem
Reference to FEProblemBase instance.
virtual bool hasFunction(const std::string &name, const THREAD_ID tid=0)

◆ hasKokkosFunction()

bool FunctionInterface::hasKokkosFunction ( const std::string &  param_name) const

Determine if the Kokkos function exists.

Parameters
param_nameThe name of the Kokkos function parameter
indexThe index of the Kokkos function
Returns
True if the Kokkos function exists

◆ hasKokkosFunctionByName()

bool FunctionInterface::hasKokkosFunctionByName ( const FunctionName &  name) const

Determine if the Kokkos function exists.

Parameters
nameThe name of the Kokkos function
Returns
True if the Kokkos function exists

◆ validParams()

InputParameters FunctionInterface::validParams ( )
static

Definition at line 17 of file FunctionInterface.C.

Referenced by MFEMObject::validParams(), Control::validParams(), and FVInterfaceKernel::validParams().

18 {
19  return emptyInputParameters();
20 }
InputParameters emptyInputParameters()

Member Data Documentation

◆ _fni_feproblem

FEProblemBase& FunctionInterface::_fni_feproblem
private

Reference to FEProblemBase instance.

Definition at line 156 of file FunctionInterface.h.

Referenced by getFunctionByName(), and hasFunctionByName().

◆ _fni_object

const MooseObject& FunctionInterface::_fni_object
private

Reference to the object.

Definition at line 149 of file FunctionInterface.h.

Referenced by getKokkosFunctionByName().

◆ _fni_params

const InputParameters& FunctionInterface::_fni_params
private

Parameters of the object with this interface.

Definition at line 153 of file FunctionInterface.h.

Referenced by getFunction(), getKokkosFunction(), and hasFunction().

◆ _fni_tid

const THREAD_ID FunctionInterface::_fni_tid
private

Thread ID.

Definition at line 159 of file FunctionInterface.h.

Referenced by getFunctionByName(), and hasFunctionByName().


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