18#include "libmesh/quadrature.h"
25 params.
addCoupledVar(
"scalar_variable",
"Primary coupled scalar variable");
26 params.
addParam<
bool>(
"compute_scalar_residuals",
true,
"Whether to compute scalar residuals");
28 "compute_field_residuals",
true,
"Whether to compute residuals for the field variable.");
34 _use_scalar(isParamValid(
"scalar_variable") ? true : false),
35 _compute_scalar_residuals(!_use_scalar ? false : getParam<bool>(
"compute_scalar_residuals")),
36 _compute_field_residuals(getParam<bool>(
"compute_field_residuals")),
37 _kappa_var_ptr(_use_scalar ? getScalarVar(
"scalar_variable", 0) : nullptr),
38 _kappa_var(_use_scalar ? _kappa_var_ptr->number() : 0),
39 _k_order(_use_scalar ? _kappa_var_ptr->order() : 0),
40 _kappa(_use_scalar ? (_is_implicit ? _kappa_var_ptr->sln() : _kappa_var_ptr->slnOld()) : _zero)
57 std::vector<Real> scalar_residuals(
_k_order);
105 if (jvar_num ==
variable().number())
125 if (jvar_num ==
variable().number())
147 const auto jvar_size = jvar.phiSize();
154 for (
_j = 0;
_j < jvar_size;
_j++)
159 mooseError(
"Array variable cannot be coupled into Kernel Scalar currently");
161 mooseError(
"Vector variable cannot be coupled into Kernel Scalar currently");
175 const unsigned int s_order = svar.
order();
182 for (
_l = 0;
_l < s_order;
_l++)
195 if (svar_num ==
variable().number())
228 const unsigned int s_order = svar.
order();
235 for (
_l = 0;
_l < s_order;
_l++)
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
const MooseArray< Real > & _coord
The scaling factor to convert from cartesian to another coordinate system (e.g rz,...
unsigned int _qp
The current quadrature point index.
const MooseArray< Real > & _JxW
The current quadrature point weight value.
unsigned int _j
current index for the shape function
unsigned int _i
current index for the test function
const QBase *const & _qrule
active quadrature rule
virtual void precalculateOffDiagJacobianScalar(unsigned int)
Precalculate method that is executed prior to scalar coupled variable loop within computeOffDiagJacob...
virtual void computeScalarOffDiagJacobian(const unsigned int jvar_num)
Method for computing an off-diagonal jacobian component d-_kappa-residual / d-jvar.
virtual void computeOffDiagJacobian(unsigned int jvar_num) override
Computes d-_var-residual / d-jvar as well as d-_kappa-residual / d-jvar.
virtual void computeJacobian() override
Compute this Kernel's contribution to the diagonal Jacobian entries.
virtual void initScalarQpJacobian(const unsigned int)
Put necessary evaluations depending on qp but independent of test and shape functions here.
virtual void computeScalarJacobian()
Method for computing the scalar variable part of Jacobian.
virtual Real computeScalarQpOffDiagJacobian(const unsigned int)
Method for computing an off-diagonal jacobian component at quadrature points.
virtual Real computeScalarQpResidual()
Method for computing the scalar part of residual at quadrature points.
virtual Real computeScalarQpJacobian()
Method for computing the scalar variable part of Jacobian at quadrature points.
const unsigned int _kappa_var
The unknown scalar variable ID.
virtual void initScalarQpOffDiagJacobian(const MooseVariableFEBase &)
Put necessary evaluations depending on qp but independent of test and shape functions here for off-di...
const unsigned int _k_order
Order of the scalar variable, used in several places.
void computeOffDiagJacobianScalar(unsigned int svar_num) override
Computes jacobian block with respect to a scalar variable.
virtual void computeResidualAndJacobian() override
Compute the residual and Jacobian together.
const bool _compute_field_residuals
Whether to compute field contributions for this instance.
virtual void initScalarQpResidual()
Put necessary evaluations depending on qp but independent of test functions here.
virtual void computeResidual() override
Compute this Kernel's contribution to the residual.
unsigned int _h
Used internally to iterate over each scalar component.
virtual void computeOffDiagJacobianScalarLocal(const unsigned int svar_num)
Method for computing an off-diagonal jacobian component d-_var-residual / d-scalar Revised version of...
virtual void computeScalarOffDiagJacobianScalar(const unsigned int svar_num)
Method for computing an off-diagonal jacobian component d-_kappa-residual / d-scalar.
virtual Real computeScalarQpOffDiagJacobianScalar(const unsigned int)
Method for computing an off-diagonal jacobian component at quadrature points.
const MooseVariableScalar *const _kappa_var_ptr
(Pointer to) Scalar variable this kernel operates on
static InputParameters validParams()
KernelScalarBase(const InputParameters ¶meters)
const bool _use_scalar
Whether a scalar variable is declared for this kernel.
virtual void computeScalarResidual()
Method for computing the scalar part of residual.
const bool _compute_scalar_residuals
Whether to compute scalar contributions for this instance.
virtual void computeResidual() override
Compute this Kernel's contribution to the residual.
virtual void computeOffDiagJacobianScalar(unsigned int jvar) override
Computes jacobian block with respect to a scalar variable.
virtual void computeResidualAndJacobian() override
Compute the residual and Jacobian together.
virtual void computeOffDiagJacobian(unsigned int jvar) override
Computes d-residual / d-jvar... storing the result in Ke.
MooseVariable & _var
This is a regular kernel so we cast to a regular MooseVariable.
virtual void computeJacobian() override
Compute this Kernel's contribution to the diagonal Jacobian entries.
const VariableTestValue & _test
the current test function
static InputParameters validParams()
virtual Real computeQpOffDiagJacobianScalar(unsigned int)
For coupling scalar variables.
virtual const MooseVariable & variable() const override
Returns the variable that this object operates on.
virtual const std::vector< dof_id_type > & dofIndices() const
Get local DoF indices.
void scalingFactor(const std::vector< Real > &factor)
Set the scaling factor for this variable.
libMesh::Order order() const
Get the order of this variable Note: Order enum can be implicitly converted to unsigned int.
const std::vector< dof_id_type > & dofIndices() const final
Get local DoF indices.
THREAD_ID _tid
The thread ID for this kernel.
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.
SystemBase & _sys
Reference to the EquationSystem object.
const std::vector< MooseVariableScalar * > & getCoupledMooseScalarVars()
Get the list of coupled scalar variables.
virtual MooseVariableScalar & getScalarVariable(THREAD_ID tid, const std::string &var_name) const
Gets a reference to a scalar variable with specified number.
DenseMatrix< Number > _local_ke
Holds local Jacobian entries as they are accumulated by this Kernel.
void addJacobian(Assembly &assembly, const Residuals &residuals, const Indices &dof_indices, Real scaling_factor)
Add the provided residual derivatives into the Jacobian for the provided dof indices.
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.
bool _is_implicit
If the object is using implicit or explicit form.
void resize(const unsigned int new_m, const unsigned int new_n)