23 params.
addCoupledVar(
"scalar_variable",
"Primary coupled scalar variable");
24 params.
addParam<
bool>(
"compute_scalar_residuals",
true,
"Whether to compute scalar residuals");
30 _use_scalar(isParamValid(
"scalar_variable") ? true : false),
31 _compute_scalar_residuals(!_use_scalar ? false : getParam<bool>(
"compute_scalar_residuals")),
32 _kappa_var_ptr(_use_scalar ? getScalarVar(
"scalar_variable", 0) : nullptr),
33 _kappa_var(_use_scalar ? _kappa_var_ptr->number() : 0),
34 _k_order(_use_scalar ? _kappa_var_ptr->order() : 0),
35 _kappa(_use_scalar ? (_is_implicit ? _kappa_var_ptr->sln() : _kappa_var_ptr->slnOld()) : _zero)
47 std::vector<Real> scalar_residuals(
_k_order);
74 for (
const auto & svariable : coupled_scalar_vars)
85 for (
const auto & svariable : coupled_scalar_vars)
97 for (
const auto & svariable : coupled_scalar_vars)
101 const unsigned int svar_num = svariable->number();
134 std::array<MType, 3> mortar_types = {{MType::Secondary, MType::Primary, MType::Lower}};
137 for (
const auto & it : ce)
142 const unsigned int ivar_num = ivariable.
number();
143 const unsigned int jvar_num = jvariable.
number();
149 std::array<size_t, 3> shape_space_sizes{{jvariable.
dofIndices().size(),
152 std::array<const VariablePhiValue *, 3> phis;
153 std::array<const VariablePhiGradient *, 3> grad_phis;
154 std::array<const VectorVariablePhiValue *, 3> vector_phis;
155 std::array<const VectorVariablePhiGradient *, 3> vector_grad_phis;
159 vector_phis = {{&temp_var.
phiFace(), &temp_var.phiFaceNeighbor(), &temp_var.phiLower()}};
161 {&temp_var.gradPhiFace(), &temp_var.gradPhiFaceNeighbor(), &temp_var.gradPhiLower()}};
166 phis = {{&temp_var.
phiFace(), &temp_var.phiFaceNeighbor(), &temp_var.phiLower()}};
168 {&temp_var.gradPhiFace(), &temp_var.gradPhiFaceNeighbor(), &temp_var.gradPhiLower()}};
172 for (MooseIndex(3) type_index = 0; type_index < 3; ++type_index)
174 const auto mortar_type = mortar_types[type_index];
175 const auto shape_space_size = shape_space_sizes[type_index];
176 std::vector<dof_id_type> dof_indices;
179 case MType::Secondary:
200 _phi = phis[type_index];
212 for (
_j = 0;
_j < shape_space_size;
_j++)
231 unsigned int test_space_size = 0;
232 std::vector<dof_id_type> dof_indices;
233 Real scaling_factor = 1;
249 mooseAssert(
_var,
"LM variable is null");
250 test_space_size =
_test.size();
258 const unsigned int s_order = svar.
order();
266 for (
_h = 0;
_h < s_order;
_h++)
267 for (
_i = 0;
_i < test_space_size;
_i++)
283 const unsigned int s_order = svar.
order();
290 for (
_l = 0;
_l < s_order;
_l++)
const std::vector< std::pair< MooseVariableScalar *, MooseVariableFieldBase * > > & scalarFieldCouplingEntries() const
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.
unsigned int number() const
Get variable number coming from libMesh.
Class for stuff related to variables.
const std::vector< dof_id_type > & dofIndicesLower() const final
Get dof indices for the current lower dimensional element (this is meaningful when performing mortar ...
const FieldVariablePhiValue & phiFace() const override final
Return the variable's shape functions on an element face.
This class provides an interface for common operations on field variables of both FE and FV types wit...
virtual const std::vector< dof_id_type > & dofIndicesLower() const =0
Get dof indices for the current lower dimensional element (this is meaningful when performing mortar ...
virtual bool isVector() const =0
virtual const std::vector< dof_id_type > & dofIndicesNeighbor() const =0
Get neighbor DOF indices for currently selected element.
Class for scalar variables (they are different).
MooseVariableField< Real > & _primary_var
Reference to the primary variable.
MooseVariable *const _var
Pointer to the lagrange multipler variable. nullptr if none.
const VariableTestValue & _test_secondary
The shape functions corresponding to the secondary interior primal variable.
const MooseArray< Real > & _coord
Member for handling change of coordinate systems (xyz, rz, spherical)
const bool _compute_primal_residuals
Whether to compute primal residuals.
MooseVariableField< Real > & _secondary_var
Reference to the secondary variable.
const VariableTestValue & _test
The shape functions corresponding to the lagrange multiplier variable.
const bool _compute_lm_residuals
Whether to compute lagrange multiplier residuals.
virtual void computeJacobian() override
Method for computing the Jacobian.
virtual void computeResidual() override
Method for computing the residual.
const VariableTestValue & _test_primary
The shape functions corresponding to the primary interior primal variable.
const VariablePhiGradient * _grad_phi
The current shape function gradients.
const VariablePhiValue * _phi
The current shape functions.
const VectorVariablePhiGradient * _vector_grad_phi
The current shape function gradients for vector variables.
static InputParameters validParams()
const VectorVariablePhiValue * _vector_phi
The current shape functions for vector variables.
const libMesh::QBase *const & _qrule_msm
The quadrature rule on the mortar segment element.
const std::vector< Real > & _JxW_msm
The element Jacobian times weights.
void computeScalarOffDiagJacobian()
Method for computing an off-diagonal jacobian component d-_kappa-residual / d-jvar.
virtual Real computeScalarQpResidual()
Method for computing the scalar part of residual at quadrature points.
const unsigned int _k_order
Order of the scalar variable, used in several places.
MortarScalarBase(const InputParameters ¶meters)
virtual Real computeQpOffDiagJacobianScalar(const Moose::MortarType, unsigned int)
For coupling scalar variables.
virtual void initScalarQpOffDiagJacobian(const Moose::MortarType, const unsigned int)
Put necessary evaluations depending on qp but independent of test and shape functions here for off-di...
const bool _use_scalar
Whether a scalar variable is declared for this constraint.
unsigned int _h
Used internally to iterate over each scalar component.
virtual void initScalarQpResidual()
Put necessary evaluations depending on qp but independent of test functions here.
virtual Real computeScalarQpOffDiagJacobian(const Moose::MortarType, const unsigned int)
Method for computing an off-diagonal jacobian component at quadrature points.
void computeScalarOffDiagJacobianScalar(const unsigned int svar_num)
Method for computing an off-diagonal jacobian component d-_kappa-residual / d-scalar.
const bool _compute_scalar_residuals
Whether to compute scalar contributions for this instance.
const unsigned int _kappa_var
The unknown scalar variable ID.
virtual Real computeScalarQpJacobian()
Method for computing the scalar variable part of Jacobian at quadrature points.
const MooseVariableScalar *const _kappa_var_ptr
(Pointer to) Scalar variable this kernel operates on
virtual void initScalarQpJacobian(const unsigned int)
Put necessary evaluations depending on qp but independent of test and shape functions here.
virtual Real computeScalarQpOffDiagJacobianScalar(const unsigned int)
Method for computing an off-diagonal jacobian component at quadrature points.
virtual void computeJacobian() override
Computes d-_var-residual / d-_var and d-_var-residual / d-jvar, as well as d-_kappa-residual / d-_var...
static InputParameters validParams()
void computeOffDiagJacobianScalar(unsigned int) override final
Computes jacobian block with respect to a scalar variable.
virtual void computeScalarJacobian()
Method for computing the scalar variable part of Jacobian.
virtual void computeResidual() override
Computes _var-residuals as well as _kappa-residual.
THREAD_ID _tid
The thread ID for this kernel.
Assembly & _assembly
Reference to this Kernel's assembly object.
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.
virtual bool hasScalarVariable(const std::string &var_name) const
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.
void resize(const unsigned int new_m, const unsigned int new_n)
unsigned int n_points() const