https://mooseframework.inl.gov
NEML2ActionCommon.C
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 #include "NEML2ActionCommon.h"
11 #include "NEML2Action.h"
12 #include "NEML2Utils.h"
13 #include "NEML2ModelExecutor.h"
14 
15 #ifdef NEML2_ENABLED
16 #include "neml2/base/Factory.h"
17 #include "neml2/base/Parser.h"
18 #endif
19 
20 registerMooseAction("MooseApp", NEML2ActionCommon, "parse_neml2");
21 
24 {
27 
28  MultiMooseEnum moose_types("MATERIAL VARIABLE POSTPROCESSOR");
29 
30  // Inputs
31  params.addParam<MultiMooseEnum>(
32  "moose_input_types",
33  moose_types,
34  NEML2Utils::docstring("Type of each MOOSE data to be used as NEML2 input variable"));
35  params.addParam<std::vector<std::string>>(
36  "moose_inputs",
37  {},
38  NEML2Utils::docstring("List of MOOSE data to be used as inputs of the material model."));
39  params.addParam<std::vector<std::string>>(
40  "neml2_inputs",
41  {},
42  NEML2Utils::docstring("List of NEML2 input variables corresponding to each MOOSE data."));
43 
44  // Model parameters
45  params.addParam<MultiMooseEnum>(
46  "moose_parameter_types",
47  moose_types,
48  NEML2Utils::docstring("Type of each MOOSE data to be used as NEML2 model parameter"));
49  params.addParam<std::vector<std::string>>(
50  "moose_parameters",
51  {},
52  NEML2Utils::docstring("List of MOOSE data to be used as parameters of the material model."));
53  params.addParam<std::vector<std::string>>(
54  "neml2_parameters",
55  {},
56  NEML2Utils::docstring("List of NEML2 model parameters corresponding to each MOOSE data."));
57 
58  // Outputs
59  params.addParam<MultiMooseEnum>(
60  "moose_output_types",
61  moose_types,
62  NEML2Utils::docstring("MOOSE types used to hold the NEML2 output variables"));
63  params.addParam<std::vector<std::string>>(
64  "moose_outputs",
65  {},
66  NEML2Utils::docstring("List of MOOSE data used to hold the output of the material model."));
67  params.addParam<std::vector<std::string>>(
68  "neml2_outputs",
69  {},
70  NEML2Utils::docstring("List of NEML2 output variables corresponding to each MOOSE data."));
71 
72  // Derivatives
73  params.addParam<MultiMooseEnum>(
74  "moose_derivative_types",
75  moose_types,
76  NEML2Utils::docstring("MOOSE types used to hold the NEML2 variable derivatives"));
77  params.addParam<std::vector<std::string>>(
78  "moose_derivatives",
79  {},
81  "List of MOOSE data used to hold the derivative of the material model."));
82  params.addParam<std::vector<std::vector<std::string>>>(
83  "neml2_derivatives",
84  {},
85  NEML2Utils::docstring("List of pairs of NEML2 variables to take derivatives (i.e., first in "
86  "the pair w.r.t. the second in the pair)."));
87 
88  // Parameter derivatives
89  params.addParam<MultiMooseEnum>(
90  "moose_parameter_derivative_types",
91  moose_types,
92  NEML2Utils::docstring("MOOSE types used to hold the NEML2 parameter derivatives"));
93  params.addParam<std::vector<std::string>>(
94  "moose_parameter_derivatives",
95  {},
96  NEML2Utils::docstring("List of MOOSE data used to hold the derivative of the material model "
97  "w.r.t. model parameters."));
98  params.addParam<std::vector<std::vector<std::string>>>(
99  "neml2_parameter_derivatives",
100  {},
101  NEML2Utils::docstring("List of pairs of NEML2 variables to take derivatives (i.e., first in "
102  "the pair w.r.t. the second in the pair)."));
103 
104  // Error checking, logging, etc
105  params.addParam<std::vector<std::string>>(
106  "skip_variables",
107  {},
109  "List of NEML2 variables to skip when setting up the model input. If an input variable "
110  "is skipped, its value will stay zero. If a required input variable is not skipped, an "
111  "error will be raised."));
112  params.addParam<bool>("verbose",
113  true,
114  NEML2Utils::docstring("Whether to print additional information about the "
115  "NEML2 model at the beginning of the simulation"));
116 
117  params.addParam<std::vector<MaterialPropertyName>>(
118  "initialize_outputs",
119  {},
120  "List of MOOSE material properties to be initialized. Each these properties must correspond "
121  "to a stateful NEML2 variable (which appears on both the input old state sub-axis and the "
122  "output state sub-axis). These MOOSE material properties will be initialized with the values "
123  "of properties specified in the initialize_output_values list.");
124  params.addParam<std::vector<MaterialPropertyName>>(
125  "initialize_output_values",
126  {},
127  "List of MOOSE material properties whose initial values (evaluated at the 0th time step) "
128  "will be used to initialize stateful properties. See the description of initialize_outputs "
129  "for more details.");
130 
131  params.addParam<std::vector<MaterialPropertyName>>(
132  "export_outputs",
133  {},
134  "List of MOOSE material properties to export which correspond to NEML2 output variables or "
135  "output derivatives. Each material property's export targets can be specified by "
136  "export_output_targets. The default export target is 'none'.");
137  params.addParam<std::vector<std::vector<OutputName>>>(
138  "export_output_targets",
139  {},
140  "The export targets corresponding to each MOOSE material property specified in "
141  "export_outputs.");
142 
143  return params;
144 }
145 
148 {
149  auto params = NEML2ActionCommon::commonParams();
150  params.addClassDescription(NEML2Utils::docstring("Parse a NEML2 input file"));
151  return params;
152 }
153 
155 {
157 }
static InputParameters validParams()
static InputParameters validParams()
Parameters that can ONLY be specified under the common area.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
Input parameters common to all block-restricted NEML2Actions.
Base class for actions.
Definition: Action.h:33
registerMooseAction("MooseApp", NEML2ActionCommon, "parse_neml2")
std::string docstring(const std::string &desc)
Augment docstring if NEML2 is not enabled.
Definition: NEML2Utils.C:77
static InputParameters actionParams()
Parameters that can be specified under the NEML2Action common area.
void assertNEML2Enabled()
Assert that NEML2 is enabled.
Definition: NEML2Utils.C:87
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type...
NEML2ActionCommon(const InputParameters &)
static InputParameters commonParams()
Parameters that can be specified EITHER under the common area OR under sub-blocks.