https://mooseframework.inl.gov
PenaltyPeriodicSegmentalConstraint.C
Go to the documentation of this file.
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 
11 
13 
16 {
18  params.addClassDescription(
19  "PenaltyPeriodicSegmentalConstraint enforces macro-micro periodic conditions between "
20  "secondary and primary sides of a mortar interface using a penalty approach "
21  "(no Lagrange multipliers needed). Must be used alongside PenaltyEqualValueConstraint.");
22  params.renameCoupledVar("scalar_variable", "epsilon", "Primary coupled scalar variable");
23  params.addRequiredCoupledVar("sigma", "Controlled scalar averaging variable");
24  params.addParam<Real>(
25  "penalty_value",
26  1.0,
27  "Penalty value used to impose a generalized force capturing the mortar constraint equation");
28 
29  return params;
30 }
31 
33  const InputParameters & parameters)
35  _temp_jump_global(),
36  _tau_s(),
37  _kappa_aux_ptr(getScalarVar("sigma", 0)),
38  _ka_order(_kappa_aux_ptr->order()),
39  _kappa_aux(coupledScalarValue("sigma")),
40  _pen_scale(getParam<Real>("penalty_value"))
41 {
43  paramError("sigma",
44  "Must assign auxiliary scalar variable to sigma, rather than nonlinear variable");
45 }
46 
47 // Compute the stability parameters to use for all quadrature points
48 void
50 {
52 }
53 void
55 {
57 }
58 
59 // Compute the temperature jump for current quadrature point
60 void
62 {
64 }
65 
66 Real
68 {
69  // Compute penalty parameter times x-jump times average heat flux
71  RealVectorValue kappa_vec(_kappa[0], 0, 0);
72  if (_k_order == 2)
73  kappa_vec(1) = _kappa[1];
74  else if (_k_order == 3)
75  {
76  kappa_vec(1) = _kappa[1];
77  kappa_vec(2) = _kappa[2];
78  }
79  Real r = _tau_s * (kappa_vec * dx);
80 
81  switch (mortar_type)
82  {
84  r *= _test_secondary[_i][_qp];
85  break;
87  r *= -_test_primary[_i][_qp];
88  break;
90  return 0;
91  default:
92  return 0;
93  }
94  return r;
95 }
96 
97 Real
99 {
100  // Stability/penalty term for residual of scalar variable
103 
104  r *= -dx(_h);
105 
106  RealVectorValue kappa_vec(_kappa[0], 0, 0);
107  RealVectorValue kappa_aux_vec(_kappa_aux[0], 0, 0);
108  if (_k_order == 2)
109  {
110  kappa_vec(1) = _kappa[1];
111  kappa_aux_vec(1) = _kappa_aux[1];
112  }
113  else if (_k_order == 3)
114  {
115  kappa_vec(1) = _kappa[1];
116  kappa_vec(2) = _kappa[2];
117  kappa_aux_vec(1) = _kappa_aux[1];
118  kappa_aux_vec(2) = _kappa_aux[2];
119  }
120 
121  r += dx(_h) * _tau_s * (kappa_vec * dx);
122  r -= dx(_h) * (kappa_aux_vec * _normals[_qp]);
123 
124  return r;
125 }
126 
127 Real
129 {
130  // Stability/penalty term for Jacobian of scalar variable
132 
133  Real jac = dx(_h) * _tau_s * dx(_l);
134 
135  return jac;
136 }
137 
138 Real
140  const Moose::MortarType mortar_type, const unsigned int svar_num)
141 {
142  if (svar_num != _kappa_var)
143  return 0;
144 
145  // Stability/penalty term for Jacobian
147  Real jac = _tau_s;
148 
149  switch (mortar_type)
150  {
151 
152  case Moose::MortarType::Secondary: // Residual_sign -1 ddeltaU_ddisp sign 1;
153  jac *= _test_secondary[_i][_qp] * dx(_h);
154  break;
155  case Moose::MortarType::Primary: // Residual_sign -1 ddeltaU_ddisp sign -1;
156  jac *= -_test_primary[_i][_qp] * dx(_h);
157  break;
158 
159  default:
160  return 0;
161  }
162  return jac;
163 }
164 
165 Real
167  const Moose::MortarType mortar_type, const unsigned int jvar_num)
168 {
169  // Test if jvar is the ID of the primary variables and not some other random variable
170  switch (mortar_type)
171  {
173  if (jvar_num != _secondary_var.number())
174  return 0;
175  break;
177  if (jvar_num != _primary_var.number())
178  return 0;
179  break;
180  default:
181  return 0;
182  }
183 
184  // Stability/penalty term for Jacobian
186  Real jac = _tau_s;
187 
188  switch (mortar_type)
189  {
191  jac *= (*_phi)[_j][_qp] * dx(_h);
192  break;
194  jac *= -(*_phi)[_j][_qp] * dx(_h);
195  break;
196 
197  default:
198  return 0;
199  }
200  return jac;
201 }
202 
203 void
205 {
206  // Example showing how the penalty could be loaded from some function
207  _tau_s = _pen_scale;
208 }
209 
210 // Compute temperature jump and flux average/jump
211 void
213 {
215 }
const Real _pen_scale
Input property from user as the value of the penalty parameter.
MooseVariableField< Real > & _secondary_var
Reference to the secondary variable.
This class enforces a periodic boundary condition between a microscale and macroscale field...
virtual Real computeQpOffDiagJacobianScalar(Moose::MortarType mortar_type, const unsigned int jvar) override
Method for computing d-_var-residual / d-_kappa at quadrature points.
const VariableTestValue & _test_secondary
The shape functions corresponding to the secondary interior primal variable.
virtual void initScalarQpResidual() override
Put necessary evaluations depending on qp but independent of test functions here. ...
static InputParameters validParams()
void paramError(const std::string &param, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
Definition: MooseBase.h:435
unsigned int number() const
Get variable number coming from libMesh.
MortarType
Definition: MooseTypes.h:771
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
void renameCoupledVar(const std::string &old_name, const std::string &new_name, const std::string &new_docstring)
Rename a coupled variable and provide a new documentation string.
const MooseArray< Point > & _phys_points_primary
The locations of the quadrature points on the interior primary elements.
unsigned int _i
Definition: Constraint.h:35
Real _tau_s
The stability parameter for the method.
unsigned int _h
Used internally to iterate over each scalar component.
const VariableValue & _u_secondary
The primal solution on the secondary side.
virtual Real computeScalarQpResidual() override
Method for computing the scalar part of residual at quadrature points.
unsigned int _j
Definition: Constraint.h:35
PenaltyPeriodicSegmentalConstraint(const InputParameters &parameters)
registerMooseObject("MooseApp", PenaltyPeriodicSegmentalConstraint)
const unsigned int _kappa_var
The unknown scalar variable ID.
std::vector< Point > _normals
the normals
const MooseArray< Point > & _phys_points_secondary
The locations of the quadrature points on the interior secondary elements.
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
This method adds a coupled variable name pair.
const VariableValue & _u_primary
The primal solution on the primary side.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Interface class ("Veneer") to provide generator methods for derivative material property names...
Moose::VarKindType kind() const
Kind of the variable (Nonlinear, Auxiliary, ...)
const unsigned int _k_order
Order of the scalar variable, used in several places.
virtual Real computeQpResidual(Moose::MortarType mortar_type) override
Method for computing the residual at quadrature points.
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump...
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object...
Real _temp_jump_global
the temperature jump in global and interface coordinates; TM-analogy: _displacement_jump_global, _interface_displacement_jump
virtual Real computeScalarQpOffDiagJacobian(Moose::MortarType mortar_type, const unsigned int jvar) override
Method for computing d-_kappa-residual / d-_var at quadrature points.
const MooseVariableScalar *const _kappa_aux_ptr
(Pointer to) the controlled scalar variable
This Constraint adds standardized methods for assembling to a primary scalar variable associated with...
const VariableValue & _kappa_aux
The controlled scalar variable.
const VariableValue & _kappa
Reference to the current solution at the current quadrature point.
const VariableTestValue & _test_primary
The shape functions corresponding to the primary interior primal variable.
virtual Real computeScalarQpJacobian() override
Method for computing the scalar variable part of Jacobian at quadrature points.
unsigned int _qp
Definition: Constraint.h:36
MooseVariableField< Real > & _primary_var
Reference to the primary variable.