24 params.
addCoupledVar(
"scalar_variable",
"Primary coupled scalar variable");
25 params.
addParam<
bool>(
"compute_scalar_residuals",
true,
"Whether to compute scalar residuals");
31 _use_scalar(isParamValid(
"scalar_variable") ? true : false),
32 _compute_scalar_residuals(!_use_scalar ? false : getParam<bool>(
"compute_scalar_residuals")),
33 _kappa_var_ptr(_use_scalar ? getScalarVar(
"scalar_variable", 0) : nullptr),
34 _kappa_var(_use_scalar ? _kappa_var_ptr->number() : 0),
35 _k_order(_use_scalar ? _kappa_var_ptr->order() : 0),
36 _kappa(_use_scalar ? (_is_implicit ? _kappa_var_ptr->sln() : _kappa_var_ptr->slnOld()) : _zero)
48 std::vector<Real> scalar_residuals(
_k_order);
76 for (
const auto & svariable : coupled_scalar_vars)
90 for (
const auto & svariable : coupled_scalar_vars)
104 for (
const auto & svariable : coupled_scalar_vars)
108 const unsigned int svar_num = svariable->number();
141 std::array<MType, 3> mortar_types = {{MType::Secondary, MType::Primary, MType::Lower}};
144 for (
const auto & it : ce)
149 const unsigned int ivar_num = ivariable.
number();
150 const unsigned int jvar_num = jvariable.
number();
156 std::array<size_t, 3> shape_space_sizes{{jvariable.
dofIndices().size(),
159 std::array<const VariablePhiValue *, 3> phis;
160 std::array<const VariablePhiGradient *, 3> grad_phis;
161 std::array<const VectorVariablePhiValue *, 3> vector_phis;
162 std::array<const VectorVariablePhiGradient *, 3> vector_grad_phis;
165 const auto & temp_var = cast_ref<MooseVariableFE<RealVectorValue> &>(jvariable);
166 vector_phis = {{&temp_var.phiFace(), &temp_var.phiFaceNeighbor(), &temp_var.phiLower()}};
168 {&temp_var.gradPhiFace(), &temp_var.gradPhiFaceNeighbor(), &temp_var.gradPhiLower()}};
172 const auto & temp_var = cast_ref<MooseVariableFE<Real> &>(jvariable);
173 phis = {{&temp_var.phiFace(), &temp_var.phiFaceNeighbor(), &temp_var.phiLower()}};
175 {&temp_var.gradPhiFace(), &temp_var.gradPhiFaceNeighbor(), &temp_var.gradPhiLower()}};
179 for (MooseIndex(3) type_index = 0; type_index < 3; ++type_index)
181 const auto mortar_type = mortar_types[type_index];
182 const auto shape_space_size = shape_space_sizes[type_index];
183 std::vector<dof_id_type> dof_indices;
186 case MType::Secondary:
207 _phi = phis[type_index];
219 for (
_j = 0;
_j < shape_space_size;
_j++)
238 unsigned int test_space_size = 0;
239 std::vector<dof_id_type> dof_indices;
240 Real scaling_factor = 1;
256 mooseAssert(
_var,
"LM variable is null");
257 test_space_size =
_test.size();
265 const unsigned int s_order = svar.
order();
273 for (
_h = 0;
_h < s_order;
_h++)
274 for (
_i = 0;
_i < test_space_size;
_i++)
290 const unsigned int s_order = svar.
order();
297 for (
_l = 0;
_l < s_order;
_l++)
const std::vector< std::pair< MooseVariableScalar *, MooseVariableFieldBase * > > & scalarFieldCouplingEntries() const
bool areCoupled(const unsigned int ivar, const unsigned int jvar, const unsigned int nl_sys_num) 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.
const std::vector< dof_id_type > & dofIndicesLower() const final
Get dof indices for the current lower dimensional element (this is meaningful when performing mortar ...
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.
FEProblemBase & _fe_problem
Reference to the finite element problem.
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.
unsigned int number() const
Gets the number of this system.
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