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 : #ifdef NEML2_ENABLED 13 : 14 : // MOOSE includes 15 : #include "GeneralUserObject.h" 16 : #include "NEML2Assembly.h" 17 : #include "NEML2FEInterpolation.h" 18 : 19 : /** 20 : * @brief NEML2Kernel is a conceptual extension of MOOSE kernel that operates on NEML2 tensors 21 : * 22 : * While this is a general user object, it is conceptually a kernel in the sense that it defines the 23 : * same set of operations on a batch of input. Typical usage of this object includes 24 : * 25 : * 1. Calculating a batch of quantities given variable values/gradients interpolated onto the finite 26 : * element space. In this case, the NEML2FEInterpolation should be used to get the interpolated 27 : * values. Note that this case could be roughly interpreted as being equivalent to a MOOSE 28 : * Material. 29 : * 2. Calculating a batch of quantities given some NEML2 tensors. If the output represents the 30 : * elemental residuals/Jacobians, this could be roughly interpreted as being equivalent to a 31 : * MOOSE Kernel. 32 : */ 33 : class NEML2Kernel : public GeneralUserObject 34 : { 35 : public: 36 : static InputParameters validParams(); 37 : 38 : NEML2Kernel(const InputParameters & parameters); 39 : 40 0 : void initialize() override {} 41 : void execute() override; 42 0 : void finalize() override {} 43 : 44 : protected: 45 : /// The forward operator of this kernel 46 : virtual void forward() = 0; 47 : 48 : /// The assembly object with cached assembly information 49 : NEML2Assembly & _neml2_assembly; 50 : 51 : /// The FEM interface for getting variable values/gradients interpolated onto the finite element space 52 : NEML2FEInterpolation & _fe; 53 : 54 : /// The output of the forward operator 55 : neml2::Tensor _output; 56 : }; 57 : 58 : #endif