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 14303 : NodalScalarKernel::validParams() 20 : { 21 14303 : InputParameters params = ScalarKernel::validParams(); 22 14303 : params.addParam<std::vector<dof_id_type>>("nodes", {}, "Supply nodes using node ids"); 23 14303 : params.addParam<std::vector<BoundaryName>>( 24 : "boundary", {}, "The list of boundary IDs from the mesh where this nodal kernel applies"); 25 : 26 14303 : return params; 27 0 : } 28 : 29 21 : NodalScalarKernel::NodalScalarKernel(const InputParameters & parameters) 30 : : ScalarKernel(parameters), 31 : Coupleable(this, true), 32 : MooseVariableDependencyInterface(this), 33 21 : _node_ids(getParam<std::vector<dof_id_type>>("nodes")), 34 42 : _boundary_names(getParam<std::vector<BoundaryName>>("boundary")) 35 : { 36 : // Fill in the MooseVariable dependencies 37 21 : const std::vector<MooseVariableFEBase *> & coupled_vars = getCoupledMooseVars(); 38 42 : for (const auto & var : coupled_vars) 39 21 : addMooseVariableDependency(var); 40 : 41 : // Check if node_ids and/or node_bc_names given 42 21 : if ((_node_ids.size() == 0) && (_boundary_names.size() == 0)) 43 0 : mooseError("Must provide either 'nodes' or 'boundary' parameter."); 44 : 45 21 : 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 21 : if ((_node_ids.size() == 0) && (_boundary_names.size() != 0)) 51 : { 52 21 : std::vector<dof_id_type> nodelist; 53 : 54 67 : for (auto & boundary_name : _boundary_names) 55 : { 56 46 : nodelist = _mesh.getNodeList(_mesh.getBoundaryID(boundary_name)); 57 92 : for (auto & node_id : nodelist) 58 46 : _node_ids.push_back(node_id); 59 : } 60 21 : } 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 21 : } 67 : 68 : void 69 27 : NodalScalarKernel::reinit() 70 : { 71 27 : _subproblem.reinitNodes(_node_ids, _tid); // compute variables at nodes 72 27 : _assembly.prepareOffDiagScalar(); 73 27 : } 74 : 75 : void 76 0 : NodalScalarKernel::computeOffDiagJacobianScalar(unsigned int jvar) 77 : { 78 0 : if (jvar == _var.number()) 79 0 : computeJacobian(); 80 0 : }