LCOV - code coverage report
Current view: top level - src/neml2/actions - NEML2ActionCommon.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 52 53 98.1 %
Date: 2025-07-17 01:28:37 Functions: 3 3 100.0 %
Legend: Lines: hit not hit

          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             : #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             : 
      22             : InputParameters
      23         450 : NEML2ActionCommon::commonParams()
      24             : {
      25         450 :   auto params = NEML2ModelInterface<Action>::validParams();
      26         450 :   params += NEML2ModelExecutor::actionParams();
      27             : 
      28         450 :   MultiMooseEnum moose_types("MATERIAL VARIABLE POSTPROCESSOR");
      29             : 
      30             :   // Inputs
      31         450 :   params.addParam<MultiMooseEnum>(
      32             :       "moose_input_types",
      33             :       moose_types,
      34         900 :       NEML2Utils::docstring("Type of each MOOSE data to be used as NEML2 input variable"));
      35         450 :   params.addParam<std::vector<std::string>>(
      36             :       "moose_inputs",
      37             :       {},
      38         900 :       NEML2Utils::docstring("List of MOOSE data to be used as inputs of the material model."));
      39         450 :   params.addParam<std::vector<std::string>>(
      40             :       "neml2_inputs",
      41             :       {},
      42         900 :       NEML2Utils::docstring("List of NEML2 input variables corresponding to each MOOSE data."));
      43             : 
      44             :   // Model parameters
      45         450 :   params.addParam<MultiMooseEnum>(
      46             :       "moose_parameter_types",
      47             :       moose_types,
      48         900 :       NEML2Utils::docstring("Type of each MOOSE data to be used as NEML2 model parameter"));
      49         450 :   params.addParam<std::vector<std::string>>(
      50             :       "moose_parameters",
      51             :       {},
      52         900 :       NEML2Utils::docstring("List of MOOSE data to be used as parameters of the material model."));
      53         450 :   params.addParam<std::vector<std::string>>(
      54             :       "neml2_parameters",
      55             :       {},
      56         900 :       NEML2Utils::docstring("List of NEML2 model parameters corresponding to each MOOSE data."));
      57             : 
      58             :   // Outputs
      59         450 :   params.addParam<MultiMooseEnum>(
      60             :       "moose_output_types",
      61             :       moose_types,
      62         900 :       NEML2Utils::docstring("MOOSE types used to hold the NEML2 output variables"));
      63         450 :   params.addParam<std::vector<std::string>>(
      64             :       "moose_outputs",
      65             :       {},
      66         900 :       NEML2Utils::docstring("List of MOOSE data used to hold the output of the material model."));
      67         450 :   params.addParam<std::vector<std::string>>(
      68             :       "neml2_outputs",
      69             :       {},
      70         900 :       NEML2Utils::docstring("List of NEML2 output variables corresponding to each MOOSE data."));
      71             : 
      72             :   // Derivatives
      73         450 :   params.addParam<MultiMooseEnum>(
      74             :       "moose_derivative_types",
      75             :       moose_types,
      76         900 :       NEML2Utils::docstring("MOOSE types used to hold the NEML2 variable derivatives"));
      77         450 :   params.addParam<std::vector<std::string>>(
      78             :       "moose_derivatives",
      79             :       {},
      80         900 :       NEML2Utils::docstring(
      81             :           "List of MOOSE data used to hold the derivative of the material model."));
      82         450 :   params.addParam<std::vector<std::vector<std::string>>>(
      83             :       "neml2_derivatives",
      84             :       {},
      85         900 :       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         450 :   params.addParam<MultiMooseEnum>(
      90             :       "moose_parameter_derivative_types",
      91             :       moose_types,
      92         900 :       NEML2Utils::docstring("MOOSE types used to hold the NEML2 parameter derivatives"));
      93         450 :   params.addParam<std::vector<std::string>>(
      94             :       "moose_parameter_derivatives",
      95             :       {},
      96         900 :       NEML2Utils::docstring("List of MOOSE data used to hold the derivative of the material model "
      97             :                             "w.r.t. model parameters."));
      98         450 :   params.addParam<std::vector<std::vector<std::string>>>(
      99             :       "neml2_parameter_derivatives",
     100             :       {},
     101         900 :       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         450 :   params.addParam<std::vector<std::string>>(
     106             :       "skip_variables",
     107             :       {},
     108         900 :       NEML2Utils::docstring(
     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         450 :   params.addParam<bool>("verbose",
     113         450 :                         true,
     114         900 :                         NEML2Utils::docstring("Whether to print additional information about the "
     115             :                                               "NEML2 model at the beginning of the simulation"));
     116             : 
     117         450 :   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         450 :   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         450 :   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         450 :   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         900 :   return params;
     144         450 : }
     145             : 
     146             : InputParameters
     147         225 : NEML2ActionCommon::validParams()
     148             : {
     149         225 :   auto params = NEML2ActionCommon::commonParams();
     150         225 :   params.addClassDescription(NEML2Utils::docstring("Parse a NEML2 input file"));
     151         225 :   return params;
     152           0 : }
     153             : 
     154          21 : NEML2ActionCommon::NEML2ActionCommon(const InputParameters & params) : Action(params)
     155             : {
     156          21 :   NEML2Utils::assertNEML2Enabled();
     157          18 : }

Generated by: LCOV version 1.14