LCOV - code coverage report
Current view: top level - include/neml2/userobjects - MOOSEQuantityToNEML2.h (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 9a5f1f Lines: 1 5 20.0 %
Date: 2026-06-21 21:23:42 Functions: 1 32 3.1 %
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 "MOOSEToNEML2.h"
      13             : #include "NEML2Utils.h"
      14             : #include "ElementUserObject.h"
      15             : 
      16             : #include "RankTwoTensor.h"
      17             : #include "SymmetricRankTwoTensor.h"
      18             : 
      19             : /**
      20             :  * Gather a MOOSE quantity for insertion into the NEML2 model.
      21             :  */
      22             : template <typename T, unsigned int state>
      23             : class MOOSEQuantityToNEML2 : public MOOSEToNEML2, public ElementUserObject
      24             : {
      25             : public:
      26             :   static InputParameters validParams();
      27             : 
      28             :   MOOSEQuantityToNEML2(const InputParameters & params);
      29             : 
      30             : #ifndef NEML2_ENABLED
      31           0 :   void initialize() override {}
      32           0 :   void execute() override {}
      33           0 :   void finalize() override {}
      34           0 :   void threadJoin(const UserObject &) override {}
      35             : #else
      36             :   void initialize() override;
      37             :   void execute() override;
      38        3059 :   void finalize() override {}
      39             :   void threadJoin(const UserObject &) override;
      40             : 
      41             :   neml2::Tensor gatheredData() const override;
      42             : 
      43             : protected:
      44             :   T qpData(unsigned int) const;
      45             : 
      46             :   /// MOOSE quantity type to read from
      47             :   const NEML2Utils::MOOSEIOType _type;
      48             : 
      49             :   ///@{
      50             :   /// candidate MOOSE quantities to read data from
      51             :   const VariableValue * _var_scalar = nullptr;
      52             :   const VariableValue * _var_scalar_old = nullptr;
      53             :   const Function * _func = nullptr;
      54             :   const MaterialProperty<T> * _mat_prop = nullptr;
      55             :   const MaterialProperty<T> * _mat_prop_old = nullptr;
      56             :   const VariableValue * _var = nullptr;
      57             :   const VariableValue * _var_old = nullptr;
      58             :   ///@}
      59             : 
      60             :   /// Whether the gathered data should be batched
      61             :   bool _batched = false;
      62             : 
      63             :   /// Intermediate data buffer, filled during the element loop
      64             :   std::vector<T> _buffer;
      65             : #endif
      66             : };
      67             : 
      68             : #define defineMOOSEQuantityToNEML2(T)                                                              \
      69             :   using MOOSE##T##ToNEML2 = MOOSEQuantityToNEML2<T, 0>;                                            \
      70             :   using MOOSEOld##T##ToNEML2 = MOOSEQuantityToNEML2<T, 1>
      71             : defineMOOSEQuantityToNEML2(Real);
      72             : defineMOOSEQuantityToNEML2(RankTwoTensor);
      73             : defineMOOSEQuantityToNEML2(SymmetricRankTwoTensor);
      74             : defineMOOSEQuantityToNEML2(RealVectorValue);
      75             : #undef defineMOOSEQuantityToNEML2

Generated by: LCOV version 1.14