www.mooseframework.org
NodalScalarKernel.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 template <>
21 {
23  params.addParam<std::vector<dof_id_type>>("nodes", "Supply nodes using node ids");
24  params.addParam<std::vector<BoundaryName>>(
25  "boundary", "The list of boundary IDs from the mesh where this nodal kernel applies");
26 
27  return params;
28 }
29 
31  : ScalarKernel(parameters),
32  Coupleable(this, true),
34  _node_ids(getParam<std::vector<dof_id_type>>("nodes")),
35  _boundary_names(getParam<std::vector<BoundaryName>>("boundary"))
36 {
37  // Fill in the MooseVariable dependencies
38  const std::vector<MooseVariableFEBase *> & coupled_vars = getCoupledMooseVars();
39  for (const auto & var : coupled_vars)
41 
42  // Check if node_ids and/or node_bc_names given
43  if ((_node_ids.size() == 0) && (_boundary_names.size() == 0))
44  mooseError("Must provide either 'nodes' or 'boundary' parameter.");
45 
46  if ((_node_ids.size() != 0) && (_boundary_names.size() != 0))
47  mooseError("Both 'nodes' and 'boundary' parameters were specified. Use the 'boundary' "
48  "parameter only.");
49 
50  // nodal bc names provided, append the nodes in each bc to _node_ids
51  if ((_node_ids.size() == 0) && (_boundary_names.size() != 0))
52  {
53  std::vector<dof_id_type> nodelist;
54 
55  for (auto & boundary_name : _boundary_names)
56  {
57  nodelist = _mesh.getNodeList(_mesh.getBoundaryID(boundary_name));
58  for (auto & node_id : nodelist)
59  _node_ids.push_back(node_id);
60  }
61  }
62  else
63  {
64  mooseDeprecated("Using the 'nodes' parameter is deprecated. Please update your input file to "
65  "use the 'boundary' parameter.");
66  }
67 }
68 
69 void
71 {
72  _subproblem.reinitNodes(_node_ids, _tid); // compute variables at nodes
74 }
75 
76 void
78 {
79  if (jvar == _var.number())
81 }
InputParameters validParams< ScalarKernel >()
Definition: ScalarKernel.C:20
unsigned int number() const
Get variable number coming from libMesh.
NodalScalarKernel(const InputParameters &parameters)
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
void mooseError(Args &&... args) const
Definition: MooseObject.h:147
Assembly & _assembly
Definition: ScalarKernel.h:73
void addMooseVariableDependency(MooseVariableFEBase *var)
Call this function to add the passed in MooseVariableFEBase as a variable that this object depends on...
InputParameters validParams< NodalScalarKernel >()
void prepareOffDiagScalar()
Definition: Assembly.C:2578
MooseVariableScalar & _var
Scalar variable.
Definition: ScalarKernel.h:75
THREAD_ID _tid
Definition: ScalarKernel.h:71
virtual void computeOffDiagJacobian(unsigned int jvar) override
const std::vector< dof_id_type > & getNodeList(boundary_id_type nodeset_id) const
Return a writable reference to a vector of node IDs that belong to nodeset_id.
Definition: MooseMesh.C:2594
std::vector< BoundaryName > _boundary_names
List of node boundary names.
virtual void reinitNodes(const std::vector< dof_id_type > &nodes, THREAD_ID tid)=0
virtual void computeJacobian()=0
virtual void reinit() override
SubProblem & _subproblem
Definition: ScalarKernel.h:68
Interface for objects that needs coupling capabilities.
Definition: Coupleable.h:62
const std::vector< MooseVariableFEBase * > & getCoupledMooseVars() const
Get the list of all coupled variables.
Definition: Coupleable.h:90
void mooseDeprecated(Args &&... args) const
Definition: MooseObject.h:161
std::vector< dof_id_type > _node_ids
List of node IDs.
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an option parameter and a documentation string to the InputParameters object...
MooseMesh & _mesh
Definition: ScalarKernel.h:76
BoundaryID getBoundaryID(const BoundaryName &boundary_name) const
Get the associated BoundaryID for the boundary name.
Definition: MooseMesh.C:1007