LCOV - code coverage report
Current view: top level - src/dgkernels - DGConvection.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 419b9d Lines: 44 45 97.8 %
Date: 2025-08-08 20:01:16 Functions: 4 4 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 "DGConvection.h"
      11             : 
      12             : registerMooseObject("MooseApp", DGConvection);
      13             : 
      14             : InputParameters
      15       14392 : DGConvection::validParams()
      16             : {
      17       14392 :   InputParameters params = DGKernel::validParams();
      18       14392 :   params.addRequiredParam<RealVectorValue>("velocity", "Velocity vector");
      19       14392 :   params.addClassDescription("DG upwinding for the convection");
      20       14392 :   return params;
      21           0 : }
      22             : 
      23          66 : DGConvection::DGConvection(const InputParameters & parameters)
      24          66 :   : DGKernel(parameters), _velocity(getParam<RealVectorValue>("velocity"))
      25             : {
      26          66 : }
      27             : 
      28             : Real
      29       37536 : DGConvection::computeQpResidual(Moose::DGResidualType type)
      30             : {
      31       37536 :   Real r = 0;
      32             : 
      33       37536 :   Real vdotn = _velocity * _normals[_qp];
      34             : 
      35       37536 :   switch (type)
      36             :   {
      37       18768 :     case Moose::Element:
      38       18768 :       if (vdotn >= 0)
      39       18712 :         r += vdotn * _u[_qp] * _test[_i][_qp];
      40             :       else
      41          56 :         r += vdotn * _u_neighbor[_qp] * _test[_i][_qp];
      42       18768 :       break;
      43             : 
      44       18768 :     case Moose::Neighbor:
      45       18768 :       if (vdotn >= 0)
      46       18712 :         r -= vdotn * _u[_qp] * _test_neighbor[_i][_qp];
      47             :       else
      48          56 :         r -= vdotn * _u_neighbor[_qp] * _test_neighbor[_i][_qp];
      49       18768 :       break;
      50             :   }
      51             : 
      52       37536 :   return r;
      53             : }
      54             : 
      55             : Real
      56       32416 : DGConvection::computeQpJacobian(Moose::DGJacobianType type)
      57             : {
      58       32416 :   Real r = 0;
      59             : 
      60       32416 :   Real vdotn = _velocity * _normals[_qp];
      61             : 
      62       32416 :   switch (type)
      63             :   {
      64        8104 :     case Moose::ElementElement:
      65        8104 :       if (vdotn >= 0)
      66        8072 :         r += vdotn * _phi[_j][_qp] * _test[_i][_qp];
      67        8104 :       break;
      68             : 
      69        8104 :     case Moose::ElementNeighbor:
      70        8104 :       if (vdotn < 0)
      71          32 :         r += vdotn * _phi_neighbor[_j][_qp] * _test[_i][_qp];
      72        8104 :       break;
      73             : 
      74        8104 :     case Moose::NeighborElement:
      75        8104 :       if (vdotn >= 0)
      76        8072 :         r -= vdotn * _phi[_j][_qp] * _test_neighbor[_i][_qp];
      77        8104 :       break;
      78             : 
      79        8104 :     case Moose::NeighborNeighbor:
      80        8104 :       if (vdotn < 0)
      81          32 :         r -= vdotn * _phi_neighbor[_j][_qp] * _test_neighbor[_i][_qp];
      82        8104 :       break;
      83             :   }
      84             : 
      85       32416 :   return r;
      86             : }

Generated by: LCOV version 1.14