https://mooseframework.inl.gov
Loading...
Searching...
No Matches
NodalScalarKernel.C
Go to the documentation of this file.
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
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
68void
74
75void
77{
78 if (jvar == _var.number())
80}
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
void mooseDeprecated(Args &&... args)
Emit a deprecated code/feature message with the given stringified, concatenated args.
Definition MooseError.h:363
void prepareOffDiagScalar()
Definition Assembly.C:2977
Interface for objects that needs coupling capabilities.
Definition Coupleable.h:53
const std::vector< MooseVariableFieldBase * > & getCoupledMooseVars() const
Get the list of all coupled variables.
Definition Coupleable.h:84
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object.
BoundaryID getBoundaryID(const BoundaryName &boundary_name) const
Get the associated BoundaryID for the boundary name.
Definition MooseMesh.C:1681
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:3571
unsigned int number() const
Get variable number coming from libMesh.
void addMooseVariableDependency(MooseVariableFieldBase *var)
Call this function to add the passed in MooseVariableFieldBase as a variable that this object depends...
static InputParameters validParams()
virtual void computeOffDiagJacobianScalar(unsigned int jvar) override
Computes jacobian block with respect to a scalar variable.
NodalScalarKernel(const InputParameters &parameters)
std::vector< dof_id_type > _node_ids
List of node IDs.
virtual void reinit() override
Reinitialization method called before each call to computeResidual()
std::vector< BoundaryName > _boundary_names
List of node boundary names.
THREAD_ID _tid
The thread ID for this kernel.
MooseMesh & _mesh
Reference to this Kernel's mesh object.
Assembly & _assembly
Reference to this Kernel's assembly object.
SubProblem & _subproblem
Reference to this kernel's SubProblem.
MooseVariableScalar & _var
Scalar variable.
virtual void computeJacobian() override
Compute this object's contribution to the diagonal Jacobian entries.
static InputParameters validParams()
virtual void reinitNodes(const std::vector< dof_id_type > &nodes, const THREAD_ID tid)=0