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

Generated by: LCOV version 1.14