LCOV - code coverage report
Current view: top level - include/neml2/interfaces - MOOSEToNEML2.h (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 1 1 100.0 %
Date: 2025-07-17 01:28:37 Functions: 1 1 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             : #pragma once
      11             : 
      12             : #include "NEML2Utils.h"
      13             : #include "InputParameters.h"
      14             : 
      15             : #ifdef NEML2_ENABLED
      16             : #include "neml2/models/Model.h"
      17             : #endif
      18             : 
      19             : /**
      20             :  * Common interface for inserting gathered MOOSE data into the NEML2 material model.
      21             :  *
      22             :  * This interface handles the insertion into both NEML2 input variable and NEML2 model parameter.
      23             :  *
      24             :  * Users are only required to provide the name of the variable/parameter, and we perform a run-time
      25             :  * introspection of the NEML2 model to determine if the supplied name is for a NEML2 variable or for
      26             :  * a NEML2 model parameter.
      27             :  */
      28             : class MOOSEToNEML2
      29             : {
      30             : public:
      31             :   static InputParameters validParams();
      32             : 
      33             :   MOOSEToNEML2(const InputParameters & params);
      34             : 
      35             : #ifdef NEML2_ENABLED
      36             :   enum class Mode
      37             :   {
      38             :     VARIABLE,
      39             :     OLD_VARIABLE,
      40             :     PARAMETER,
      41             :     UNDEFINED
      42             :   };
      43             : 
      44             :   /**
      45             :    * Change the mode of operation
      46             :    *
      47             :    * The NEML2ModelExecutor user object performs run-time introspection of the NEML2 model to
      48             :    * determine if the supplied name is for a NEML2 variable or for a NEML2 model parameter.
      49             :    * It then uses this method to change the mode of operation of the MOOSEToNEML2 gatherer.
      50             :    */
      51             :   void setMode(Mode) const;
      52             : 
      53             :   /// Get the current mode of operation
      54             :   Mode getMode() const { return _mode; }
      55             : 
      56             :   /// Perform error checking after _mode has been set
      57             :   virtual void checkMode() const;
      58             : 
      59             :   /// Raw name of the NEML2 variable/parameter
      60          72 :   const std::string & NEML2Name() const { return _raw_name; }
      61             : 
      62             :   /// Name of the NEML2 input variable (only meaningful when _mode == VARIABLE)
      63             :   const neml2::VariableName & NEML2VariableName() const;
      64             : 
      65             :   /// Name of the NEML2 parameter (only meaningful when _mode == PARAMETER)
      66             :   const std::string & NEML2ParameterName() const;
      67             : 
      68             :   /// Convert data gathered from MOOSE into neml2::Tensor
      69             :   virtual neml2::Tensor gatheredData() const = 0;
      70             : 
      71             :   /// Insert the gathered data into the NEML2 material model
      72             :   void insertInto(neml2::ValueMap &, std::map<std::string, neml2::Tensor> &) const;
      73             : 
      74             : protected:
      75             :   /// Whether we should insert into NEML2 input variable or NEML2 model parameter
      76             :   mutable Mode _mode;
      77             : 
      78             :   /// NEML2 input variable to transfer data to
      79             :   mutable neml2::VariableName _neml2_variable;
      80             : 
      81             :   /// NEML2 parameter to transfer data to
      82             :   mutable std::string _neml2_parameter;
      83             : 
      84             : private:
      85             :   /// Raw name of the input variable or model parameter
      86             :   const std::string _raw_name;
      87             : #endif
      88             : };

Generated by: LCOV version 1.14