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 "NodalKernelBase.h" 13 : #include "ADFunctorInterface.h" 14 : #include "MooseVariableInterface.h" 15 : 16 : /** 17 : * Base class for creating nodal kernels with AD-computed Jacobians 18 : */ 19 : class ADNodalKernel : public NodalKernelBase, 20 : public ADFunctorInterface, 21 : public MooseVariableInterface<Real> 22 : { 23 : public: 24 : /** 25 : * Class constructor. 26 : * @param parameters The InputParameters for the object 27 : */ 28 : static InputParameters validParams(); 29 : 30 : ADNodalKernel(const InputParameters & parameters); 31 : 32 : /** 33 : * Compute the residual at the current node. 34 : * 35 : * Note: This is NOT what a user would normally want to override. 36 : * Usually a user would override computeQpResidual() 37 : */ 38 : void computeResidual() override; 39 : 40 : /** 41 : * Compute the Jacobian at one node. 42 : * 43 : * Note: This is NOT what a user would normally want to override. 44 : * Usually a user would override computeQpJacobian() 45 : */ 46 : void computeJacobian() override; 47 : 48 : /** 49 : * This method simply routes to computeJacobian whenever jvar == _var.number() since global AD 50 : * computes all the derivatives for all variables at once 51 : */ 52 : void computeOffDiagJacobian(unsigned int jvar) override final; 53 : 54 : /** 55 : * Gets the variable this is active on 56 : * @return the variable 57 : */ 58 1173891 : const MooseVariable & variable() const override { return _var; } 59 : 60 : protected: 61 : /** 62 : * The user can override this function to compute the residual at a node. 63 : */ 64 : virtual ADReal computeQpResidual() = 0; 65 : 66 : /// variable this works on 67 : MooseVariable & _var; 68 : 69 : /// Value of the unknown variable this is acting on 70 : const ADVariableValue & _u; 71 : };