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 "AEFVKernel.h" 11 : 12 : registerMooseObject("RdgApp", AEFVKernel); 13 : 14 : InputParameters 15 116 : AEFVKernel::validParams() 16 : { 17 116 : InputParameters params = DGKernel::validParams(); 18 116 : params.addClassDescription( 19 : "A dgkernel for the advection equation using a cell-centered finite volume method."); 20 232 : MooseEnum component("concentration"); 21 232 : params.addParam<MooseEnum>("component", component, "Choose one of the equations"); 22 232 : params.addRequiredCoupledVar("u", "Name of the variable to use"); 23 232 : params.addRequiredParam<UserObjectName>("flux", "Name of the internal side flux object to use"); 24 116 : return params; 25 116 : } 26 : 27 67 : AEFVKernel::AEFVKernel(const InputParameters & parameters) 28 : : DGKernel(parameters), 29 67 : _component(getParam<MooseEnum>("component")), 30 67 : _uc1(coupledValue("u")), 31 67 : _uc2(coupledNeighborValue("u")), 32 134 : _u1(getMaterialProperty<Real>("u")), 33 134 : _u2(getNeighborMaterialProperty<Real>("u")), 34 134 : _flux(getUserObject<InternalSideFluxBase>("flux")) 35 : { 36 67 : } 37 : 38 134 : AEFVKernel::~AEFVKernel() {} 39 : 40 : Real 41 89852 : AEFVKernel::computeQpResidual(Moose::DGResidualType type) 42 : { 43 : // assemble the input vectors, which are 44 : // the reconstructed linear monomial 45 : // extrapolated at side center from the current and neighbor elements 46 89852 : std::vector<Real> uvec1 = {_u1[_qp]}; 47 89852 : std::vector<Real> uvec2 = {_u2[_qp]}; 48 : 49 : // calculate the flux 50 179704 : const auto & flux = _flux.getFlux( 51 89852 : _current_side, _current_elem->id(), _neighbor_elem->id(), uvec1, uvec2, _normals[_qp]); 52 : 53 : // distribute the contribution to the current and neighbor elements 54 89852 : switch (type) 55 : { 56 44926 : case Moose::Element: 57 44926 : return flux[_component] * _test[_i][_qp]; 58 : 59 44926 : case Moose::Neighbor: 60 44926 : return -flux[_component] * _test_neighbor[_i][_qp]; 61 : } 62 : 63 : return 0.0; 64 89852 : } 65 : 66 : Real 67 24156 : AEFVKernel::computeQpJacobian(Moose::DGJacobianType type) 68 : { 69 : // assemble the input vectors, which are 70 : // the constant monomial from the current and neighbor elements 71 24156 : std::vector<Real> uvec1 = {_uc1[_qp]}; 72 24156 : std::vector<Real> uvec2 = {_uc2[_qp]}; 73 : 74 : // calculate the Jacobian matrices 75 48312 : const auto & fjac1 = _flux.getJacobian(Moose::Element, 76 24156 : _current_side, 77 24156 : _current_elem->id(), 78 24156 : _neighbor_elem->id(), 79 : uvec1, 80 : uvec2, 81 24156 : _normals[_qp]); 82 : 83 48312 : const auto & fjac2 = _flux.getJacobian(Moose::Neighbor, 84 24156 : _current_side, 85 24156 : _current_elem->id(), 86 24156 : _neighbor_elem->id(), 87 : uvec1, 88 : uvec2, 89 24156 : _normals[_qp]); 90 : 91 : // distribute the contribution to the current and neighbor elements 92 24156 : switch (type) 93 : { 94 6039 : case Moose::ElementElement: 95 6039 : return fjac1(_component, _component) * _phi[_j][_qp] * _test[_i][_qp]; 96 : 97 6039 : case Moose::ElementNeighbor: 98 6039 : return fjac2(_component, _component) * _phi_neighbor[_j][_qp] * _test[_i][_qp]; 99 : 100 6039 : case Moose::NeighborElement: 101 6039 : return -fjac1(_component, _component) * _phi[_j][_qp] * _test_neighbor[_i][_qp]; 102 : 103 6039 : case Moose::NeighborNeighbor: 104 6039 : return -fjac2(_component, _component) * _phi_neighbor[_j][_qp] * _test_neighbor[_i][_qp]; 105 : } 106 : 107 : return 0.0; 108 24156 : }