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 
20 {
22  params.addParam<std::vector<dof_id_type>>("nodes", {}, "Supply nodes using node ids");
23  params.addParam<std::vector<BoundaryName>>(
24  "boundary", {}, "The list of boundary IDs from the mesh where this nodal kernel applies");
25 
26  return params;
27 }
28 
30  : ScalarKernel(parameters),
31  Coupleable(this, true),
33  _node_ids(getParam<std::vector<dof_id_type>>("nodes")),
34  _boundary_names(getParam<std::vector<BoundaryName>>("boundary"))
35 {
36  // Fill in the MooseVariable dependencies
37  const std::vector<MooseVariableFEBase *> & coupled_vars = getCoupledMooseVars();
38  for (const auto & var : coupled_vars)
40 
41  // Check if node_ids and/or node_bc_names given
42  if ((_node_ids.size() == 0) && (_boundary_names.size() == 0))
43  mooseError("Must provide either 'nodes' or 'boundary' parameter.");
44 
45  if ((_node_ids.size() != 0) && (_boundary_names.size() != 0))
46  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  if ((_node_ids.size() == 0) && (_boundary_names.size() != 0))
51  {
52  std::vector<dof_id_type> nodelist;
53 
54  for (auto & boundary_name : _boundary_names)
55  {
56  nodelist = _mesh.getNodeList(_mesh.getBoundaryID(boundary_name));
57  for (auto & node_id : nodelist)
58  _node_ids.push_back(node_id);
59  }
60  }
61  else
62  {
63  mooseDeprecated("Using the 'nodes' parameter is deprecated. Please update your input file to "
64  "use the 'boundary' parameter.");
65  }
66 }
67 
68 void
70 {
71  _subproblem.reinitNodes(_node_ids, _tid); // compute variables at nodes
73 }
74 
75 void
77 {
78  if (jvar == _var.number())
80 }
MooseMesh & _mesh
Reference to this Kernel&#39;s mesh object.
void mooseDeprecated(Args &&... args) const
unsigned int number() const
Get variable number coming from libMesh.
virtual void computeOffDiagJacobianScalar(unsigned int jvar) override
Computes jacobian block with respect to a scalar variable.
NodalScalarKernel(const InputParameters &parameters)
static InputParameters validParams()
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
MooseVariableScalar & _var
Scalar variable.
virtual void computeJacobian() override
Compute this object&#39;s contribution to the diagonal Jacobian entries.
Definition: ScalarKernel.C:37
THREAD_ID _tid
The thread ID for this kernel.
void prepareOffDiagScalar()
Definition: Assembly.C:2965
SubProblem & _subproblem
Reference to this kernel&#39;s SubProblem.
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:3220
std::vector< BoundaryName > _boundary_names
List of node boundary names.
virtual void reinit() override
Reinitialization method called before each call to computeResidual()
Assembly & _assembly
Reference to this Kernel&#39;s assembly object.
const std::vector< MooseVariableFieldBase * > & getCoupledMooseVars() const
Get the list of all coupled variables.
Definition: Coupleable.h:69
Interface for objects that needs coupling capabilities.
Definition: Coupleable.h:44
void addMooseVariableDependency(MooseVariableFieldBase *var)
Call this function to add the passed in MooseVariableFieldBase as a variable that this object depends...
std::vector< dof_id_type > _node_ids
List of node IDs.
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
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...
static InputParameters validParams()
Definition: ScalarKernel.C:14
BoundaryID getBoundaryID(const BoundaryName &boundary_name) const
Get the associated BoundaryID for the boundary name.
Definition: MooseMesh.C:1474
uint8_t dof_id_type
virtual void reinitNodes(const std::vector< dof_id_type > &nodes, const THREAD_ID tid)=0