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 "KernelBase.h" 13 : #include "MooseVariableInterface.h" 14 : 15 : class Kernel : public KernelBase, public MooseVariableInterface<Real> 16 : { 17 : public: 18 : static InputParameters validParams(); 19 : 20 : Kernel(const InputParameters & parameters); 21 : 22 : /// Compute this Kernel's contribution to the residual 23 : virtual void computeResidual() override; 24 : 25 : /// Compute this Kernel's contribution to the diagonal Jacobian entries 26 : virtual void computeJacobian() override; 27 : 28 : /// Computes d-residual / d-jvar... storing the result in Ke. 29 : virtual void computeOffDiagJacobian(unsigned int jvar) override; 30 : 31 : /// Compute the residual and Jacobian together 32 : virtual void computeResidualAndJacobian() override; 33 : 34 : /** 35 : * Computes jacobian block with respect to a scalar variable 36 : * @param jvar The number of the scalar variable 37 : */ 38 : virtual void computeOffDiagJacobianScalar(unsigned int jvar) override; 39 : 40 126448990 : virtual const MooseVariable & variable() const override { return _var; } 41 : 42 : protected: 43 : /** 44 : * Compute this Kernel's contribution to the residual at the current quadrature point 45 : */ 46 : virtual Real computeQpResidual() = 0; 47 : 48 : /** 49 : * Compute this Kernel's contribution to the Jacobian at the current quadrature point 50 : */ 51 2486636614 : virtual Real computeQpJacobian() { return 0; } 52 : 53 : /** 54 : * For coupling standard variables 55 : */ 56 1080596522 : virtual Real computeQpOffDiagJacobian(unsigned int /*jvar*/) { return 0; } 57 : 58 : /** 59 : * For coupling scalar variables 60 : */ 61 0 : virtual Real computeQpOffDiagJacobianScalar(unsigned int /*jvar*/) { return 0; } 62 : 63 : /** 64 : * For coupling array variables 65 : */ 66 49152 : virtual RealEigenVector computeQpOffDiagJacobianArray(const ArrayMooseVariable & jvar) 67 : { 68 98304 : return RealEigenVector::Zero(jvar.count()); 69 : } 70 : 71 : /// This is a regular kernel so we cast to a regular MooseVariable 72 : MooseVariable & _var; 73 : 74 : /// the current test function 75 : const VariableTestValue & _test; 76 : 77 : /// gradient of the test function 78 : const VariableTestGradient & _grad_test; 79 : 80 : /// the current shape functions 81 : const VariablePhiValue & _phi; 82 : 83 : /// gradient of the shape function 84 : const VariablePhiGradient & _grad_phi; 85 : 86 : /// Holds the solution at current quadrature points 87 : const VariableValue & _u; 88 : 89 : /// Holds the solution gradient at the current quadrature points 90 : const VariableGradient & _grad_u; 91 : };