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 : // MOOSE includes 13 : #include "DiracKernelInfo.h" 14 : #include "MooseVariableInterface.h" 15 : #include "DiracKernelBase.h" 16 : 17 : // forward declarations 18 : template <typename> 19 : class DiracKernelTempl; 20 : 21 : using DiracKernel = DiracKernelTempl<Real>; 22 : using VectorDiracKernel = DiracKernelTempl<RealVectorValue>; 23 : 24 : /** 25 : * A DiracKernel is used when you need to add contributions to the residual by means of 26 : * multiplying some number by the shape functions on an element and adding the value into 27 : * the residual vector at the places associated with that shape function. 28 : * 29 : * This is common in point sources / sinks and various other algorithms. 30 : */ 31 : template <typename T> 32 : class DiracKernelTempl : public DiracKernelBase, public MooseVariableInterface<T> 33 : { 34 : public: 35 : static InputParameters validParams(); 36 : 37 : DiracKernelTempl(const InputParameters & parameters); 38 : 39 : /** 40 : * Computes the residual for the current element. 41 : */ 42 : virtual void computeResidual() override; 43 : 44 : /** 45 : * Computes the jacobian for the current element. 46 : */ 47 : virtual void computeJacobian() override; 48 : 49 : /** 50 : * This gets called by computeOffDiagJacobian() at each quadrature point. 51 : */ 52 : virtual Real computeQpOffDiagJacobian(unsigned int jvar) override; 53 : 54 : /** 55 : * Computes the off-diagonal Jacobian for variable jvar. 56 : */ 57 : virtual void computeOffDiagJacobian(unsigned int jvar) override; 58 : 59 72984 : virtual const MooseVariableField<T> & variable() const override { return _var; } 60 : 61 : /** 62 : * This is where the DiracKernel should call addPoint() for each point it needs to have a 63 : * value distributed at. 64 : */ 65 : virtual void addPoints() override = 0; 66 : 67 : protected: 68 : /** 69 : * This is the virtual that derived classes should override for computing the residual. 70 : */ 71 : virtual Real computeQpResidual() = 0; 72 : 73 : /** 74 : * This is the virtual that derived classes should override for computing the Jacobian. 75 : */ 76 : virtual Real computeQpJacobian(); 77 : 78 : /// Variable this kernel acts on 79 : MooseVariableField<T> & _var; 80 : 81 : // shape functions 82 : 83 : /// Values of shape functions at QPs 84 : const typename OutputTools<T>::VariablePhiValue & _phi; 85 : /// Gradients of shape functions at QPs 86 : const typename OutputTools<T>::VariablePhiGradient & _grad_phi; 87 : 88 : // test functions 89 : 90 : /// Values of test functions at QPs 91 : const typename OutputTools<T>::VariableTestValue & _test; 92 : /// Gradients of test functions at QPs 93 : const typename OutputTools<T>::VariableTestGradient & _grad_test; 94 : 95 : /// Holds the solution at current quadrature points 96 : const typename OutputTools<T>::VariableValue & _u; 97 : /// Holds the solution gradient at the current quadrature points 98 : const typename OutputTools<T>::VariableGradient & _grad_u; 99 : 100 : /// drop duplicate points or consider them in residual and Jacobian 101 : const bool _drop_duplicate_points; 102 : 103 : // @{ Point-not-found behavior 104 : enum class PointNotFoundBehavior 105 : { 106 : ERROR, 107 : WARNING, 108 : IGNORE 109 : }; 110 : const PointNotFoundBehavior _point_not_found_behavior; 111 : // @} 112 : };