Line data Source code
1 : //* This file is part of the MOOSE framework 2 : //* https://mooseframework.inl.gov 3 : //* 4 : //* All rights reserved, see COPYRIGHT for full restrictions 5 : //* https://github.com/idaholab/moose/blob/master/COPYRIGHT 6 : //* 7 : //* Licensed under LGPL 2.1, please see LICENSE for details 8 : //* https://www.gnu.org/licenses/lgpl-2.1.html 9 : 10 : #pragma once 11 : 12 : #include "ADMortarConstraint.h" 13 : 14 : /** 15 : * This Constraint adds standardized methods for assembling to a primary 16 : * scalar variable associated with the major variables of the Mortar 17 : * Constraint object. Essentially, the entire row of the residual and Jacobian 18 : * associated with this scalar variable will also be assembled here 19 : * using the loops over mortar segments. 20 : * This variable is "scalar_variable" in the input file and "kappa" 21 : * within the source code. 22 : */ 23 : class ADMortarScalarBase : public ADMortarConstraint 24 : { 25 : public: 26 : static InputParameters validParams(); 27 : 28 : ADMortarScalarBase(const InputParameters & parameters); 29 : 30 : // Using declarations necessary to pull in computeResidual with different parameter list and avoid 31 : // hidden method warning 32 : using ADMortarConstraint::computeResidual; 33 : 34 : // Using declarations necessary to pull in computeJacobian with different parameter list and avoid 35 : // hidden method warning 36 : using ADMortarConstraint::computeJacobian; 37 : 38 : /** 39 : * The scalar variable that this kernel operates on. 40 : */ 41 : const MooseVariableScalar & scalarVariable() const 42 : { 43 : mooseAssert(_kappa_var_ptr, "kappa pointer should have been set in the constructor"); 44 : return *_kappa_var_ptr; 45 : } 46 : 47 : /** 48 : * Computes _var-residuals as well as _kappa-residual 49 : */ 50 : virtual void computeResidual() override; 51 : /** 52 : * Computes d-_var-residual / d-_var and d-_var-residual / d-jvar, 53 : * as well as d-_kappa-residual / d-_var and d-_kappa-residual / d-jvar 54 : */ 55 : virtual void computeJacobian() override; 56 : 57 : protected: 58 : /** 59 : * Method for computing the scalar part of residual at quadrature points 60 : */ 61 : virtual ADReal computeScalarQpResidual(); 62 : 63 : /** 64 : * Put necessary evaluations depending on qp but independent of test functions here 65 : */ 66 24312 : virtual void initScalarQpResidual() {} 67 : 68 : /// Whether a scalar variable is declared for this constraint 69 : const bool _use_scalar; 70 : 71 : /// Whether to compute scalar contributions for this instance 72 : const bool _compute_scalar_residuals; 73 : 74 : /// (Pointer to) Scalar variable this kernel operates on 75 : const MooseVariableScalar * const _kappa_var_ptr; 76 : 77 : /// The unknown scalar variable ID 78 : const unsigned int _kappa_var; 79 : 80 : /// Order of the scalar variable, used in several places 81 : const unsigned int _k_order; 82 : 83 : /// Reference to the current solution at the current quadrature point 84 : const ADVariableValue & _kappa; 85 : 86 : /// Used internally to iterate over each scalar component 87 : unsigned int _h; 88 : }; 89 : 90 : inline ADReal 91 0 : ADMortarScalarBase::computeScalarQpResidual() 92 : { 93 0 : mooseError( 94 : "A scalar_variable has been set and compute_scalar_residuals=true, ", 95 : "but the computeScalarQpResidual method was not overridden. Accidental call of base class?"); 96 : return 0; 97 : }