Loading [MathJax]/extensions/tex2jax.js
https://mooseframework.inl.gov
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
NEML2Action.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #pragma once
11 
12 #ifdef NEML2_ENABLED
13 #include "neml2/models/Model.h"
14 #endif
15 
16 #include "Action.h"
17 
18 class NEML2ActionCommon;
19 
23 class NEML2Action : public Action
24 {
25 public:
27 
29 
30  virtual void act() override;
31 
32 protected:
33  const NEML2ActionCommon & getCommonAction() const;
34 
35 #ifdef NEML2_ENABLED
36 
37  enum class MOOSEIOType
38  {
39  MATERIAL,
40  VARIABLE,
42  };
43 
44  struct MOOSEIO
45  {
46  const std::string name;
48  };
49 
50  struct NEML2IO
51  {
52  const neml2::VariableName name;
53  const neml2::TensorType type;
54  };
55 
56  struct NEML2Param
57  {
58  const std::string name;
59  const neml2::TensorType type;
60  };
61 
63  {
64  const MOOSEIO moose;
65  const NEML2IO neml2;
66  };
67 
69  {
70  const MOOSEIO moose;
72  };
73 
75  {
76  const MOOSEIO moose;
77  const struct NEML2Derivative
78  {
79  const NEML2IO y;
80  const NEML2IO x;
81  } neml2;
82  };
83 
85  {
86  const MOOSEIO moose;
87  const struct NEML2Derivative
88  {
89  const NEML2IO y;
90  const NEML2Param x;
91  } neml2;
92  };
93 
95  void setupInputMappings(const neml2::Model &);
96 
98  void setupParameterMappings(const neml2::Model &);
99 
101  void setupOutputMappings(const neml2::Model &);
102 
104  void setupDerivativeMappings(const neml2::Model &);
105 
107  void setupParameterDerivativeMappings(const neml2::Model &);
108 
110  std::vector<VariableMapping> _inputs;
111 
113  std::vector<ParameterMapping> _params;
114 
116  std::vector<VariableMapping> _outputs;
117 
119  std::vector<DerivativeMapping> _derivs;
120 
122  std::vector<ParameterDerivativeMapping> _param_derivs;
123 
124 #endif
125  const UserObjectName _executor_name;
127 
129  const UserObjectName _idx_generator_name;
130 
132  const std::vector<SubdomainName> _block;
133 
135  std::map<MaterialPropertyName, MaterialPropertyName> _initialize_output_values;
136 
138  std::map<MaterialPropertyName, std::vector<OutputName>> _export_output_targets;
139 
140 private:
141 #ifdef NEML2_ENABLED
142  template <typename EnumType, typename T1, typename T2>
144  std::tuple<std::vector<EnumType>, std::vector<T1>, std::vector<T2>>
145  getInputParameterMapping(const std::string & moose_type_opt,
146  const std::string & moose_name_opt,
147  const std::string & neml2_name_opt) const
148  {
149  const auto moose_types = getParam<MultiMooseEnum>(moose_type_opt).getSetValueIDs<EnumType>();
150  const auto moose_names = getParam<std::vector<T1>>(moose_name_opt);
151  const auto neml2_names = getParam<std::vector<T2>>(neml2_name_opt);
152 
153  if (moose_types.size() != moose_names.size())
154  paramError(moose_name_opt, moose_name_opt, " must have the same length as ", moose_type_opt);
155  if (moose_names.size() != neml2_names.size())
156  paramError(moose_name_opt, moose_name_opt, " must have the same length as ", neml2_name_opt);
157 
158  return {moose_types, moose_names, neml2_names};
159  }
160 
162  void printSummary(const neml2::Model &) const;
163 #endif
164 
166  std::size_t getLongestMOOSEName() const;
167 };
std::vector< DerivativeMapping > _derivs
MOOSE-NEML2 derivative mappings.
Definition: NEML2Action.h:119
std::map< MaterialPropertyName, std::vector< OutputName > > _export_output_targets
Material property additional outputs.
Definition: NEML2Action.h:138
Action to set up NEML2 objects.
Definition: NEML2Action.h:23
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
const neml2::VariableName name
Definition: NEML2Action.h:52
Input parameters common to all block-restricted NEML2Actions.
const neml2::TensorType type
Definition: NEML2Action.h:59
const struct NEML2Action::DerivativeMapping::NEML2Derivative neml2
void setupParameterDerivativeMappings(const neml2::Model &)
Set up MOOSE-NEML2 parameter derivative mappings.
Definition: NEML2Action.C:448
Base class for actions.
Definition: Action.h:33
std::tuple< std::vector< EnumType >, std::vector< T1 >, std::vector< T2 > > getInputParameterMapping(const std::string &moose_type_opt, const std::string &moose_name_opt, const std::string &neml2_name_opt) const
Get parameter lists for mapping between MOOSE and NEML2 quantities.
Definition: NEML2Action.h:145
const std::vector< SubdomainName > _block
Blocks this sub-block action applies to.
Definition: NEML2Action.h:132
virtual void act() override
Method to add objects to the simulation or perform other setup tasks.
Definition: NEML2Action.C:118
const UserObjectName _executor_name
Name of the NEML2Executor user object.
Definition: NEML2Action.h:126
const std::string name
Definition: NEML2Action.h:58
std::map< MaterialPropertyName, MaterialPropertyName > _initialize_output_values
Material property initial conditions.
Definition: NEML2Action.h:135
void paramError(const std::string &param, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
std::vector< ParameterDerivativeMapping > _param_derivs
MOOSE-NEML2 parameter derivative mappings.
Definition: NEML2Action.h:122
void setupParameterMappings(const neml2::Model &)
Set up MOOSE-NEML2 model parameter mappings.
Definition: NEML2Action.C:397
const NEML2ActionCommon & getCommonAction() const
Definition: NEML2Action.C:108
NEML2Action(const InputParameters &)
Definition: NEML2Action.C:70
void printSummary(const neml2::Model &) const
Print a summary of the NEML2 model.
Definition: NEML2Action.C:473
const neml2::TensorType type
Definition: NEML2Action.h:53
const struct NEML2Action::ParameterDerivativeMapping::NEML2Derivative neml2
void setupInputMappings(const neml2::Model &)
Set up MOOSE-NEML2 input variable mappings.
Definition: NEML2Action.C:380
void setupDerivativeMappings(const neml2::Model &)
Set up MOOSE-NEML2 derivative mappings.
Definition: NEML2Action.C:426
static InputParameters validParams()
Definition: NEML2Action.C:48
const std::string name
Definition: NEML2Action.h:46
void setupOutputMappings(const neml2::Model &)
Set up MOOSE-NEML2 output variable mappings.
Definition: NEML2Action.C:409
const UserObjectName _idx_generator_name
Name of the NEML2BatchIndexGenerator user object.
Definition: NEML2Action.h:129
std::size_t getLongestMOOSEName() const
Get the maximum length of all MOOSE names (for printing purposes)
Definition: NEML2Action.C:549
std::vector< VariableMapping > _outputs
MOOSE-NEML2 output variable mappings.
Definition: NEML2Action.h:116
const MOOSEIOType type
Definition: NEML2Action.h:47
std::vector< ParameterMapping > _params
MOOSE-NEML2 model parameter mappings.
Definition: NEML2Action.h:113
std::vector< VariableMapping > _inputs
MOOSE-NEML2 input variable mappings.
Definition: NEML2Action.h:110