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 "DiracKernelBase.h" 13 : #include "MooseVariableInterface.h" 14 : #include "ADFunctorInterface.h" 15 : 16 : /** 17 : * AD version of DiracKernel 18 : */ 19 : class ADDiracKernel : public DiracKernelBase, 20 : public MooseVariableInterface<Real>, 21 : public ADFunctorInterface 22 : { 23 : public: 24 : static InputParameters validParams(); 25 : 26 : ADDiracKernel(const InputParameters & parameters); 27 : 28 : virtual void jacobianSetup() override; 29 : 30 : virtual void computeResidual() override; 31 : virtual void computeJacobian() override; 32 : virtual void computeOffDiagJacobian(unsigned int jvar) override; 33 : virtual void computeResidualAndJacobian() override; 34 : 35 172 : virtual const MooseVariableField<Real> & variable() const override { return _var; } 36 : 37 : protected: 38 : /** 39 : * Computes the residual contribution at the current quadrature point 40 : */ 41 : virtual ADReal computeQpResidual() = 0; 42 : 43 : /// Variable this kernel acts on 44 : MooseVariableField<Real> & _var; 45 : 46 : /// Values of shape functions at QPs 47 : const ADTemplateVariablePhiValue<Real> & _phi; 48 : 49 : /// Values of test functions at QPs 50 : const ADTemplateVariableTestValue<Real> & _test; 51 : 52 : /// Holds the solution at current quadrature points 53 : const ADTemplateVariableValue<Real> & _u; 54 : /// Holds the solution gradient at the current quadrature points 55 : const ADTemplateVariableGradient<Real> & _grad_u; 56 : 57 : private: 58 : /// Computes the AD residuals for the current element 59 : void computeADResiduals(); 60 : /// Computes the full Jacobian for the current element 61 : void computeFullJacobian(); 62 : 63 : /// AD residuals for the current element 64 : std::vector<ADReal> _ad_residuals; 65 : /// The element corresponding to previous Jacobian calculation 66 : const Elem * _last_jacobian_elem; 67 : };