https://mooseframework.inl.gov
Loading...
Searching...
No Matches
ArrayNodalKernel.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 "ArrayNodalKernel.h"
11#include "SubProblem.h"
12#include "SystemBase.h"
13#include "MooseVariableFE.h"
14#include "Assembly.h"
15
21
23 : NodalKernelBase(parameters),
24 MooseVariableInterface<RealEigenVector>(this,
25 true,
26 "variable",
27 Moose::VarKindType::VAR_SOLVER,
28 Moose::VarFieldType::VAR_FIELD_ARRAY),
29 _var(*mooseVariable()),
30 _u(_var.dofValues()),
31 _count(_var.count()),
32 _work_vector(_count),
33 _scaling(_var.arrayScalingFactor())
34{
36}
37
38void
47
48void
50{
51 if (!_var.isNodalDefined())
52 return;
53 _qp = 0;
54
57 mooseAssert(_ivar_indices->size() == _count, "The number of dofs should be equal to count");
58
60}
61
62void
63ArrayNodalKernel::computeOffDiagJacobian(const unsigned int jvar_num)
64{
65 if (!_var.isNodalDefined())
66 return;
67
68 if (jvar_num == _var.number())
70 else
71 {
72 const auto & jvar = getVariable(jvar_num);
74 _jvar_indices = &jvar.dofIndices();
75 mooseAssert(_ivar_indices->size() == _count, "The number of dofs should be equal to count");
76 mooseAssert(_jvar_indices->size() == jvar.count(),
77 "The number of dofs should be equal to count");
78
80 }
81}
82
83void
84ArrayNodalKernel::setJacobian(unsigned int i, unsigned int j, Real value)
85{
87}
unsigned int count
Definition MortarUtils.C:53
const std::vector< dof_id_type > * _ivar_indices
DOF indices.
virtual void computeResidual() override
Compute and assemble the residual at the current node.
MooseVariableFE< RealEigenVector > & _var
variable this works on
void setJacobian(unsigned int i, unsigned int j, Real value)
Add a Jacobian entry for the current nodal kernel contribution.
const unsigned int _count
Number of components of the array variable.
virtual void computeQpOffDiagJacobian(unsigned int)
The user can override this function to compute the inter-variable off-diagonal Jacobian contribution ...
virtual void computeQpResidual(RealEigenVector &residual)=0
The user must override this function to compute the residual at a node.
virtual void computeQpJacobian()
The user can override this function to compute the intra-variable off-diagonal Jacobian contribution ...
RealEigenVector _work_vector
Work vector for residual.
static InputParameters validParams()
Class constructor.
virtual void computeOffDiagJacobian(unsigned int jvar) override
Compute the off-diagonal Jacobian at one node.
const std::vector< dof_id_type > * _jvar_indices
virtual void computeJacobian() override
Compute and assemble the Jacobian at one node.
ArrayNodalKernel(const InputParameters &parameters)
const std::vector< Real > & _scaling
scaling factors
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
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...
const std::vector< dof_id_type > & dofIndices() const final
Get local DoF indices.
virtual bool isNodalDefined() const override
Is this variable defined at nodes.
Interface for objects that need to get values of MooseVariables.
virtual const OutputTools< RealEigenVector >::VariableValue & value()
The value of the variable this object is operating on.
MooseVariableFE< RealEigenVector > * mooseVariable() const
Return the MooseVariableFE object that this interface acts on.
Base class for creating new types of nodal kernels.
unsigned int _qp
Quadrature point index.
static InputParameters validParams()
Class constructor.
Assembly & _assembly
Reference to this Kernel's assembly object.
const MooseVariableFieldBase & getVariable(unsigned int jvar_num) const
Retrieve the variable object from our system associated with jvar_num.
void addJacobianElement(Assembly &assembly, Real value, dof_id_type row_index, dof_id_type column_index, Real scaling_factor)
Add into a single Jacobian element.
void addResiduals(Assembly &assembly, const Residuals &residuals, const Indices &dof_indices, Real scaling_factor)
Add the provided incoming residuals corresponding to the provided dof indices.
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...