LCOV - code coverage report
Current view: top level - src/dgkernels - ADDGAdvection.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #32971 (54bef8) with base c6cf66 Lines: 32 35 91.4 %
Date: 2026-05-29 20:35:17 Functions: 6 6 100.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.14