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 14394 : InterfaceReaction::validParams() 16 : { 17 14394 : InputParameters params = InterfaceKernel::validParams(); 18 14394 : params.addRequiredParam<Real>("kf", "Forward reaction rate coefficient."); 19 14394 : params.addRequiredParam<Real>("kb", "Backward reaction rate coefficient."); 20 14394 : params.addClassDescription("Implements a reaction to establish ReactionRate=k_f*u-k_b*v " 21 : "at interface."); 22 14394 : return params; 23 0 : } 24 : 25 67 : InterfaceReaction::InterfaceReaction(const InputParameters & parameters) 26 67 : : InterfaceKernel(parameters), _kf(getParam<Real>("kf")), _kb(getParam<Real>("kb")) 27 : { 28 67 : } 29 : 30 : Real 31 8420 : InterfaceReaction::computeQpResidual(Moose::DGResidualType type) 32 : { 33 8420 : Real r = 0; 34 8420 : 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 4210 : case Moose::Element: 40 4210 : r = _test[_i][_qp] * (_kf * _u[_qp] - _kb * _neighbor_value[_qp]); 41 4210 : 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 4210 : case Moose::Neighbor: 46 4210 : r = -_test_neighbor[_i][_qp] * (_kf * _u[_qp] - _kb * _neighbor_value[_qp]); 47 4210 : break; 48 : } 49 8420 : return r; 50 : } 51 : 52 : Real 53 34336 : InterfaceReaction::computeQpJacobian(Moose::DGJacobianType type) 54 : { 55 34336 : Real jac = 0; 56 34336 : switch (type) 57 : { 58 8584 : case Moose::ElementElement: 59 8584 : jac = _test[_i][_qp] * _kf * _phi[_j][_qp]; 60 8584 : break; 61 8584 : case Moose::NeighborNeighbor: 62 8584 : jac = -_test_neighbor[_i][_qp] * -_kb * _phi_neighbor[_j][_qp]; 63 8584 : break; 64 8584 : case Moose::NeighborElement: 65 8584 : jac = -_test_neighbor[_i][_qp] * _kf * _phi[_j][_qp]; 66 8584 : break; 67 8584 : case Moose::ElementNeighbor: 68 8584 : jac = _test[_i][_qp] * -_kb * _phi_neighbor[_j][_qp]; 69 8584 : break; 70 : } 71 34336 : return jac; 72 : }