Line data Source code
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 : registerMooseAction("MooseApp", NEML2ActionCommon, "parse_neml2");
16 :
17 : InputParameters
18 105 : NEML2ActionCommon::commonParams()
19 : {
20 105 : auto params = NEML2ModelInterface<Action>::validParams();
21 105 : params += NEML2ModelExecutor::actionParams();
22 :
23 210 : MultiMooseEnum moose_types("MATERIAL VARIABLE POSTPROCESSOR");
24 :
25 : // Inputs
26 420 : params.addParam<MultiMooseEnum>("moose_input_types",
27 : moose_types,
28 : "Type of each MOOSE data to be used as NEML2 input variable");
29 420 : params.addParam<std::vector<std::string>>(
30 : "moose_inputs", {}, "List of MOOSE data to be used as inputs of the material model.");
31 420 : params.addParam<std::vector<std::string>>(
32 : "neml2_inputs", {}, "List of NEML2 input variables corresponding to each MOOSE data.");
33 420 : params.addParam<std::vector<std::string>>(
34 : "moose_input_kernels", {}, "NEML2 kernels defined in MOOSE that provides input data.");
35 :
36 : // Model parameters
37 420 : params.addParam<MultiMooseEnum>("moose_parameter_types",
38 : moose_types,
39 : "Type of each MOOSE data to be used as NEML2 model parameter");
40 420 : params.addParam<std::vector<std::string>>(
41 : "moose_parameters", {}, "List of MOOSE data to be used as parameters of the material model.");
42 420 : params.addParam<std::vector<std::string>>(
43 : "neml2_parameters", {}, "List of NEML2 model parameters corresponding to each MOOSE data.");
44 :
45 : // Outputs
46 420 : params.addParam<MultiMooseEnum>(
47 : "moose_output_types", moose_types, "MOOSE types used to hold the NEML2 output variables");
48 420 : params.addParam<std::vector<std::string>>(
49 : "moose_outputs", {}, "List of MOOSE data used to hold the output of the material model.");
50 420 : params.addParam<std::vector<std::string>>(
51 : "neml2_outputs", {}, "List of NEML2 output variables corresponding to each MOOSE data.");
52 :
53 : // Derivatives
54 420 : params.addParam<MultiMooseEnum>("moose_derivative_types",
55 : moose_types,
56 : "MOOSE types used to hold the NEML2 variable derivatives");
57 420 : params.addParam<std::vector<std::string>>(
58 : "moose_derivatives",
59 : {},
60 : "List of MOOSE data used to hold the derivative of the material model.");
61 420 : params.addParam<std::vector<std::vector<std::string>>>(
62 : "neml2_derivatives",
63 : {},
64 : "List of pairs of NEML2 variables to take derivatives (i.e., first in "
65 : "the pair w.r.t. the second in the pair).");
66 :
67 : // Parameter derivatives
68 420 : params.addParam<MultiMooseEnum>("moose_parameter_derivative_types",
69 : moose_types,
70 : "MOOSE types used to hold the NEML2 parameter derivatives");
71 420 : params.addParam<std::vector<std::string>>(
72 : "moose_parameter_derivatives",
73 : {},
74 : "List of MOOSE data used to hold the derivative of the material model "
75 : "w.r.t. model parameters.");
76 420 : params.addParam<std::vector<std::vector<std::string>>>(
77 : "neml2_parameter_derivatives",
78 : {},
79 : "List of pairs of NEML2 variables to take derivatives (i.e., first in the pair w.r.t. the "
80 : "second in the pair).");
81 :
82 : // Error checking, logging, etc
83 420 : params.addParam<std::vector<std::string>>(
84 : "skip_variables",
85 : {},
86 : "List of NEML2 variables to skip when setting up the model input. If an input variable is "
87 : "skipped, its value will stay zero. If a required input variable is not skipped, an error "
88 : "will be raised.");
89 315 : params.addParam<bool>("verbose",
90 210 : true,
91 : "Whether to print additional information about the NEML2 model at the "
92 : "beginning of the simulation");
93 :
94 420 : params.addParam<std::vector<MaterialPropertyName>>(
95 : "initialize_outputs",
96 : {},
97 : "List of MOOSE material properties to be initialized. Each these properties must correspond "
98 : "to a stateful NEML2 variable (which appears on both the input old state sub-axis and the "
99 : "output state sub-axis). These MOOSE material properties will be initialized with the values "
100 : "of properties specified in the initialize_output_values list.");
101 420 : params.addParam<std::vector<MaterialPropertyName>>(
102 : "initialize_output_values",
103 : {},
104 : "List of MOOSE material properties whose initial values (evaluated at the 0th time step) "
105 : "will be used to initialize stateful properties. See the description of initialize_outputs "
106 : "for more details.");
107 :
108 420 : params.addParam<std::vector<MaterialPropertyName>>(
109 : "export_outputs",
110 : {},
111 : "List of MOOSE material properties to export which correspond to NEML2 output variables or "
112 : "output derivatives. Each material property's export targets can be specified by "
113 : "export_output_targets. The default export target is 'none'.");
114 315 : params.addParam<std::vector<std::vector<OutputName>>>(
115 : "export_output_targets",
116 : {},
117 : "The export targets corresponding to each MOOSE material property specified in "
118 : "export_outputs.");
119 :
120 210 : return params;
121 105 : }
122 :
123 : InputParameters
124 55 : NEML2ActionCommon::validParams()
125 : {
126 55 : auto params = NEML2ActionCommon::commonParams();
127 55 : params.addClassDescription("Parse a NEML2 input file");
128 55 : return params;
129 0 : }
130 :
131 11 : NEML2ActionCommon::NEML2ActionCommon(const InputParameters & params) : Action(params)
132 : {
133 11 : NEML2Utils::assertNEML2Enabled();
134 8 : }
|