diff --git a/framework/doc/content/source/kernels/ADMatReaction.md b/framework/doc/content/source/kernels/ADMatReaction.md deleted file mode 100644 index 8d6681b55427..000000000000 --- a/framework/doc/content/source/kernels/ADMatReaction.md +++ /dev/null @@ -1,28 +0,0 @@ -# ADMatReaction - -!syntax description /Kernels/ADMatReaction - -Implements -\begin{equation} -(-L(v,a,b,\dots) v, \psi), -\end{equation} -where $L$ ([!param](/Kernels/ADMatReaction/reaction_rate)) is a reaction rate, $v$ is either -a coupled variable ([!param](/Kernels/ADMatReaction/v)) or - if not explicitly specified - -the non-linear variable the kernel is operating on. - -Forward automatic differentiation is used to compute all on and off-diagonal -Jacobian contributions. - -!alert warning -Note the negative sign, which does *not* appear in [Reaction](/Reaction.md) or -[CoefReaction](/CoefReaction.md). - -## Example Input File Syntax - -!listing ad_mat_reaction.i block=Kernels/reaction - -!syntax parameters /Kernels/ADMatReaction - -!syntax inputs /Kernels/ADMatReaction - -!syntax children /Kernels/ADMatReaction diff --git a/framework/doc/content/source/kernels/ADMatReaction.md b/framework/doc/content/source/kernels/ADMatReaction.md new file mode 120000 index 000000000000..6454c72ac858 --- /dev/null +++ b/framework/doc/content/source/kernels/ADMatReaction.md @@ -0,0 +1 @@ +MatReaction.md \ No newline at end of file diff --git a/framework/include/kernels/ADMatReaction.h b/framework/include/kernels/ADMatReaction.h index d61fadb3112a..06ac62579689 100644 --- a/framework/include/kernels/ADMatReaction.h +++ b/framework/include/kernels/ADMatReaction.h @@ -9,32 +9,4 @@ #pragma once -#include "ADKernel.h" - -/** - * Kernel representing the contribution of the PDE term $-L*v$, where $L$ is a - * reaction rate coefficient material property, $v$ is a scalar variable (nonlinear or coupled - * auxvariable), and whose Jacobian contribution is calculated using automatic differentiation. - */ -class ADMatReaction : public ADKernel -{ -public: - static InputParameters validParams(); - - ADMatReaction(const InputParameters & parameters); - -protected: - virtual ADReal computeQpResidual() override; - -private: - /** - * Kernel variable (can be nonlinear or coupled variable) - * (For constrained Allen-Cahn problems such as those in - * phase field, v = lambda where lambda is the Lagrange - * multiplier) - */ - const ADVariableValue & _v; - - /// Reaction rate material property - const ADMaterialProperty & _reaction_rate; -}; +#include "MatReaction.h" diff --git a/framework/include/kernels/CoefReaction.h b/framework/include/kernels/CoefReaction.h index e672e9c1ca19..d6248f90a974 100644 --- a/framework/include/kernels/CoefReaction.h +++ b/framework/include/kernels/CoefReaction.h @@ -21,10 +21,17 @@ class CoefReactionTempl : public ReactionTempl protected: virtual GenericReal computeQpResidual() override; - virtual Real computeQpJacobian() override; + Real computeQpJacobian() override; /// input parameter multiplied by the reaction kernel const Real _coef; + + using ReactionTempl::_test; + using ReactionTempl::_i; + using ReactionTempl::_qp; + using ReactionTempl::_rate; + using ReactionTempl::_phi; + using ReactionTempl::_j; }; typedef CoefReactionTempl CoefReaction; diff --git a/framework/include/kernels/MatReaction.h b/framework/include/kernels/MatReaction.h index 65d7fe2cec58..1adef1b5868f 100644 --- a/framework/include/kernels/MatReaction.h +++ b/framework/include/kernels/MatReaction.h @@ -9,26 +9,49 @@ #pragma once -#include "Kernel.h" +#include "GenericKernel.h" #include "JvarMapInterface.h" #include "DerivativeMaterialInterface.h" -// Forward Declaration - /** * This kernel adds to the residual a contribution of \f$ -L*v \f$ where \f$ L \f$ is a material * property and \f$ v \f$ is a variable (nonlinear or coupled). */ -class MatReaction : public DerivativeMaterialInterface> +template +class MatReactionTempl : public GenericKernel +{ +public: + static InputParameters validParams(); + + MatReactionTempl(const InputParameters & parameters); + +protected: + virtual GenericReal computeQpResidual(); + + /// Reaction rate + const GenericMaterialProperty & _rate; + + /** + * Kernel variable (can be nonlinear or coupled variable) + * (For constrained Allen-Cahn problems, v = lambda + * where lambda is the Lagrange multiplier) + */ + const GenericVariableValue & _v; + + usingGenericKernelMembers; +}; + +class MatReaction + : public DerivativeMaterialInterface>> { public: static InputParameters validParams(); MatReaction(const InputParameters & parameters); + virtual void initialSetup(); protected: - virtual Real computeQpResidual(); virtual Real computeQpJacobian(); virtual Real computeQpOffDiagJacobian(unsigned int jvar); @@ -40,23 +63,17 @@ class MatReaction : public DerivativeMaterialInterface & _L; - - /// name of the order parameter (needed to retrieve the derivative material properties) - VariableName _eta_name; - - /// Reaction rate derivative w.r.t. order parameter - const MaterialProperty & _dLdop; + /// Reaction rate derivative w.r.t. primal variable + const MaterialProperty & _drate_du; /// Reaction rate derivative w.r.t. the variable being added by this kernel - const MaterialProperty & _dLdv; + const MaterialProperty & _drate_dv; /// Reaction rate derivatives w.r.t. other coupled variables - std::vector *> _dLdarg; + std::vector *> _drate_darg; }; + +typedef MatReactionTempl ADMatReaction; diff --git a/framework/src/kernels/ADMatReaction.C b/framework/src/kernels/ADMatReaction.C deleted file mode 100644 index 746c0b03bb41..000000000000 --- a/framework/src/kernels/ADMatReaction.C +++ /dev/null @@ -1,41 +0,0 @@ -//* This file is part of the MOOSE framework -//* https://mooseframework.inl.gov -//* -//* All rights reserved, see COPYRIGHT for full restrictions -//* https://github.com/idaholab/moose/blob/master/COPYRIGHT -//* -//* Licensed under LGPL 2.1, please see LICENSE for details -//* https://www.gnu.org/licenses/lgpl-2.1.html - -#include "ADMatReaction.h" - -registerMooseObject("MooseApp", ADMatReaction); - -InputParameters -ADMatReaction::validParams() -{ - InputParameters params = ADKernel::validParams(); - params.addClassDescription( - "Kernel representing the contribution of the PDE term $-L*v$, where $L$ is a reaction rate " - "material property, $v$ is a scalar variable (nonlinear or coupled), and whose Jacobian " - "contribution is calculated using automatic differentiation."); - params.addCoupledVar("v", - "Set this to make v a coupled variable, otherwise it will use the " - "kernel's nonlinear variable for v"); - params.addRequiredParam("reaction_rate", - "The reaction_rate used with the kernel."); - return params; -} - -ADMatReaction::ADMatReaction(const InputParameters & parameters) - : ADKernel(parameters), - _v(isCoupled("v") ? adCoupledValue("v") : _u), - _reaction_rate(getADMaterialProperty("reaction_rate")) -{ -} - -ADReal -ADMatReaction::computeQpResidual() -{ - return -_reaction_rate[_qp] * _test[_i][_qp] * _v[_qp]; -} diff --git a/framework/src/kernels/CoefReaction.C b/framework/src/kernels/CoefReaction.C index ea77024ab5c4..21f2227f1fe3 100644 --- a/framework/src/kernels/CoefReaction.C +++ b/framework/src/kernels/CoefReaction.C @@ -9,8 +9,8 @@ #include "CoefReaction.h" -registerMooseObject("MooseApp", CoefReaction); -registerMooseObject("MooseApp", ADCoefReaction); +registerMooseObjectReplaced("MooseApp", CoefReaction, "01/01/2027 00:00", Reaction); +registerMooseObjectReplaced("MooseApp", ADCoefReaction, "01/21/2027 00:00", ADReaction); template InputParameters @@ -39,13 +39,7 @@ template Real CoefReactionTempl::computeQpJacobian() { - // This function will never be called for the AD version. But because C++ does - // not support an optional function declaration based on a template parameter, - // we must keep this template for all cases. - mooseAssert(!is_ad, - "In ADCoefReaction, computeQpJacobian should not be called. Check computeJacobian " - "implementation."); - return _coef * ReactionTempl::computeQpJacobian(); + return _coef * _test[_i][_qp] * _rate * _phi[_j][_qp]; } template class CoefReactionTempl; diff --git a/framework/src/kernels/MatReaction.C b/framework/src/kernels/MatReaction.C index 51a3e780445f..eb005f03a464 100644 --- a/framework/src/kernels/MatReaction.C +++ b/framework/src/kernels/MatReaction.C @@ -10,37 +10,59 @@ #include "MatReaction.h" registerMooseObject("MooseApp", MatReaction); +registerMooseObject("MooseApp", ADMatReaction); +template InputParameters -MatReaction::validParams() +MatReactionTempl::validParams() { - InputParameters params = Kernel::validParams(); + InputParameters params = GenericKernel::validParams(); + params.addClassDescription("Kernel to add -L*v, where L=reaction rate, v=variable"); params.addCoupledVar("v", "Set this to make v a coupled variable, otherwise it will use the " "kernel's nonlinear variable for v"); - params.addClassDescription("Kernel to add -L*v, where L=reaction rate, v=variable"); - params.addRequiredParam("mob_name", + params.addRequiredParam("reaction_rate", "The reaction rate used with the kernel"); - params.deprecateParam("mob_name", "reaction_rate", "01/01/2025"); + return params; +} + +template +MatReactionTempl::MatReactionTempl(const InputParameters & parameters) + : GenericKernel(parameters), + _rate(this->template getGenericMaterialProperty("reaction_rate")), + _v(this->isCoupled("v") ? this->template coupledGenericValue("v") : this->_u) +{ + if (this->isCoupled("v") && coupled("v") == _var.number()) + paramError("v", "In order to correctly couple the primal variable, leave 'v' blank"); +} + +template +GenericReal +MatReactionTempl::computeQpResidual() +{ + return -_rate[_qp] * _v[_qp] * _test[_i][_qp]; +} + +InputParameters +MatReaction::validParams() +{ + InputParameters params = MatReactionTempl::validParams(); params.addCoupledVar("args", "Vector of nonlinear variable arguments this object depends on"); return params; } MatReaction::MatReaction(const InputParameters & parameters) - : DerivativeMaterialInterface>(parameters), + : DerivativeMaterialInterface>>(parameters), _is_coupled(isCoupled("v")), _v_name(_is_coupled ? coupledName("v") : _var.name()), - _v(_is_coupled ? coupledValue("v") : _u), _v_var(_is_coupled ? coupled("v") : _var.number()), - _L(getMaterialProperty("reaction_rate")), - _eta_name(_var.name()), - _dLdop(getMaterialPropertyDerivative("reaction_rate", _eta_name)), - _dLdv(getMaterialPropertyDerivative("reaction_rate", _v_name)), - _dLdarg(_n_args) + _drate_du(getMaterialPropertyDerivative("reaction_rate", _var.name())), + _drate_dv(getMaterialPropertyDerivative("reaction_rate", _v_name)), + _drate_darg(_n_args) { // Get reaction rate derivatives for (unsigned int i = 0; i < _n_args; ++i) - _dLdarg[i] = &getMaterialPropertyDerivative("reaction_rate", i); + _drate_darg[i] = &getMaterialPropertyDerivative("reaction_rate", i); } void @@ -49,19 +71,13 @@ MatReaction::initialSetup() validateNonlinearCoupling("reaction_rate"); } -Real -MatReaction::computeQpResidual() -{ - return -_L[_qp] * _test[_i][_qp] * _v[_qp]; -} - Real MatReaction::computeQpJacobian() { if (_is_coupled) - return -_dLdop[_qp] * _v[_qp] * _phi[_j][_qp] * _test[_i][_qp]; + return -_drate_du[_qp] * _v[_qp] * _phi[_j][_qp] * _test[_i][_qp]; - return -(_L[_qp] + _dLdop[_qp] * _v[_qp]) * _phi[_j][_qp] * _test[_i][_qp]; + return -(_rate[_qp] + _drate_du[_qp] * _v[_qp]) * _phi[_j][_qp] * _test[_i][_qp]; } Real @@ -70,11 +86,14 @@ MatReaction::computeQpOffDiagJacobian(unsigned int jvar) // first handle the case where jvar is a coupled variable v being added to residual // the first term in the sum just multiplies by L which is always needed // the second term accounts for cases where L depends on v - if ((jvar == _v_var) && _is_coupled) - return -(_L[_qp] + _dLdv[_qp] * _v[_qp]) * _test[_i][_qp] * _phi[_j][_qp]; + if (jvar == _v_var && _is_coupled) + return -(_rate[_qp] + _drate_dv[_qp] * _v[_qp]) * _test[_i][_qp] * _phi[_j][_qp]; // for all other vars get the coupled variable jvar is referring to - const unsigned int cvar = mapJvarToCvar(jvar); + const auto cvar = mapJvarToCvar(jvar); - return -(*_dLdarg[cvar])[_qp] * _v[_qp] * _test[_i][_qp] * _phi[_j][_qp]; + return -(*_drate_darg[cvar])[_qp] * _v[_qp] * _test[_i][_qp] * _phi[_j][_qp]; } + +template class MatReactionTempl; +template class MatReactionTempl; diff --git a/framework/src/kernels/Reaction.C b/framework/src/kernels/Reaction.C index 827e751ba845..b5e61386d517 100644 --- a/framework/src/kernels/Reaction.C +++ b/framework/src/kernels/Reaction.C @@ -42,12 +42,6 @@ template Real ReactionTempl::computeQpJacobian() { - // This function will never be called for the AD version. But because C++ does - // not support an optional function declaration based on a template parameter, - // we must keep this template for all cases. - mooseAssert(!is_ad, - "In ADReaction, computeQpJacobian should not be called. Check computeJacobian " - "implementation."); return _test[_i][_qp] * _rate * _phi[_j][_qp]; } diff --git a/modules/phase_field/src/actions/GrandPotentialKernelAction.C b/modules/phase_field/src/actions/GrandPotentialKernelAction.C index 37c4b6ae6e5e..25901928b020 100644 --- a/modules/phase_field/src/actions/GrandPotentialKernelAction.C +++ b/modules/phase_field/src/actions/GrandPotentialKernelAction.C @@ -320,7 +320,7 @@ GrandPotentialKernelAction::act() InputParameters params = _factory.getValidParams("MatReaction"); params.set("variable") = w_names[i]; params.set>("v") = v4; - params.set("mob_name") = "-1"; + params.set("reaction_rate") = "-1"; kernel_name = "MR_c" + w_names[i]; _problem->addKernel("MatReaction", kernel_name, params); @@ -333,7 +333,7 @@ GrandPotentialKernelAction::act() params = _factory.getValidParams("MatReaction"); params.set("variable") = w_names[i]; params.set>("args") = v1; - params.set("mob_name") = hj_over_kVa[j]; + params.set("reaction_rate") = hj_over_kVa[j]; params.set("implicit") = implicity; params.set("use_displaced_mesh") = displaced_mesh; kernel_name = "MR_" + w_names[i] + "_" + all_etas[j]; diff --git a/modules/stochastic_tools/test/src/kernels/MaterialReaction.C b/modules/stochastic_tools/test/src/kernels/MaterialReaction.C index 5c684145e0fa..e65e36080123 100644 --- a/modules/stochastic_tools/test/src/kernels/MaterialReaction.C +++ b/modules/stochastic_tools/test/src/kernels/MaterialReaction.C @@ -13,6 +13,8 @@ registerMooseObject("StochasticToolsTestApp", MaterialReaction); +registerMooseObjectReplaced("StochasticToolsTestApp", MaterialReaction, "01/01/2027 00:00", Matreaction); + InputParameters MaterialReaction::validParams() { diff --git a/test/tests/kernels/ad_mat_reaction/tests b/test/tests/kernels/ad_mat_reaction/tests deleted file mode 100644 index 73b794a556a4..000000000000 --- a/test/tests/kernels/ad_mat_reaction/tests +++ /dev/null @@ -1,16 +0,0 @@ -[Tests] - issues = '#13484 #13744' - design = 'ADMatReaction.md' - [./ad_mat_reaction] - type = 'Exodiff' - input = 'ad_mat_reaction.i' - exodiff = 'ad_mat_reaction_out.e' - requirement = 'The system shall provide an ability to solve a steady-state diffusion-reaction problem, where the reaction term has a material property reaction rate.' - [../] - [./ad_mat_reaction_jac] - type = 'PetscJacobianTester' - input = 'ad_mat_reaction.i' - difference_tol = 1e-7 - requirement = 'The system shall calculate the correct Jacobian of ADMatReaction using automatic differentiation.' - [../] -[] diff --git a/test/tests/kernels/ad_reaction/ad_reaction.i b/test/tests/kernels/ad_reaction/ad_reaction.i deleted file mode 100644 index 3fc3db626478..000000000000 --- a/test/tests/kernels/ad_reaction/ad_reaction.i +++ /dev/null @@ -1,46 +0,0 @@ -[Mesh] - type = GeneratedMesh - dim = 2 - nx = 5 - ny = 5 -[] - -[Variables] - [u] - [] -[] - -[Kernels] - [diffusion] - type = ADDiffusion - variable = u - [] - - [reaction] - type = ADReaction - variable = u - [] - - [force] - type = ADBodyForce - variable = u - [] -[] - -[BCs] - [left] - type = ADDirichletBC - boundary = left - variable = u - value = 0 - [] -[] - -[Executioner] - type = Steady - solve_type = NEWTON -[] - -[Outputs] - exodus = true -[] diff --git a/test/tests/kernels/ad_reaction/gold/ad_coef_reaction_out.e b/test/tests/kernels/ad_reaction/gold/ad_coef_reaction_out.e deleted file mode 100644 index a18604d38c04..000000000000 Binary files a/test/tests/kernels/ad_reaction/gold/ad_coef_reaction_out.e and /dev/null differ diff --git a/test/tests/kernels/ad_reaction/gold/ad_reaction_out.e b/test/tests/kernels/ad_reaction/gold/ad_reaction_out.e deleted file mode 100644 index 229d47ebb4bb..000000000000 Binary files a/test/tests/kernels/ad_reaction/gold/ad_reaction_out.e and /dev/null differ diff --git a/test/tests/kernels/ad_reaction/tests b/test/tests/kernels/ad_reaction/tests deleted file mode 100644 index 21c9d195c626..000000000000 --- a/test/tests/kernels/ad_reaction/tests +++ /dev/null @@ -1,35 +0,0 @@ -[Tests] - [ad_reaction] - type = 'Exodiff' - input = 'ad_reaction.i' - exodiff = 'ad_reaction_out.e' - requirement = 'The system shall contain a consuming reaction term object whose Jacobian is calculated via forward automatic differentiation.' - design = 'Reaction.md' - issues = '#21009' - [] - [ad_reaction_jac] - type = PetscJacobianTester - input = 'ad_reaction.i' - requirement = 'The system shall produce a perfect Jacobian for a consuming reaction term object using forward automatic differentiation.' - design = 'Reaction.md' - issues = '#21009' - [] - - [ad_coef_reaction] - type = 'Exodiff' - input = 'ad_reaction.i' - cli_args = 'Kernels/reaction/type=ADCoefReaction Kernels/reaction/coefficient=2 Outputs/file_base=ad_coef_reaction_out' - exodiff = 'ad_coef_reaction_out.e' - requirement = 'The system shall contain a consuming reaction term object with a scalar coefficient whose Jacobian is calculated via forward automatic differentiation.' - design = 'CoefReaction.md' - issues = '#21009' - [] - [ad_coef_reaction_jac] - type = PetscJacobianTester - input = 'ad_reaction.i' - cli_args = 'Kernels/reaction/type=ADCoefReaction Kernels/reaction/coefficient=2' - requirement = 'The system shall produce a perfect Jacobian for a consuming reaction term object with a scalar coefficient using forward automatic differentiation.' - design = 'CoefReaction.md' - issues = '#21009' - [] -[] diff --git a/test/tests/kernels/mat_reaction/gold/ADmat_reaction_out.e b/test/tests/kernels/mat_reaction/gold/ADmat_reaction_out.e new file mode 120000 index 000000000000..af935fd7a456 --- /dev/null +++ b/test/tests/kernels/mat_reaction/gold/ADmat_reaction_out.e @@ -0,0 +1 @@ +mat_reaction_out.e \ No newline at end of file diff --git a/test/tests/kernels/ad_mat_reaction/gold/ad_mat_reaction_out.e b/test/tests/kernels/mat_reaction/gold/mat_reaction_out.e similarity index 100% rename from test/tests/kernels/ad_mat_reaction/gold/ad_mat_reaction_out.e rename to test/tests/kernels/mat_reaction/gold/mat_reaction_out.e diff --git a/test/tests/kernels/ad_mat_reaction/ad_mat_reaction.i b/test/tests/kernels/mat_reaction/mat_reaction.i similarity index 76% rename from test/tests/kernels/ad_mat_reaction/ad_mat_reaction.i rename to test/tests/kernels/mat_reaction/mat_reaction.i index df81f42c5ba3..b900f2cb6966 100644 --- a/test/tests/kernels/ad_mat_reaction/ad_mat_reaction.i +++ b/test/tests/kernels/mat_reaction/mat_reaction.i @@ -1,3 +1,5 @@ +AD = '' + [Mesh] [square] type = GeneratedMeshGenerator @@ -13,14 +15,12 @@ [Variables] [u] - order = FIRST - family = LAGRANGE [] [] [Materials] [ad_prop] - type = ADParsedMaterial + type = ${AD}ParsedMaterial expression = '-log(3)*log(3)' property_name = rxn_prop [] @@ -28,11 +28,11 @@ [Kernels] [diff] - type = ADDiffusion + type = ${AD}Diffusion variable = u [] [reaction] - type = ADMatReaction + type = ${AD}MatReaction variable = u reaction_rate = rxn_prop [] @@ -40,13 +40,13 @@ [BCs] [left] - type = DirichletBC + type = ${AD}DirichletBC variable = u boundary = left value = 1 [] [right] - type = DirichletBC + type = ${AD}DirichletBC variable = u boundary = right value = 3 @@ -60,4 +60,5 @@ [Outputs] exodus = true + file_base = ${AD}mat_reaction_out [] diff --git a/test/tests/kernels/mat_reaction/tests b/test/tests/kernels/mat_reaction/tests new file mode 100644 index 000000000000..7e672839339d --- /dev/null +++ b/test/tests/kernels/mat_reaction/tests @@ -0,0 +1,33 @@ +[Tests] + issues = '#13484 #13744' + [mat_reaction] + type = 'Exodiff' + input = 'mat_reaction.i' + exodiff = 'mat_reaction_out.e' + design = 'MatReaction.md' + requirement = 'The system shall provide an ability to solve a steady-state diffusion-reaction problem, where the reaction term has a material property reaction rate.' + [] + [mat_reaction_jac] + type = 'PetscJacobianTester' + input = 'mat_reaction.i' + difference_tol = 1e-7 + design = 'MatReaction.md' + requirement = 'The system shall calculate the correct Jacobian of MatReaction.' + [../] + [ad_mat_reaction] + type = 'Exodiff' + input = 'mat_reaction.i' + exodiff = 'ADmat_reaction_out.e' + cli_args = 'AD=AD' + design = 'ADMatReaction.md' + requirement = 'The system shall provide an ability to solve a steady-state diffusion-reaction problem, where the reaction term has a material property reaction rate, using automatic differentiation.' + [] + [ad_mat_reaction_jac] + type = 'PetscJacobianTester' + input = 'mat_reaction.i' + difference_tol = 1e-7 + cli_args = 'AD=AD' + design = 'ADMatReaction.md' + requirement = 'The system shall calculate the correct Jacobian of ADMatReaction using automatic differentiation.' + [../] +[] diff --git a/test/tests/kernels/reaction/exact.i b/test/tests/kernels/reaction/exact.i new file mode 100644 index 000000000000..eacc160f24cf --- /dev/null +++ b/test/tests/kernels/reaction/exact.i @@ -0,0 +1,51 @@ +AD = '' + +ic = 5 +rate = 1e-4 + +[Mesh] + type = GeneratedMesh + dim = 1 +[] + +[Variables] + [u] + initial_condition = ${ic} + [] +[] + +[Kernels] + [reaction] + type = ${AD}Reaction + variable = u + rate = ${rate} + [] + + [force] + type = ${AD}TimeDerivative + variable = u + [] +[] + +[Executioner] + type = Transient + solve_type = NEWTON + num_steps = 10 +[] + +[Postprocessors] + [u_avg] + type = ElementAverageValue + variable = u + [] + [u_exact] + type = ParsedPostprocessor + expression = '${ic} * exp(-${rate} * t)' + use_t = true + [] +[] + +[Outputs] + csv = true + file_base = '${AD}exact_out' +[] diff --git a/test/tests/kernels/reaction/gold/ADexact_out.csv b/test/tests/kernels/reaction/gold/ADexact_out.csv new file mode 120000 index 000000000000..b729afd9452b --- /dev/null +++ b/test/tests/kernels/reaction/gold/ADexact_out.csv @@ -0,0 +1 @@ +exact_out.csv \ No newline at end of file diff --git a/test/tests/kernels/reaction/gold/exact_out.csv b/test/tests/kernels/reaction/gold/exact_out.csv new file mode 100644 index 000000000000..81e669c84b84 --- /dev/null +++ b/test/tests/kernels/reaction/gold/exact_out.csv @@ -0,0 +1,12 @@ +time,u_avg,u_exact +0,0,0 +1,4.999500049995,4.9995000249992 +2,4.99900014998,4.9990000999933 +3,4.99850029995,4.9985002249775 +4,4.9980004999,4.9980003999467 +5,4.997500749825,4.9975006248958 +6,4.9970010497201,4.99700089982 +7,4.9965013995801,4.9965012247142 +8,4.9960017994002,4.9960015995734 +9,4.9955022491752,4.9955020243926 +10,4.9950027489004,4.9950024991669 diff --git a/test/tests/kernels/reaction/tests b/test/tests/kernels/reaction/tests new file mode 100644 index 000000000000..80ab85070f3c --- /dev/null +++ b/test/tests/kernels/reaction/tests @@ -0,0 +1,27 @@ +[Tests] + [exact] + type = 'CSVDiff' + input = 'exact.i' + csvdiff = 'exact_out.csv' + requirement = 'The system shall contain a consuming reaction term object.' + design = 'Reaction.md' + issues = '#21009' + [] + [ad_exact] + type = 'CSVDiff' + input = 'exact.i' + csvdiff = 'ADexact_out.csv' + cli_args = 'AD=AD' + requirement = 'The system shall contain a consuming reaction term object whose Jacobian is calculated via forward automatic differentiation.' + design = 'Reaction.md' + issues = '#21009' + [] + [ad_exact_jac] + type = PetscJacobianTester + input = 'exact.i' + cli_args = 'AD=AD' + requirement = 'The system shall produce a perfect Jacobian for a consuming reaction term object using forward automatic differentiation.' + design = 'Reaction.md' + issues = '#21009' + [] +[]