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...
 
const neml2::Device & output_device () const
 Get the target output 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...
 
const neml2::Device _output_device
 The device on which to store the outputs. 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 33 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 61 of file NEML2ModelInterface.h.

◆ RJType

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

Definition at line 59 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 133 of file NEML2ModelInterface.h.

134  : T(params, args...)
135 {
136 }

Member Function Documentation

◆ device()

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

Get the target compute device.

Definition at line 54 of file NEML2ModelInterface.h.

54 { 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 66 of file NEML2ModelInterface.h.

66 { 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 51 of file NEML2ModelInterface.h.

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

◆ output_device()

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

Get the target output device.

Definition at line 57 of file NEML2ModelInterface.h.

57 { return _output_device; }
const neml2::Device _output_device
The device on which to store the outputs.

◆ scheduler()

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

Get the work scheduler.

Definition at line 64 of file NEML2ModelInterface.h.

64 { 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 221 of file NEML2ModelInterface.h.

222 {
223  mooseAssert(_model != nullptr, "_model must be initialized");
224  neml2::diagnose(*_model);
225 }
std::shared_ptr< neml2::Model > _model
The NEML2 material model.

◆ validParams()

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

Definition at line 92 of file NEML2ModelInterface.h.

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

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

Member Data Documentation

◆ _async_dispatch

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

Whether to dispatch work asynchronously.

Definition at line 83 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 70 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 81 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 74 of file NEML2ModelInterface.h.

◆ _model

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

The NEML2 material model.

Definition at line 76 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 85 of file NEML2ModelInterface.h.

◆ _output_device

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

The device on which to store the outputs.

Definition at line 72 of file NEML2ModelInterface.h.

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

◆ _scheduler

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

The work scheduler to use.

Definition at line 79 of file NEML2ModelInterface.h.

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


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