www.mooseframework.org
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
SwitchingFunctionConstraintLagrange Class Reference

SwitchingFunctionConstraintLagrange is a constraint kernel that acts on the lambda lagrange multiplier non-linear variables to enforce \( \sum_n h_i(\eta_i) - \epsilon\lambda \equiv 1 \). More...

#include <SwitchingFunctionConstraintLagrange.h>

Inheritance diagram for SwitchingFunctionConstraintLagrange:
[legend]

Public Member Functions

 SwitchingFunctionConstraintLagrange (const InputParameters &parameters)
 

Protected Member Functions

virtual Real computeQpResidual ()
 
virtual Real computeQpJacobian ()
 
virtual Real computeQpOffDiagJacobian (unsigned int)
 

Protected Attributes

std::vector< MaterialPropertyName > _h_names
 Switching function names. More...
 
unsigned int _num_h
 
std::vector< const MaterialProperty< Real > * > _h
 Switching functions and their drivatives. More...
 
std::vector< const MaterialProperty< Real > * > _dh
 
const unsigned int _number_of_nl_variables
 number of non-linear variables in the problem More...
 
std::vector< int > _j_eta
 eta index for the j_vars in the jacobian computation More...
 
Real _epsilon
 shift factor More...
 

Detailed Description

SwitchingFunctionConstraintLagrange is a constraint kernel that acts on the lambda lagrange multiplier non-linear variables to enforce \( \sum_n h_i(\eta_i) - \epsilon\lambda \equiv 1 \).

Definition at line 28 of file SwitchingFunctionConstraintLagrange.h.

Constructor & Destructor Documentation

◆ SwitchingFunctionConstraintLagrange()

SwitchingFunctionConstraintLagrange::SwitchingFunctionConstraintLagrange ( const InputParameters &  parameters)

Definition at line 29 of file SwitchingFunctionConstraintLagrange.C.

31  : DerivativeMaterialInterface<Kernel>(parameters),
32  _h_names(getParam<std::vector<MaterialPropertyName>>("h_names")),
33  _num_h(_h_names.size()),
34  _h(_num_h),
35  _dh(_num_h),
36  _number_of_nl_variables(_fe_problem.getNonlinearSystemBase().nVariables()),
38  _epsilon(getParam<Real>("epsilon"))
39 {
40  // parameter check. We need exactly one eta per h
41  if (_num_h != coupledComponents("etas"))
42  mooseError(
43  "Need to pass in as many h_names as etas in SwitchingFunctionConstraintLagrange kernel ",
44  name());
45 
46  // fetch switching functions (for the residual) and h derivatives (for the Jacobian)
47  for (unsigned int i = 0; i < _num_h; ++i)
48  {
49  _h[i] = &getMaterialPropertyByName<Real>(_h_names[i]);
50  _dh[i] = &getMaterialPropertyDerivative<Real>(_h_names[i], getVar("etas", i)->name());
51 
52  // generate the lookup table from j_var -> eta index
53  unsigned int num = coupled("etas", i);
54  if (num < _number_of_nl_variables)
55  _j_eta[num] = i;
56  }
57 }
const unsigned int _number_of_nl_variables
number of non-linear variables in the problem
const std::string name
Definition: Setup.h:22
std::vector< const MaterialProperty< Real > * > _dh
std::vector< int > _j_eta
eta index for the j_vars in the jacobian computation
std::vector< MaterialPropertyName > _h_names
Switching function names.
std::vector< const MaterialProperty< Real > * > _h
Switching functions and their drivatives.

Member Function Documentation

◆ computeQpJacobian()

Real SwitchingFunctionConstraintLagrange::computeQpJacobian ( )
protectedvirtual

Definition at line 70 of file SwitchingFunctionConstraintLagrange.C.

71 {
72  return _test[_i][_qp] * -_epsilon * _phi[_j][_qp];
73 }

◆ computeQpOffDiagJacobian()

Real SwitchingFunctionConstraintLagrange::computeQpOffDiagJacobian ( unsigned int  j_var)
protectedvirtual

Definition at line 76 of file SwitchingFunctionConstraintLagrange.C.

77 {
78  const int eta = _j_eta[j_var];
79 
80  if (eta >= 0)
81  return (*_dh[eta])[_qp] * _phi[_j][_qp] * _test[_i][_qp];
82  else
83  return 0.0;
84 }
std::vector< const MaterialProperty< Real > * > _dh
std::vector< int > _j_eta
eta index for the j_vars in the jacobian computation

◆ computeQpResidual()

Real SwitchingFunctionConstraintLagrange::computeQpResidual ( )
protectedvirtual

Definition at line 60 of file SwitchingFunctionConstraintLagrange.C.

61 {
62  Real g = -_epsilon * _u[_qp] - 1.0;
63  for (unsigned int i = 0; i < _num_h; ++i)
64  g += (*_h[i])[_qp];
65 
66  return _test[_i][_qp] * g;
67 }
std::vector< const MaterialProperty< Real > * > _h
Switching functions and their drivatives.

Member Data Documentation

◆ _dh

std::vector<const MaterialProperty<Real> *> SwitchingFunctionConstraintLagrange::_dh
protected

◆ _epsilon

Real SwitchingFunctionConstraintLagrange::_epsilon
protected

shift factor

Definition at line 52 of file SwitchingFunctionConstraintLagrange.h.

Referenced by computeQpJacobian(), and computeQpResidual().

◆ _h

std::vector<const MaterialProperty<Real> *> SwitchingFunctionConstraintLagrange::_h
protected

Switching functions and their drivatives.

Definition at line 43 of file SwitchingFunctionConstraintLagrange.h.

Referenced by computeQpResidual(), and SwitchingFunctionConstraintLagrange().

◆ _h_names

std::vector<MaterialPropertyName> SwitchingFunctionConstraintLagrange::_h_names
protected

Switching function names.

Definition at line 39 of file SwitchingFunctionConstraintLagrange.h.

Referenced by SwitchingFunctionConstraintLagrange().

◆ _j_eta

std::vector<int> SwitchingFunctionConstraintLagrange::_j_eta
protected

eta index for the j_vars in the jacobian computation

Definition at line 49 of file SwitchingFunctionConstraintLagrange.h.

Referenced by computeQpOffDiagJacobian(), and SwitchingFunctionConstraintLagrange().

◆ _num_h

unsigned int SwitchingFunctionConstraintLagrange::_num_h
protected

◆ _number_of_nl_variables

const unsigned int SwitchingFunctionConstraintLagrange::_number_of_nl_variables
protected

number of non-linear variables in the problem

Definition at line 46 of file SwitchingFunctionConstraintLagrange.h.

Referenced by SwitchingFunctionConstraintLagrange().


The documentation for this class was generated from the following files: