LCOV - code coverage report
Current view: top level - src/neml2/actions - NEML2ActionCommon.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: fa5e60 Lines: 29 30 96.7 %
Date: 2026-06-24 08:03:36 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             : registerMooseAction("MooseApp", NEML2ActionCommon, "parse_neml2");
      16             : 
      17             : InputParameters
      18         135 : NEML2ActionCommon::commonParams()
      19             : {
      20         135 :   auto params = NEML2ModelInterface<Action>::validParams();
      21         135 :   params += NEML2ModelExecutor::actionParams();
      22             : 
      23         270 :   MultiMooseEnum moose_types("TIME SCALAR FUNCTION VARIABLE MATERIAL");
      24             : 
      25             :   // Inputs
      26         540 :   params.addParam<MultiMooseEnum>(
      27             :       "input_types", moose_types, "Type of each MOOSE data to be used as NEML2 input variable");
      28         540 :   params.addParam<std::vector<std::string>>(
      29             :       "inputs", {}, "List of NEML2 input variables corresponding to each MOOSE data.");
      30         540 :   params.addParam<std::vector<std::string>>(
      31             :       "input_kernels",
      32             :       {},
      33             :       "NEML2 kernels defined in MOOSE that provides input data. The object name must match the "
      34             :       "input variable name.");
      35             : 
      36             :   // Model parameters
      37         540 :   params.addParam<MultiMooseEnum>("parameter_types",
      38             :                                   moose_types,
      39             :                                   "Type of each MOOSE data to be used as NEML2 model parameter");
      40         540 :   params.addParam<std::vector<std::string>>(
      41             :       "parameters", {}, "List of NEML2 model parameters corresponding to each MOOSE data.");
      42             : 
      43             :   // Output
      44         405 :   params.addParam<bool>("auto_output",
      45         270 :                         true,
      46             :                         "Whether to automatically retrieve all NEML2 output variables as MOOSE "
      47             :                         "material properties.");
      48             : 
      49             :   // Derivatives
      50         540 :   params.addParam<std::vector<std::vector<std::string>>>(
      51             :       "derivatives",
      52             :       {},
      53             :       "List of pairs of NEML2 variables to take derivatives (i.e., first in the pair w.r.t. the "
      54             :       "second in the pair).");
      55             : 
      56             :   // Parameter derivatives
      57         540 :   params.addParam<std::vector<std::vector<std::string>>>(
      58             :       "parameter_derivatives",
      59             :       {},
      60             :       "List of pairs of NEML2 variables to take derivatives (i.e., first in the pair w.r.t. the "
      61             :       "second in the pair).");
      62             : 
      63             :   // Error checking, logging, etc
      64         540 :   params.addParam<std::vector<std::string>>(
      65             :       "skip_input_variables",
      66             :       {},
      67             :       "List of NEML2 variables to skip when setting up the model input. If an input variable is "
      68             :       "skipped, its value will stay zero. If a required input variable is skipped, an error "
      69             :       "will be raised.");
      70         405 :   params.addParam<bool>("verbose",
      71         270 :                         true,
      72             :                         "Whether to print additional information about the NEML2 model at the "
      73             :                         "beginning of the simulation");
      74             : 
      75         540 :   params.addParam<std::vector<MaterialPropertyName>>(
      76             :       "initialize_outputs",
      77             :       {},
      78             :       "List of MOOSE material properties to be initialized. Each these properties must correspond "
      79             :       "to a stateful NEML2 variable (which appears on both the input old state sub-axis and the "
      80             :       "output state sub-axis). These MOOSE material properties will be initialized with the values "
      81             :       "of properties specified in the initialize_output_values list.");
      82         540 :   params.addParam<std::vector<MaterialPropertyName>>(
      83             :       "initialize_output_values",
      84             :       {},
      85             :       "List of MOOSE material properties whose initial values (evaluated at the 0th time step) "
      86             :       "will be used to initialize stateful properties. See the description of initialize_outputs "
      87             :       "for more details.");
      88             : 
      89         540 :   params.addParam<std::vector<MaterialPropertyName>>(
      90             :       "export_outputs",
      91             :       {},
      92             :       "List of MOOSE material properties to export which correspond to NEML2 output variables or "
      93             :       "output derivatives. Each material property's export targets can be specified by "
      94             :       "export_output_targets. The default export target is 'none'.");
      95         405 :   params.addParam<std::vector<std::vector<OutputName>>>(
      96             :       "export_output_targets",
      97             :       {},
      98             :       "The export targets corresponding to each MOOSE material property specified in "
      99             :       "export_outputs.");
     100             : 
     101         270 :   return params;
     102         135 : }
     103             : 
     104             : InputParameters
     105          68 : NEML2ActionCommon::validParams()
     106             : {
     107          68 :   auto params = NEML2ActionCommon::commonParams();
     108          68 :   params.addClassDescription("Parse a NEML2 input file");
     109          68 :   return params;
     110           0 : }
     111             : 
     112          24 : NEML2ActionCommon::NEML2ActionCommon(const InputParameters & params) : Action(params)
     113             : {
     114          24 :   NEML2Utils::assertNEML2Enabled();
     115          21 : }

Generated by: LCOV version 1.14