https://mooseframework.inl.gov
ADArrayReaction.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 #include "ADArrayReaction.h"
11 
13 
16 {
19  params.addRequiredParam<MaterialPropertyName>(
20  "reaction_coefficient",
21  "The name of the reaction (can be either a scalar, vector, or matrix) material property.");
22  params.addClassDescription(
23  "An automatic differentiation kernel for the array reaction operator ($r * u$)");
24  return params;
25 }
26 
28  : ADArrayKernel(parameters),
29  _r(hasADMaterialProperty<Real>("reaction_coefficient")
30  ? &getADMaterialProperty<Real>("reaction_coefficient")
31  : nullptr),
32  _r_array(hasADMaterialProperty<RealEigenVector>("reaction_coefficient")
33  ? &getADMaterialProperty<RealEigenVector>("reaction_coefficient")
34  : nullptr),
35  _r_2d_array(hasADMaterialProperty<RealEigenMatrix>("reaction_coefficient")
36  ? &getADMaterialProperty<RealEigenMatrix>("reaction_coefficient")
37  : nullptr)
38 {
39  if (!_r && !_r_array && !_r_2d_array)
40  {
41  MaterialPropertyName mat = getParam<MaterialPropertyName>("reaction_coefficient");
42  mooseError("Property '" + mat + "' is of unsupported type for ADArrayReaction");
43  }
44 }
45 
46 void
48 {
49  if (_r)
50  residual = (*_r)[_qp] * _u[_qp] * _test[_i][_qp];
51  else if (_r_array)
52  residual.noalias() = (*_r_array)[_qp].cwiseProduct(_u[_qp]) * _test[_i][_qp];
53  else
54  residual.noalias() = (*_r_2d_array)[_qp] * _u[_qp] * _test[_i][_qp];
55 }
ADArrayReaction(const InputParameters &parameters)
Eigen::Matrix< ADReal, Eigen::Dynamic, 1 > ADRealEigenVector
Definition: MooseTypes.h:148
static InputParameters validParams()
Definition: ADArrayKernel.C:22
static InputParameters validParams()
static InputParameters validParams()
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
Array kernel for adding a reaction term.
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...
const ArrayVariableTestValue & _test
the current test function
Definition: ADArrayKernel.h:51
Base class for array variable (equation) kernels using automatic differentiation. ...
Definition: ADArrayKernel.h:19
unsigned int _i
current index for the test function
Definition: KernelBase.h:58
registerMooseObject("MooseApp", ADArrayReaction)
Eigen::Matrix< Real, Eigen::Dynamic, Eigen::Dynamic > RealEigenMatrix
Definition: MooseTypes.h:151
const ADMaterialProperty< Real > * _r
scalar reaction coefficient
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const ADArrayVariableValue & _u
Holds the solution at current quadrature points.
Definition: ADArrayKernel.h:64
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type and optionally a file path to the top-level block p...
Definition: MooseBase.h:271
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
virtual void computeQpResidual(ADRealEigenVector &residual) override
Compute this Kernel&#39;s contribution to the residual at the current quadrature point, to be filled in residual.
const ADMaterialProperty< RealEigenVector > *const _r_array
array reaction coefficient
const ADMaterialProperty< RealEigenMatrix > *const _r_2d_array
matrix of reaction coefficients (for cross reaction terms between array variables) ...
unsigned int _qp
The current quadrature point index.
Definition: KernelBase.h:43