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 "ADDGAdvection.h" 11 : 12 : registerMooseObject("MooseApp", ADDGAdvection); 13 : 14 : InputParameters 15 14311 : ADDGAdvection::validParams() 16 : { 17 14311 : InputParameters params = ADDGKernel::validParams(); 18 14311 : params.addRequiredParam<MaterialPropertyName>("velocity", "Velocity vector"); 19 14311 : params.addClassDescription( 20 : "Adds internal face advection flux contributions for discontinuous Galerkin discretizations"); 21 14311 : params.addParam<MaterialPropertyName>("advected_quantity", 22 : "An optional material property to be advected. If not " 23 : "supplied, then the variable will be used."); 24 14311 : return params; 25 0 : } 26 : 27 24 : ADDGAdvection::ADDGAdvection(const InputParameters & parameters) 28 : : ADDGKernel(parameters), 29 24 : _velocity(getADMaterialProperty<RealVectorValue>("velocity")), 30 24 : _velocity_neighbor(getNeighborADMaterialProperty<RealVectorValue>("velocity")), 31 48 : _adv_quant_elem(isParamValid("advected_quantity") 32 24 : ? getADMaterialProperty<Real>("advected_quantity").get() 33 : : _u), 34 48 : _adv_quant_neighbor(isParamValid("advected_quantity") 35 24 : ? getNeighborADMaterialProperty<Real>("advected_quantity").get() 36 24 : : _u_neighbor) 37 : { 38 24 : } 39 : 40 : ADReal 41 157892 : ADDGAdvection::computeQpResidual(Moose::DGResidualType type) 42 : { 43 157892 : ADReal r = 0; 44 : 45 157892 : auto average = [](const auto & elem_value, const auto & neighbor_value) 46 157892 : { return (elem_value + neighbor_value) / 2; }; 47 : 48 157892 : const auto vdotn = average(_velocity[_qp], _velocity_neighbor[_qp]) * _normals[_qp]; 49 : 50 0 : const auto face_u = [&]() 51 : { 52 157892 : if (vdotn >= 0) 53 157892 : return _adv_quant_elem[_qp]; 54 : else 55 0 : return _adv_quant_neighbor[_qp]; 56 157892 : }(); 57 : 58 157892 : switch (type) 59 : { 60 78946 : case Moose::Element: 61 78946 : r += vdotn * face_u * _test[_i][_qp]; 62 78946 : break; 63 : 64 78946 : case Moose::Neighbor: 65 78946 : r -= vdotn * face_u * _test_neighbor[_i][_qp]; 66 78946 : break; 67 : } 68 : 69 315784 : return r; 70 157892 : }