https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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.");
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
46void
47ADArrayReaction::computeQpResidual(ADRealEigenVector & residual)
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}
registerMooseObject("MooseApp", ADArrayReaction)
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
Base class for array variable (equation) kernels using automatic differentiation.
const ADArrayVariableValue & _u
Holds the solution at current quadrature points.
const ArrayVariableTestValue & _test
the current test function
static InputParameters validParams()
Array kernel for adding a reaction term.
virtual void computeQpResidual(ADRealEigenVector &residual) override
Compute this Kernel's contribution to the residual at the current quadrature point,...
const ADMaterialProperty< RealEigenVector > *const _r_array
array reaction coefficient
static InputParameters validParams()
const ADMaterialProperty< RealEigenMatrix > *const _r_2d_array
matrix of reaction coefficients (for cross reaction terms between array variables)
ADArrayReaction(const InputParameters &parameters)
const ADMaterialProperty< Real > * _r
scalar reaction coefficient
static InputParameters validParams()
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
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...
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.
unsigned int _qp
The current quadrature point index.
Definition KernelBase.h:43
unsigned int _i
current index for the test function
Definition KernelBase.h:58