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