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 : // Local Includes 13 : #include "IntegralRayKernelBase.h" 14 : 15 : // MOOSE Includes 16 : #include "MooseVariableInterface.h" 17 : #include "TaggingInterface.h" 18 : 19 : // Forward declarations 20 : template <typename> 21 : class ADRayKernelTempl; 22 : 23 : using ADRayKernel = ADRayKernelTempl<Real>; 24 : // Not implementing this until there is a use case and tests for it! 25 : // using ADVectorRayKernel = ADRayKernelTempl<RealVectorValue>; 26 : 27 : /** 28 : * Base class for an AD ray kernel that contributes to the residual and/or Jacobian 29 : */ 30 : template <typename T> 31 : class ADRayKernelTempl : public IntegralRayKernelBase, 32 : public MooseVariableInterface<T>, 33 : public TaggingInterface 34 : { 35 : public: 36 : ADRayKernelTempl(const InputParameters & params); 37 : 38 : static InputParameters validParams(); 39 : 40 : /** 41 : * The MooseVariable this RayKernel contributes to 42 : */ 43 57 : MooseVariableField<T> & variable() { return _var; } 44 : 45 : void onSegment() override final; 46 : 47 : protected: 48 : /** 49 : * Compute this kernel's contribution to the residual at _qp and _i 50 : */ 51 : virtual ADReal computeQpResidual() = 0; 52 : 53 : /** 54 : * Insertion point for calculation before the residual computation 55 : */ 56 14224 : virtual void precalculateResidual(){}; 57 : 58 : /// The MooseVariable this kernel contributes to 59 : MooseVariableField<T> & _var; 60 : 61 : /// The current test function 62 : const ADTemplateVariableTestValue<T> & _test; 63 : 64 : /// Holds the solution at current quadrature points 65 : const ADTemplateVariableValue<T> & _u; 66 : 67 : /// Holds the solution gradient at the current quadrature points 68 : const ADTemplateVariableGradient<T> & _grad_u; 69 : 70 : /// The current shape functions 71 : const ADTemplateVariablePhiValue<T> & _phi; 72 : 73 : /// Current index for the test function 74 : unsigned int _i; 75 : 76 : /// Current index for the shape function 77 : unsigned int _j; 78 : 79 : private: 80 : /** 81 : * Computes and contributes to the Jacobian for a segment 82 : */ 83 : void computeJacobian(); 84 : /** 85 : * Computes and contributes to the residual for a segment 86 : */ 87 : void computeResidual(); 88 : 89 : /// Temporary for filling the residuals 90 : std::vector<ADReal> _residuals; 91 : };