19 #include "libmesh/threads.h" 20 #include "libmesh/quadrature.h" 37 _var(*mooseVariable()),
39 _grad_test(_var.gradPhi()),
40 _phi(_assembly.phi(_var)),
41 _grad_phi(_assembly.gradPhi(_var)),
42 _u(_is_implicit ? _var.sln() : _var.slnOld()),
43 _grad_u(_is_implicit ? _var.gradSln() : _var.gradSlnOld())
54 paramError(
"save_in",
"cannot use solution variable as save-in variable");
59 "saved-in auxiliary variable is incompatible with the object's nonlinear variable: ",
74 paramError(
"diag_save_in",
"cannot use solution variable as diag save-in variable");
79 "saved-in auxiliary variable is incompatible with the object's nonlinear variable: ",
107 Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
109 var->sys().solution().add_vector(
_local_re, var->dofIndices());
129 Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
131 var->sys().solution().add_vector(diag, var->dofIndices());
148 auto phi_size = jvar.dofIndices().size();
151 "The size of the phi container does not match the number of local Jacobian columns");
157 if (jvar.count() == 1)
160 for (
_j = 0;
_j < phi_size;
_j++)
166 unsigned int n = phi_size;
168 for (
_j = 0;
_j < n;
_j++)
173 const_cast<MooseVariableFieldBase &>(jvar)));
174 for (
unsigned int k = 0; k < v.size(); ++k)
204 const unsigned int ivar = ivariable->number();
205 const unsigned int jvar = jvariable->number();
virtual void computeResidual() override
Compute this Kernel's contribution to the residual.
std::vector< std::pair< MooseVariableFEBase *, MooseVariableFEBase * > > & couplingEntries(const THREAD_ID tid, const unsigned int nl_sys_num)
static InputParameters validParams()
void accumulateTaggedLocalResidual()
Local residual blocks will be appended by adding the current local kernel residual.
virtual Real computeQpResidual()=0
Compute this Kernel's contribution to the residual at the current quadrature point.
bool hasVectorTags() const
virtual RealEigenVector computeQpOffDiagJacobianArray(const ArrayMooseVariable &jvar)
For coupling array variables.
MooseVariable & _var
This is a regular kernel so we cast to a regular MooseVariable.
Class for stuff related to variables.
std::vector< MooseVariableFEBase * > _save_in
std::string incompatVarMsg(MooseVariableFieldBase &var1, MooseVariableFieldBase &var2)
Builds and returns a string of the form:
const MooseArray< Real > & _JxW
The current quadrature point weight value.
std::vector< AuxVariableName > _diag_save_in_strings
virtual void precalculateOffDiagJacobian(unsigned int)
unsigned int number() const
Get variable number coming from libMesh.
virtual Real computeQpOffDiagJacobian(unsigned int)
For coupling standard variables.
virtual void precalculateResidual()
bool computingScalingJacobian() const
Whether we are computing an initial Jacobian for automatic variable scaling.
virtual void prepareShapes(unsigned int var_num)
Prepare shape functions.
virtual void computeResidualAndJacobian() override
Compute the residual and Jacobian together.
THREAD_ID _tid
The thread ID for this kernel.
bool _has_diag_save_in
The aux variables to save the diagonal Jacobian contributions to.
DenseVector< Real > getJacobianDiagonal(DenseMatrix< Number > &ke)
DenseMatrix< Number > _local_ke
Holds local Jacobian entries as they are accumulated by this Kernel.
const FEType & feType() const
Get the type of finite element object.
const MooseVariableFieldBase & getVariable(unsigned int jvar_num) const
Retrieve the variable object from our system associated with jvar_num.
Kernel(const InputParameters ¶meters)
SystemBase & _sys
Reference to the EquationSystem object.
MooseVariableFE< Real > * mooseVariable() const
unsigned int size() const
The number of elements that can currently be stored in the array.
const VariableTestValue & _test
the current test function
This is the common base class for the three main kernel types implemented in MOOSE, Kernel, VectorKernel and ArrayKernel.
virtual void precalculateJacobian()
std::vector< MooseVariableFEBase * > _diag_save_in
SubProblem & _subproblem
Reference to this kernel's SubProblem.
VarKindType
Framework-wide stuff.
const QBase *const & _qrule
active quadrature rule
bool _has_save_in
The aux variables to save the residual contributions to.
FEProblemBase & _fe_problem
Reference to this kernel's FEProblemBase.
virtual Real computeQpJacobian()
Compute this Kernel's contribution to the Jacobian at the current quadrature point.
unsigned int _i
current index for the test function
virtual MooseVariable & getStandardVariable(const THREAD_ID tid, const std::string &var_name)=0
Returns the variable reference for requested MooseVariable which may be in any system.
NonlinearSystemBase & getNonlinearSystemBase(const unsigned int sys_num)
void paramError(const std::string ¶m, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
unsigned int number() const
Gets the number of this system.
void accumulateTaggedLocalMatrix()
Local Jacobian blocks will be appended by adding the current local kernel Jacobian.
const MooseArray< Real > & _coord
The scaling factor to convert from cartesian to another coordinate system (e.g rz, spherical, etc.)
Assembly & _assembly
Reference to this Kernel's assembly object.
virtual void computeJacobian() override
Compute this Kernel's contribution to the diagonal Jacobian entries.
Order order() const
Get the order of this variable Note: Order enum can be implicitly converted to unsigned int...
std::vector< AuxVariableName > _save_in_strings
unsigned int _j
current index for the shape function
virtual MooseVariableScalar & getScalarVariable(THREAD_ID tid, const std::string &var_name) const
Gets a reference to a scalar variable with specified number.
void addMooseVariableDependency(MooseVariableFieldBase *var)
Call this function to add the passed in MooseVariableFieldBase as a variable that this object depends...
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual void addVariableToZeroOnResidual(std::string var_name)
Adds this variable to the list of variables to be zeroed during each residual evaluation.
DenseVector< Number > _local_re
Holds local residual entries as they are accumulated by this Kernel.
Interface for objects that need to get values of MooseVariables.
Class for scalar variables (they are different).
virtual void addVariableToZeroOnJacobian(std::string var_name)
Adds this variable to the list of variables to be zeroed during each Jacobian evaluation.
Eigen::Matrix< Real, Eigen::Dynamic, 1 > RealEigenVector
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...
virtual Real computeQpOffDiagJacobianScalar(unsigned int)
For coupling scalar variables.
void prepareVectorTag(Assembly &assembly, unsigned int ivar)
Prepare data for computing element residual according to active tags.
static InputParameters validParams()
void prepareMatrixTag(Assembly &assembly, unsigned int ivar, unsigned int jvar)
Prepare data for computing element jacobian according to the active tags.
virtual void computeOffDiagJacobian(unsigned int jvar) override
Computes d-residual / d-jvar... storing the result in Ke.
const VariablePhiValue & _phi
the current shape functions
SystemBase & sys()
Get the system this variable is part of.
bool _is_implicit
If the object is using implicit or explicit form.
virtual void computeOffDiagJacobianScalar(unsigned int jvar) override
Computes jacobian block with respect to a scalar variable.
unsigned int _qp
The current quadrature point index.