LCOV - code coverage report
Current view: top level - src/kernels - NodalScalarKernel.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 25 33 75.8 %
Date: 2025-07-17 01:28:37 Functions: 3 4 75.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 "NodalScalarKernel.h"
      11             : 
      12             : // MOOSE includes
      13             : #include "Assembly.h"
      14             : #include "MooseVariableScalar.h"
      15             : #include "MooseMesh.h"
      16             : #include "SystemBase.h"
      17             : 
      18             : InputParameters
      19       14301 : NodalScalarKernel::validParams()
      20             : {
      21       14301 :   InputParameters params = ScalarKernel::validParams();
      22       14301 :   params.addParam<std::vector<dof_id_type>>("nodes", {}, "Supply nodes using node ids");
      23       14301 :   params.addParam<std::vector<BoundaryName>>(
      24             :       "boundary", {}, "The list of boundary IDs  from the mesh where this nodal kernel applies");
      25             : 
      26       14301 :   return params;
      27           0 : }
      28             : 
      29          20 : NodalScalarKernel::NodalScalarKernel(const InputParameters & parameters)
      30             :   : ScalarKernel(parameters),
      31             :     Coupleable(this, true),
      32             :     MooseVariableDependencyInterface(this),
      33          20 :     _node_ids(getParam<std::vector<dof_id_type>>("nodes")),
      34          40 :     _boundary_names(getParam<std::vector<BoundaryName>>("boundary"))
      35             : {
      36             :   // Fill in the MooseVariable dependencies
      37          20 :   const std::vector<MooseVariableFEBase *> & coupled_vars = getCoupledMooseVars();
      38          40 :   for (const auto & var : coupled_vars)
      39          20 :     addMooseVariableDependency(var);
      40             : 
      41             :   // Check if node_ids and/or node_bc_names given
      42          20 :   if ((_node_ids.size() == 0) && (_boundary_names.size() == 0))
      43           0 :     mooseError("Must provide either 'nodes' or 'boundary' parameter.");
      44             : 
      45          20 :   if ((_node_ids.size() != 0) && (_boundary_names.size() != 0))
      46           0 :     mooseError("Both 'nodes' and 'boundary' parameters were specified. Use the 'boundary' "
      47             :                "parameter only.");
      48             : 
      49             :   // nodal bc names provided, append the nodes in each bc to _node_ids
      50          20 :   if ((_node_ids.size() == 0) && (_boundary_names.size() != 0))
      51             :   {
      52          20 :     std::vector<dof_id_type> nodelist;
      53             : 
      54          64 :     for (auto & boundary_name : _boundary_names)
      55             :     {
      56          44 :       nodelist = _mesh.getNodeList(_mesh.getBoundaryID(boundary_name));
      57          88 :       for (auto & node_id : nodelist)
      58          44 :         _node_ids.push_back(node_id);
      59             :     }
      60          20 :   }
      61             :   else
      62             :   {
      63           0 :     mooseDeprecated("Using the 'nodes' parameter is deprecated. Please update your input file to "
      64             :                     "use the 'boundary' parameter.");
      65             :   }
      66          20 : }
      67             : 
      68             : void
      69          24 : NodalScalarKernel::reinit()
      70             : {
      71          24 :   _subproblem.reinitNodes(_node_ids, _tid); // compute variables at nodes
      72          24 :   _assembly.prepareOffDiagScalar();
      73          24 : }
      74             : 
      75             : void
      76           0 : NodalScalarKernel::computeOffDiagJacobianScalar(unsigned int jvar)
      77             : {
      78           0 :   if (jvar == _var.number())
      79           0 :     computeJacobian();
      80           0 : }

Generated by: LCOV version 1.14