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 : #include "ArrayReaction.h" 11 : 12 : registerMooseObject("MooseApp", ArrayReaction); 13 : 14 : InputParameters 15 15151 : ArrayReaction::validParams() 16 : { 17 15151 : InputParameters params = ArrayKernel::validParams(); 18 15151 : params.addRequiredParam<MaterialPropertyName>( 19 : "reaction_coefficient", 20 : "The name of the reactivity, can be scalar, vector, or matrix material property."); 21 15151 : params.addClassDescription("The array reaction operator with the weak " 22 : "form of $(\\psi_i, u_h)$."); 23 15151 : return params; 24 0 : } 25 : 26 453 : ArrayReaction::ArrayReaction(const InputParameters & parameters) 27 : : ArrayKernel(parameters), 28 906 : _r(hasMaterialProperty<Real>("reaction_coefficient") 29 453 : ? &getMaterialProperty<Real>("reaction_coefficient") 30 : : nullptr), 31 906 : _r_array(hasMaterialProperty<RealEigenVector>("reaction_coefficient") 32 453 : ? &getMaterialProperty<RealEigenVector>("reaction_coefficient") 33 : : nullptr), 34 906 : _r_2d_array(hasMaterialProperty<RealEigenMatrix>("reaction_coefficient") 35 453 : ? &getMaterialProperty<RealEigenMatrix>("reaction_coefficient") 36 453 : : nullptr) 37 : { 38 453 : if (!_r && !_r_array && !_r_2d_array) 39 : { 40 0 : MaterialPropertyName mat = getParam<MaterialPropertyName>("reaction_coefficient"); 41 0 : mooseError("Property " + mat + " is of unsupported type for ArrayReaction"); 42 0 : } 43 453 : } 44 : 45 : void 46 2738336 : ArrayReaction::computeQpResidual(RealEigenVector & residual) 47 : { 48 : 49 2738336 : if (_r) 50 0 : residual = (*_r)[_qp] * _u[_qp] * _test[_i][_qp]; 51 : 52 2738336 : else if (_r_array) 53 : { 54 : mooseAssert((*_r_array)[_qp].size() == _var.count(), 55 : "reaction_coefficient size is inconsistent with the number of components of array " 56 : "variable"); 57 : // WARNING: use noalias() syntax with caution. See ArrayDiffusion.C for more details. 58 2440672 : residual.noalias() = (*_r_array)[_qp].asDiagonal() * _u[_qp] * _test[_i][_qp]; 59 : } 60 : 61 : else 62 : { 63 : mooseAssert((*_r_2d_array)[_qp].cols() == _var.count(), 64 : "reaction_coefficient size is inconsistent with the number of components of array " 65 : "variable"); 66 : mooseAssert((*_r_2d_array)[_qp].rows() == _var.count(), 67 : "reaction_coefficient size is inconsistent with the number of components of array " 68 : "variable"); 69 : // WARNING: use noalias() syntax with caution. See ArrayDiffusion.C for more details. 70 297664 : residual.noalias() = (*_r_2d_array)[_qp] * _u[_qp] * _test[_i][_qp]; 71 : } 72 2738336 : } 73 : 74 : RealEigenVector 75 1723808 : ArrayReaction::computeQpJacobian() 76 : { 77 1723808 : if (_r) 78 0 : return RealEigenVector::Constant(_var.count(), _phi[_j][_qp] * _test[_i][_qp] * (*_r)[_qp]); 79 1723808 : else if (_r_array) 80 3228480 : return _phi[_j][_qp] * _test[_i][_qp] * (*_r_array)[_qp]; 81 : 82 : else 83 219136 : return _phi[_j][_qp] * _test[_i][_qp] * (*_r_2d_array)[_qp].diagonal(); 84 : } 85 : 86 : RealEigenMatrix 87 1179424 : ArrayReaction::computeQpOffDiagJacobian(const MooseVariableFEBase & jvar) 88 : { 89 1179424 : if (jvar.number() == _var.number() && _r_2d_array) 90 647168 : return _phi[_j][_qp] * _test[_i][_qp] * (*_r_2d_array)[_qp]; 91 : else 92 855840 : return ArrayKernel::computeQpOffDiagJacobian(jvar); 93 : }