https://mooseframework.inl.gov
Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Private Attributes | List of all members
NEML2ModelInterface< T > Class Template Reference

Interface class to provide common input parameters, members, and methods for MOOSEObjects that use NEML2 models. More...

#include <NEML2ModelInterface.h>

Inheritance diagram for NEML2ModelInterface< T >:
[legend]

Public Member Functions

template<typename... P>
 NEML2ModelInterface (const InputParameters &params, P &&... args)
 

Static Public Member Functions

static InputParameters validParams ()
 

Protected Types

using RJType = std::tuple< neml2::ValueMap, neml2::DerivMap >
 
using DispatcherType = neml2::WorkDispatcher< neml2::ValueMap, RJType, RJType, neml2::ValueMap, RJType >
 

Protected Member Functions

virtual void validateModel () const
 Validate the NEML2 material model. More...
 
neml2::Model & model () const
 Get the NEML2 model. More...
 
const neml2::Device & device () const
 Get the target compute device. More...
 
neml2::WorkScheduler * scheduler ()
 Get the work scheduler. More...
 
const std::unique_ptr< DispatcherType > & dispatcher () const
 Get the work dispatcher. More...
 

Private Attributes

const neml2::Device _device
 The device on which to evaluate the NEML2 model. More...
 
std::unique_ptr< neml2::Factory > _factory
 The NEML2 factory. More...
 
std::shared_ptr< neml2::Model > _model
 The NEML2 material model. More...
 
std::shared_ptr< neml2::WorkScheduler > _scheduler
 The work scheduler to use. More...
 
std::unique_ptr< DispatcherType_dispatcher
 Work dispatcher. More...
 
const bool _async_dispatch
 Whether to dispatch work asynchronously. More...
 
std::unordered_map< std::thread::id, std::shared_ptr< neml2::Model > > _model_pool
 Models for each thread. More...
 

Detailed Description

template<class T>
class NEML2ModelInterface< T >

Interface class to provide common input parameters, members, and methods for MOOSEObjects that use NEML2 models.

Definition at line 32 of file NEML2ModelInterface.h.

Member Typedef Documentation

◆ DispatcherType

template<class T>
using NEML2ModelInterface< T >::DispatcherType = neml2::WorkDispatcher<neml2::ValueMap, RJType, RJType, neml2::ValueMap, RJType>
protected

Definition at line 57 of file NEML2ModelInterface.h.

◆ RJType

template<class T>
using NEML2ModelInterface< T >::RJType = std::tuple<neml2::ValueMap, neml2::DerivMap>
protected

Definition at line 55 of file NEML2ModelInterface.h.

Constructor & Destructor Documentation

◆ NEML2ModelInterface()

template<class T >
template<typename... P>
NEML2ModelInterface< T >::NEML2ModelInterface ( const InputParameters params,
P &&...  args 
)

Definition at line 128 of file NEML2ModelInterface.h.

129  : T(params, args...)
130 {
131 }

Member Function Documentation

◆ device()

template<class T>
const neml2::Device& NEML2ModelInterface< T >::device ( ) const
inlineprotected

Get the target compute device.

Definition at line 53 of file NEML2ModelInterface.h.

53 { return _device; }
const neml2::Device _device
The device on which to evaluate the NEML2 model.

◆ dispatcher()

template<class T>
const std::unique_ptr<DispatcherType>& NEML2ModelInterface< T >::dispatcher ( ) const
inlineprotected

Get the work dispatcher.

Definition at line 62 of file NEML2ModelInterface.h.

62 { return _dispatcher; }
std::unique_ptr< DispatcherType > _dispatcher
Work dispatcher.

◆ model()

template<class T>
neml2::Model& NEML2ModelInterface< T >::model ( ) const
inlineprotected

Get the NEML2 model.

Definition at line 50 of file NEML2ModelInterface.h.

50 { return *_model; }
std::shared_ptr< neml2::Model > _model
The NEML2 material model.

◆ scheduler()

template<class T>
neml2::WorkScheduler* NEML2ModelInterface< T >::scheduler ( )
inlineprotected

Get the work scheduler.

Definition at line 60 of file NEML2ModelInterface.h.

60 { return _scheduler.get(); }
std::shared_ptr< neml2::WorkScheduler > _scheduler
The work scheduler to use.

◆ validateModel()

template<class T >
void NEML2ModelInterface< T >::validateModel ( ) const
protectedvirtual

Validate the NEML2 material model.

Note that the developer is responsible for calling this method at the appropriate times, for example, at initialSetup().

Definition at line 209 of file NEML2ModelInterface.h.

210 {
211  mooseAssert(_model != nullptr, "_model must be initialized");
212  neml2::diagnose(*_model);
213 }
std::shared_ptr< neml2::Model > _model
The NEML2 material model.

◆ validParams()

template<class T >
InputParameters NEML2ModelInterface< T >::validParams ( )
static

Definition at line 86 of file NEML2ModelInterface.h.

Referenced by NEML2ActionCommon::commonParams(), and NEML2ModelExecutor::validParams().

87 {
89  params.addParam<DataFileName>(
90  "input",
91  NEML2Utils::docstring("Path to the NEML2 input file containing the NEML2 model(s)."));
92  params.addParam<std::vector<std::string>>(
93  "cli_args",
94  {},
96  "Additional command line arguments to use when parsing the NEML2 input file."));
97  params.addParam<std::string>(
98  "model",
99  "",
100  NEML2Utils::docstring("Name of the NEML2 model, i.e., the string inside the brackets [] in "
101  "the NEML2 input file that corresponds to the model you want to use."));
102  params.addParam<std::string>(
103  "device",
104  "cpu",
106  "Device on which to evaluate the NEML2 model. The string supplied must follow the "
107  "following schema: (cpu|cuda)[:<device-index>] where cpu or cuda specifies the device "
108  "type, and :<device-index> optionally specifies a device index. For example, "
109  "device='cpu' sets the target compute device to be CPU, and device='cuda:1' sets the "
110  "target compute device to be CUDA with device ID 1."));
111 
112  params.addParam<std::string>(
113  "scheduler",
115  "NEML2 scheduler to use to run the model. If not specified no scheduler is used and "
116  "MOOSE will pass all the constitutive updates to the provided device at once."));
117 
118  params.addParam<bool>(
119  "async_dispatch", true, NEML2Utils::docstring("Whether to use asynchronous dispatch."));
120 
121  return params;
122 }
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
InputParameters validParams()
std::string docstring(const std::string &desc)
Augment docstring if NEML2 is not enabled.
Definition: NEML2Utils.C:77
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...

Member Data Documentation

◆ _async_dispatch

template<class T>
const bool NEML2ModelInterface< T >::_async_dispatch
private

Whether to dispatch work asynchronously.

Definition at line 77 of file NEML2ModelInterface.h.

◆ _device

template<class T>
const neml2::Device NEML2ModelInterface< T >::_device
private

The device on which to evaluate the NEML2 model.

Definition at line 66 of file NEML2ModelInterface.h.

Referenced by NEML2ModelInterface< GeneralUserObject >::device().

◆ _dispatcher

template<class T>
std::unique_ptr<DispatcherType> NEML2ModelInterface< T >::_dispatcher
private

Work dispatcher.

Definition at line 75 of file NEML2ModelInterface.h.

Referenced by NEML2ModelInterface< GeneralUserObject >::dispatcher().

◆ _factory

template<class T>
std::unique_ptr<neml2::Factory> NEML2ModelInterface< T >::_factory
private

The NEML2 factory.

Definition at line 68 of file NEML2ModelInterface.h.

◆ _model

template<class T>
std::shared_ptr<neml2::Model> NEML2ModelInterface< T >::_model
private

The NEML2 material model.

Definition at line 70 of file NEML2ModelInterface.h.

Referenced by NEML2ModelInterface< GeneralUserObject >::model().

◆ _model_pool

template<class T>
std::unordered_map<std::thread::id, std::shared_ptr<neml2::Model> > NEML2ModelInterface< T >::_model_pool
private

Models for each thread.

Definition at line 79 of file NEML2ModelInterface.h.

◆ _scheduler

template<class T>
std::shared_ptr<neml2::WorkScheduler> NEML2ModelInterface< T >::_scheduler
private

The work scheduler to use.

Definition at line 73 of file NEML2ModelInterface.h.

Referenced by NEML2ModelInterface< GeneralUserObject >::scheduler().


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