https://mooseframework.inl.gov
ArrayReactionNodalKernel.C
Go to the documentation of this file.
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 
11 
14 
15 template <bool is_ad>
18 {
20  params.addClassDescription(
21  "Implements a simple consuming reaction term at nodes for an array variable");
22  params.addRequiredParam<RealEigenVector>("coeff",
23  "Coefficients for multiplying the reaction term");
24  return params;
25 }
26 
27 template <bool is_ad>
29  const InputParameters & parameters)
30  : GenericArrayNodalKernel<is_ad>(parameters),
31  _coeff(this->template getParam<RealEigenVector>("coeff"))
32 {
33  if (_coeff.size() != _count)
34  paramError("coeff",
35  "The size of the coefficient vector must match the size of the array variable");
36 }
37 
38 template <bool is_ad>
39 void
41 {
42  residual = _coeff.cwiseProduct(_u[_qp]);
43 }
44 
45 template <bool is_ad>
46 void
48 {
49  for (const auto i : index_range(_coeff))
50  setJacobian(i, i, _coeff(i));
51 }
52 
registerMooseObject("MooseApp", ArrayReactionNodalKernel)
const RealEigenVector & _coeff
rate coefficient
void paramError(const std::string &param, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
Definition: MooseBase.h:467
Represents a nodal reaction term equivalent to $a * u$.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
Template for array nodal kernels, using or not automatic differentiation.
void addRequiredParam(const std::string &name, const std::string &doc_string)
This method adds a parameter and documentation string to the InputParameters object that will be extr...
static InputParameters validParams()
virtual void computeQpResidual(GenericRealEigenVector< is_ad > &residual) override
virtual void computeQpJacobian() override
The user can override this function to compute the intra-variable off-diagonal Jacobian contribution ...
ArrayReactionNodalKernelTempl(const InputParameters &parameters)
static InputParameters validParams()
const unsigned int _count
Number of components of the array variable.
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump...
Eigen::Matrix< Real, Eigen::Dynamic, 1 > RealEigenVector
Definition: MooseTypes.h:147
auto index_range(const T &sizable)
Moose::GenericType< RealEigenVector, is_ad > GenericRealEigenVector
Definition: MooseTypes.h:719