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 "InterfaceReaction.h" 11 : 12 : registerMooseObject("MooseApp", InterfaceReaction); 13 : 14 : InputParameters 15 14386 : InterfaceReaction::validParams() 16 : { 17 14386 : InputParameters params = InterfaceKernel::validParams(); 18 14386 : params.addRequiredParam<Real>("kf", "Forward reaction rate coefficient."); 19 14386 : params.addRequiredParam<Real>("kb", "Backward reaction rate coefficient."); 20 14386 : params.addClassDescription("Implements a reaction to establish ReactionRate=k_f*u-k_b*v " 21 : "at interface."); 22 14386 : return params; 23 0 : } 24 : 25 63 : InterfaceReaction::InterfaceReaction(const InputParameters & parameters) 26 63 : : InterfaceKernel(parameters), _kf(getParam<Real>("kf")), _kb(getParam<Real>("kb")) 27 : { 28 63 : } 29 : 30 : Real 31 7632 : InterfaceReaction::computeQpResidual(Moose::DGResidualType type) 32 : { 33 7632 : Real r = 0; 34 7632 : switch (type) 35 : { 36 : // Move all the terms to the LHS to get residual, for primary domain 37 : // Residual = kf*u - kb*v = kf*u - kb*v 38 : // Weak form for primary domain is: (test, kf*u - kb*v) 39 3816 : case Moose::Element: 40 3816 : r = _test[_i][_qp] * (_kf * _u[_qp] - _kb * _neighbor_value[_qp]); 41 3816 : break; 42 : 43 : // Similarly, weak form for secondary domain is: -(test, kf*u - kb*v), 44 : // flip the sign because the direction is opposite. 45 3816 : case Moose::Neighbor: 46 3816 : r = -_test_neighbor[_i][_qp] * (_kf * _u[_qp] - _kb * _neighbor_value[_qp]); 47 3816 : break; 48 : } 49 7632 : return r; 50 : } 51 : 52 : Real 53 30544 : InterfaceReaction::computeQpJacobian(Moose::DGJacobianType type) 54 : { 55 30544 : Real jac = 0; 56 30544 : switch (type) 57 : { 58 7636 : case Moose::ElementElement: 59 7636 : jac = _test[_i][_qp] * _kf * _phi[_j][_qp]; 60 7636 : break; 61 7636 : case Moose::NeighborNeighbor: 62 7636 : jac = -_test_neighbor[_i][_qp] * -_kb * _phi_neighbor[_j][_qp]; 63 7636 : break; 64 7636 : case Moose::NeighborElement: 65 7636 : jac = -_test_neighbor[_i][_qp] * _kf * _phi[_j][_qp]; 66 7636 : break; 67 7636 : case Moose::ElementNeighbor: 68 7636 : jac = _test[_i][_qp] * -_kb * _phi_neighbor[_j][_qp]; 69 7636 : break; 70 : } 71 30544 : return jac; 72 : }