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++)
virtual void computeScalarResidual()
Method for computing the scalar part of residual.
virtual void computeResidual() override
Compute this Kernel's contribution to the residual.
static InputParameters validParams()
virtual void computeOffDiagJacobianScalarLocal(const unsigned int svar_num)
Method for computing an off-diagonal jacobian component d-_var-residual / d-scalar Revised version of...
MooseVariable & _var
This is a regular kernel so we cast to a regular MooseVariable.
const MooseArray< Real > & _JxW
The current quadrature point weight value.
unsigned int _h
Used internally to iterate over each scalar component.
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.
const bool _compute_scalar_residuals
Whether to compute scalar contributions for this instance.
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.
THREAD_ID _tid
The thread ID for this kernel.
virtual void precalculateOffDiagJacobianScalar(unsigned int)
Precalculate method that is executed prior to scalar coupled variable loop within computeOffDiagJacob...
DenseMatrix< Number > _local_ke
Holds local Jacobian entries as they are accumulated by this Kernel.
const MooseVariableFieldBase & getVariable(unsigned int jvar_num) const
Retrieve the variable object from our system associated with jvar_num.
virtual void computeOffDiagJacobian(unsigned int jvar_num) override
Computes d-_var-residual / d-jvar as well as d-_kappa-residual / d-jvar.
virtual void computeScalarOffDiagJacobianScalar(const unsigned int svar_num)
Method for computing an off-diagonal jacobian component d-_kappa-residual / d-scalar.
SystemBase & _sys
Reference to the EquationSystem object.
virtual void computeScalarJacobian()
Method for computing the scalar variable part of Jacobian.
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.
const VariableTestValue & _test
the current test function
const std::vector< dof_id_type > & dofIndices() const final
Get local DoF indices.
virtual Real computeScalarQpJacobian()
Method for computing the scalar variable part of Jacobian at quadrature points.
virtual void computeJacobian() override
Compute this Kernel's contribution to the diagonal Jacobian entries.
const QBase *const & _qrule
active quadrature rule
virtual const std::vector< dof_id_type > & dofIndices() const
Get local DoF indices.
unsigned int _i
current index for the test function
virtual Real computeScalarQpOffDiagJacobian(const unsigned int)
Method for computing an off-diagonal jacobian component at quadrature points.
KernelScalarBase(const InputParameters ¶meters)
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 initScalarQpJacobian(const unsigned int)
Put necessary evaluations depending on qp but independent of test and shape functions here...
virtual void computeJacobian() override
Compute this Kernel's contribution to the diagonal Jacobian entries.
libMesh::Order order() const
Get the order of this variable Note: Order enum can be implicitly converted to unsigned int...
virtual void computeScalarOffDiagJacobian(const unsigned int jvar_num)
Method for computing an off-diagonal jacobian component d-_kappa-residual / d-jvar.
unsigned int _j
current index for the shape function
virtual Real computeScalarQpOffDiagJacobianScalar(const unsigned int)
Method for computing an off-diagonal jacobian component at quadrature points.
virtual MooseVariableScalar & getScalarVariable(THREAD_ID tid, const std::string &var_name) const
Gets a reference to a scalar variable with specified number.
virtual Real computeScalarQpResidual()
Method for computing the scalar part of residual at quadrature points.
virtual const MooseVariable & variable() const override
Returns the variable that this object operates on.
void resize(const unsigned int new_m, const unsigned int new_n)
static InputParameters validParams()
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
virtual void initScalarQpResidual()
Put necessary evaluations depending on qp but independent of test functions here. ...
const MooseVariableScalar *const _kappa_var_ptr
(Pointer to) Scalar variable this kernel operates on
virtual Real computeQpOffDiagJacobianScalar(unsigned int)
For coupling scalar variables.
const unsigned int _kappa_var
The unknown scalar variable ID.
virtual void computeOffDiagJacobian(unsigned int jvar) override
Computes d-residual / d-jvar... storing the result in Ke.
const bool _compute_field_residuals
Whether to compute field 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.
const bool _use_scalar
Whether a scalar variable is declared for this kernel.
void scalingFactor(const std::vector< Real > &factor)
Set the scaling factor for this variable.
unsigned int _qp
The current quadrature point index.
virtual void initScalarQpOffDiagJacobian(const MooseVariableFEBase &)
Put necessary evaluations depending on qp but independent of test and shape functions here for off-di...