https://mooseframework.inl.gov
PeriodicSegmentalConstraint.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  "PeriodicSegmentalConstraint enforces macro-micro periodic conditions between "
20  "secondary and primary sides of a mortar interface using Lagrange multipliers."
21  "Must be used alongside EqualValueConstraint.");
22  params.renameCoupledVar("scalar_variable", "epsilon", "Primary coupled scalar variable");
23  params.addRequiredCoupledVar("sigma", "Controlled scalar averaging variable");
24 
25  return params;
26 }
27 
30  _kappa_aux_ptr(getScalarVar("sigma", 0)),
31  _ka_order(_kappa_aux_ptr->order()),
32  _kappa_aux(coupledScalarValue("sigma"))
33 {
35  paramError("sigma",
36  "Must assign auxiliary scalar variable to sigma, rather than nonlinear variable");
37 }
38 
39 Real
41 {
43  RealVectorValue kappa_vec(_kappa[0], 0, 0);
44  if (_k_order == 2)
45  kappa_vec(1) = _kappa[1];
46  else if (_k_order == 3)
47  {
48  kappa_vec(1) = _kappa[1];
49  kappa_vec(2) = _kappa[2];
50  }
51  Real r = -(kappa_vec * dx);
52 
53  switch (mortar_type)
54  {
56  r *= _test[_i][_qp];
57  break;
58  default:
59  return 0;
60  }
61  return r;
62 }
63 
64 Real
66 {
67  // Stability/penalty term for residual of scalar variable
69  Real r = -dx(_h) * _lambda[_qp];
70 
71  RealVectorValue kappa_aux_vec(_kappa_aux[0], 0, 0);
72  if (_k_order == 2)
73  {
74  kappa_aux_vec(1) = _kappa_aux[1];
75  }
76  else if (_k_order == 3)
77  {
78  kappa_aux_vec(1) = _kappa_aux[1];
79  kappa_aux_vec(2) = _kappa_aux[2];
80  }
81 
82  r -= dx(_h) * (kappa_aux_vec * _normals[_qp]);
83 
84  return r;
85 }
86 
87 Real
89  const unsigned int svar_num)
90 {
91  if (svar_num != _kappa_var)
92  return 0;
93 
94  // Stability/penalty term for Jacobian
96  Real jac = -dx(_h);
97 
98  switch (mortar_type)
99  {
100  case Moose::MortarType::Lower: // Residual_sign -1 ddeltaU_ddisp sign 1;
101  jac *= _test[_i][_qp];
102  break;
103  default:
104  return 0;
105  }
106  return jac;
107 }
108 
109 Real
111  const unsigned int jvar_num)
112 {
113  // Test if jvar is the ID of the primary variables and not some other random variable
114  switch (mortar_type)
115  {
117  if (!_var || _var->number() != jvar_num)
118  return 0;
119  break;
120  default:
121  return 0;
122  }
123 
124  // Stability/penalty term for Jacobian
126  Real jac = -dx(_h);
127 
128  switch (mortar_type)
129  {
131  jac *= (*_phi)[_j][_qp];
132  break;
133  default:
134  return 0;
135  }
136  return jac;
137 }
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
const VariableValue & _lambda
The LM solution.
virtual Real computeScalarQpOffDiagJacobian(Moose::MortarType mortar_type, const unsigned int jvar) override
Method for computing d-_kappa-residual / d-_var at quadrature points.
virtual Real computeScalarQpResidual() override
Method for computing the scalar part of residual at quadrature points.
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
unsigned int _h
Used internally to iterate over each scalar component.
const VariableTestValue & _test
The shape functions corresponding to the lagrange multiplier variable.
unsigned int _j
Definition: Constraint.h:35
registerMooseObject("MooseApp", PeriodicSegmentalConstraint)
This class enforces a periodic boundary condition between a microscale and macroscale field...
const unsigned int _kappa_var
The unknown scalar variable ID.
std::vector< Point > _normals
the normals
static InputParameters validParams()
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.
virtual Real computeQpOffDiagJacobianScalar(Moose::MortarType mortar_type, const unsigned int jvar) override
Method for computing d-_var-residual / d-_kappa at quadrature points.
MooseVariable *const _var
Pointer to the lagrange multipler variable. nullptr if none.
const MooseVariableScalar *const _kappa_aux_ptr
(Pointer to) the controlled scalar variable
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.
PeriodicSegmentalConstraint(const InputParameters &parameters)
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...
const VariableValue & _kappa_aux
The controlled scalar variable.
This Constraint adds standardized methods for assembling to a primary scalar variable associated with...
const VariableValue & _kappa
Reference to the current solution at the current quadrature point.
unsigned int _qp
Definition: Constraint.h:36