https://mooseframework.inl.gov
Loading...
Searching...
No Matches
ArrayReaction.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
10#include "ArrayReaction.h"
11#include "FEProblemBase.h"
13
15
18{
20 params.addRequiredParam<MaterialPropertyName>(
21 "reaction_coefficient",
22 "The name of the reactivity, can be scalar, vector, or matrix material property.");
23 params.addClassDescription("The array reaction operator with the weak "
24 "form of $(\\psi_i, u_h)$.");
25 return params;
26}
27
29 : ArrayKernel(parameters),
30 _r(hasMaterialProperty<Real>("reaction_coefficient")
31 ? &getMaterialProperty<Real>("reaction_coefficient")
32 : nullptr),
33 _r_array(hasMaterialProperty<RealEigenVector>("reaction_coefficient")
34 ? &getMaterialProperty<RealEigenVector>("reaction_coefficient")
35 : nullptr),
36 _r_2d_array(hasMaterialProperty<RealEigenMatrix>("reaction_coefficient")
37 ? &getMaterialProperty<RealEigenMatrix>("reaction_coefficient")
38 : nullptr)
39{
40 if (!_r && !_r_array && !_r_2d_array)
41 {
42 MaterialPropertyName mat = getParam<MaterialPropertyName>("reaction_coefficient");
43 mooseError("Property " + mat + " is of unsupported type for ArrayReaction");
44 }
45}
46
47void
58
59void
60ArrayReaction::computeQpResidual(RealEigenVector & residual)
61{
62
63 if (_r)
64 residual = (*_r)[_qp] * _u[_qp] * _test[_i][_qp];
65
66 else if (_r_array)
67 {
68 mooseAssert((*_r_array)[_qp].size() == _var.count(),
69 "reaction_coefficient size is inconsistent with the number of components of array "
70 "variable");
71 // WARNING: use noalias() syntax with caution. See ArrayDiffusion.C for more details.
72 residual.noalias() = (*_r_array)[_qp].cwiseProduct(_u[_qp]) * _test[_i][_qp];
73 }
74
75 else
76 {
77 mooseAssert((*_r_2d_array)[_qp].cols() == _var.count(),
78 "reaction_coefficient size is inconsistent with the number of components of array "
79 "variable");
80 mooseAssert((*_r_2d_array)[_qp].rows() == _var.count(),
81 "reaction_coefficient size is inconsistent with the number of components of array "
82 "variable");
83 // WARNING: use noalias() syntax with caution. See ArrayDiffusion.C for more details.
84 residual.noalias() = (*_r_2d_array)[_qp] * _u[_qp] * _test[_i][_qp];
85 }
86}
87
88RealEigenVector
90{
91 if (_r)
92 return RealEigenVector::Constant(_var.count(), _phi[_j][_qp] * _test[_i][_qp] * (*_r)[_qp]);
93 else if (_r_array)
94 return _phi[_j][_qp] * _test[_i][_qp] * (*_r_array)[_qp];
95
96 else
97 return _phi[_j][_qp] * _test[_i][_qp] * (*_r_2d_array)[_qp].diagonal();
98}
99
100RealEigenMatrix
102{
103 if (jvar.number() == _var.number() && _r_2d_array)
104 return _phi[_j][_qp] * _test[_i][_qp] * (*_r_2d_array)[_qp];
105 else
107}
registerMooseObject("MooseApp", ArrayReaction)
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
const ArrayVariableTestValue & _test
the current test function
Definition ArrayKernel.h:88
static InputParameters validParams()
Definition ArrayKernel.C:23
ArrayMooseVariable & _var
This is an array kernel so we cast to a ArrayMooseVariable.
Definition ArrayKernel.h:85
virtual RealEigenMatrix computeQpOffDiagJacobian(const MooseVariableFEBase &jvar)
This is the virtual that derived classes should override for computing a full Jacobian component.
const ArrayVariableValue & _u
Holds the solution at current quadrature points.
const ArrayVariablePhiValue & _phi
the current shape functions
Definition ArrayKernel.h:95
const MaterialProperty< RealEigenMatrix > *const _r_2d_array
matrix diffusion coefficient
const MaterialProperty< RealEigenVector > *const _r_array
array diffusion coefficient
static InputParameters validParams()
const MaterialProperty< Real > *const _r
scalar diffusion coefficient
virtual RealEigenMatrix computeQpOffDiagJacobian(const MooseVariableFEBase &jvar) override
This is the virtual that derived classes should override for computing a full Jacobian component.
virtual void computeQpResidual(RealEigenVector &residual) override
Compute this Kernel's contribution to the residual at the current quadrature point,...
virtual RealEigenVector computeQpJacobian() override
Compute this Kernel's contribution to the diagonal Jacobian at the current quadrature point.
ArrayReaction(const InputParameters &parameters)
virtual void initialSetup() override
Gets called at the beginning of the simulation before this object is asked to do its job.
virtual const std::set< SubdomainID > & blockIDs() const
Return the block subdomain ids for this object Note, if this is not block restricted,...
const std::set< SubdomainID > & meshBlockIDs() const
Return all of the SubdomainIDs for the mesh.
virtual bool blockRestricted() const
Returns true if this object has been restricted to a block.
const MaterialWarehouse & getMaterialWarehouse() const
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 _j
current index for the shape function
Definition KernelBase.h:61
unsigned int _i
current index for the test function
Definition KernelBase.h:58
unsigned int number() const
Get variable number coming from libMesh.
unsigned int count() const
Get the number of components Note: For standard and vector variables, the number is one.
This class provides an interface for common operations on field variables of both FE and FV types wit...
FEProblemBase & _fe_problem
Reference to this kernel's FEProblemBase.
void checkArrayMaterialPropertySize(const MooseObject &object, const MaterialWarehouse &warehouse, const std::set< SubdomainID > &blocks, const std::string &param_name, std::size_t count, bool is_matrix)
Check during setup that an array material property used as a coefficient has one entry per component ...