LCOV - code coverage report
Current view: top level - src/kernels - DivField.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 419b9d Lines: 18 20 90.0 %
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 "DivField.h"
      11             : #include "Assembly.h"
      12             : 
      13             : registerMooseObject("MooseApp", DivField);
      14             : 
      15             : InputParameters
      16       14589 : DivField::validParams()
      17             : {
      18       14589 :   InputParameters params = Kernel::validParams();
      19       14589 :   params.addClassDescription("The divergence operator optionally scaled by a constant scalar "
      20             :                              "coefficient. Weak form: $(\\psi_i, k \\nabla \\cdot \\vec{u})$.");
      21       14589 :   params.addRequiredCoupledVar("coupled_vector_variable", "The vector field");
      22       14589 :   params.addParam<Real>("coeff", 1.0, "The constant coefficient");
      23       14589 :   return params;
      24           0 : }
      25             : 
      26         168 : DivField::DivField(const InputParameters & parameters)
      27             :   : Kernel(parameters),
      28         168 :     _u_var(*getVectorVar("coupled_vector_variable", 0)),
      29         168 :     _u_var_num(coupled("coupled_vector_variable")),
      30         168 :     _div_u(coupledDiv("coupled_vector_variable")),
      31         168 :     _div_phi(_assembly.divPhi(_u_var)),
      32         336 :     _coeff(getParam<Real>("coeff"))
      33             : {
      34         168 : }
      35             : 
      36             : Real
      37      513216 : DivField::computeQpResidual()
      38             : {
      39      513216 :   return _coeff * _div_u[_qp] * _test[_i][_qp];
      40             : }
      41             : 
      42             : Real
      43     2104704 : DivField::computeQpOffDiagJacobian(unsigned int jvar)
      44             : {
      45     2104704 :   if (_u_var_num == jvar)
      46     2104704 :     return _coeff * _div_phi[_j][_qp] * _test[_i][_qp];
      47             : 
      48           0 :   return 0.0;
      49             : }

Generated by: LCOV version 1.14