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

Generated by: LCOV version 1.14