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 
19 
22 {
24  params.addParam<std::vector<dof_id_type>>("nodes", "Supply nodes using node ids");
25  params.addParam<std::vector<BoundaryName>>(
26  "boundary", "The list of boundary IDs from the mesh where this nodal kernel applies");
27 
28  return params;
29 }
30 
32  : ScalarKernel(parameters),
33  Coupleable(this, true),
35  _node_ids(getParam<std::vector<dof_id_type>>("nodes")),
36  _boundary_names(getParam<std::vector<BoundaryName>>("boundary"))
37 {
38  // Fill in the MooseVariable dependencies
39  const std::vector<MooseVariableFEBase *> & coupled_vars = getCoupledMooseVars();
40  for (const auto & var : coupled_vars)
42 
43  // Check if node_ids and/or node_bc_names given
44  if ((_node_ids.size() == 0) && (_boundary_names.size() == 0))
45  mooseError("Must provide either 'nodes' or 'boundary' parameter.");
46 
47  if ((_node_ids.size() != 0) && (_boundary_names.size() != 0))
48  mooseError("Both 'nodes' and 'boundary' parameters were specified. Use the 'boundary' "
49  "parameter only.");
50 
51  // nodal bc names provided, append the nodes in each bc to _node_ids
52  if ((_node_ids.size() == 0) && (_boundary_names.size() != 0))
53  {
54  std::vector<dof_id_type> nodelist;
55 
56  for (auto & boundary_name : _boundary_names)
57  {
58  nodelist = _mesh.getNodeList(_mesh.getBoundaryID(boundary_name));
59  for (auto & node_id : nodelist)
60  _node_ids.push_back(node_id);
61  }
62  }
63  else
64  {
65  mooseDeprecated("Using the 'nodes' parameter is deprecated. Please update your input file to "
66  "use the 'boundary' parameter.");
67  }
68 }
69 
70 void
72 {
73  _subproblem.reinitNodes(_node_ids, _tid); // compute variables at nodes
75 }
76 
77 void
79 {
80  if (jvar == _var.number())
82 }
MooseMesh.h
ScalarKernel::_subproblem
SubProblem & _subproblem
Definition: ScalarKernel.h:70
SystemBase.h
MooseObject::mooseError
void mooseError(Args &&... args) const
Definition: MooseObject.h:141
ScalarKernel::_mesh
MooseMesh & _mesh
Definition: ScalarKernel.h:78
Assembly::prepareOffDiagScalar
void prepareOffDiagScalar()
Definition: Assembly.C:2578
MooseVariableDependencyInterface::addMooseVariableDependency
void addMooseVariableDependency(MooseVariableFEBase *var)
Call this function to add the passed in MooseVariableFEBase as a variable that this object depends on...
Definition: MooseVariableDependencyInterface.h:36
ScalarKernel
Definition: ScalarKernel.h:35
MooseMesh::getNodeList
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:2626
NodalScalarKernel::computeOffDiagJacobian
virtual void computeOffDiagJacobian(unsigned int jvar) override
Definition: NodalScalarKernel.C:78
MooseVariableDependencyInterface
Definition: MooseVariableDependencyInterface.h:17
MooseMesh::getBoundaryID
BoundaryID getBoundaryID(const BoundaryName &boundary_name) const
Get the associated BoundaryID for the boundary name.
Definition: MooseMesh.C:1039
InputParameters::addParam
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.
Definition: InputParameters.h:1198
Assembly.h
defineLegacyParams
defineLegacyParams(NodalScalarKernel)
NodalScalarKernel::reinit
virtual void reinit() override
Definition: NodalScalarKernel.C:71
InputParameters
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
Definition: InputParameters.h:53
NodalScalarKernel::_boundary_names
std::vector< BoundaryName > _boundary_names
List of node boundary names.
Definition: NodalScalarKernel.h:40
MooseVariableScalar.h
ScalarKernel::_assembly
Assembly & _assembly
Definition: ScalarKernel.h:75
NodalScalarKernel::_node_ids
std::vector< dof_id_type > _node_ids
List of node IDs.
Definition: NodalScalarKernel.h:38
Coupleable
Interface for objects that needs coupling capabilities.
Definition: Coupleable.h:62
ScalarKernel::_tid
THREAD_ID _tid
Definition: ScalarKernel.h:73
ScalarKernel::computeJacobian
virtual void computeJacobian()=0
std
Definition: TheWarehouse.h:80
Coupleable::getCoupledMooseVars
const std::vector< MooseVariableFEBase * > & getCoupledMooseVars() const
Get the list of all coupled variables.
Definition: Coupleable.h:85
ScalarKernel::validParams
static InputParameters validParams()
Definition: ScalarKernel.C:21
NodalScalarKernel.h
MooseObject::mooseDeprecated
void mooseDeprecated(Args &&... args) const
Definition: MooseObject.h:156
SubProblem::reinitNodes
virtual void reinitNodes(const std::vector< dof_id_type > &nodes, THREAD_ID tid)=0
NodalScalarKernel::validParams
static InputParameters validParams()
Definition: NodalScalarKernel.C:21
NodalScalarKernel
Definition: NodalScalarKernel.h:24
ScalarKernel::_var
MooseVariableScalar & _var
Scalar variable.
Definition: ScalarKernel.h:77
NodalScalarKernel::NodalScalarKernel
NodalScalarKernel(const InputParameters &parameters)
Definition: NodalScalarKernel.C:31
MooseVariableBase::number
unsigned int number() const
Get variable number coming from libMesh.
Definition: MooseVariableBase.h:48