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 25 of file SwitchingFunctionConstraintLagrange.h.

Constructor & Destructor Documentation

SwitchingFunctionConstraintLagrange::SwitchingFunctionConstraintLagrange ( const InputParameters &  parameters)

Definition at line 24 of file SwitchingFunctionConstraintLagrange.C.

26  : DerivativeMaterialInterface<Kernel>(parameters),
27  _h_names(getParam<std::vector<MaterialPropertyName>>("h_names")),
28  _num_h(_h_names.size()),
29  _h(_num_h),
30  _dh(_num_h),
31  _number_of_nl_variables(_fe_problem.getNonlinearSystemBase().nVariables()),
33  _epsilon(getParam<Real>("epsilon"))
34 {
35  // parameter check. We need exactly one eta per h
36  if (_num_h != coupledComponents("etas"))
37  mooseError(
38  "Need to pass in as many h_names as etas in SwitchingFunctionConstraintLagrange kernel ",
39  name());
40 
41  // fetch switching functions (for the residual) and h derivatives (for the Jacobian)
42  for (unsigned int i = 0; i < _num_h; ++i)
43  {
44  _h[i] = &getMaterialPropertyByName<Real>(_h_names[i]);
45  _dh[i] = &getMaterialPropertyDerivative<Real>(_h_names[i], getVar("etas", i)->name());
46 
47  // generate the lookup table from j_var -> eta index
48  unsigned int num = coupled("etas", i);
49  if (num < _number_of_nl_variables)
50  _j_eta[num] = i;
51  }
52 }
const unsigned int _number_of_nl_variables
number of non-linear variables in the problem
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

Real SwitchingFunctionConstraintLagrange::computeQpJacobian ( )
protectedvirtual

Definition at line 65 of file SwitchingFunctionConstraintLagrange.C.

66 {
67  return _test[_i][_qp] * -_epsilon * _phi[_j][_qp];
68 }
Real SwitchingFunctionConstraintLagrange::computeQpOffDiagJacobian ( unsigned int  j_var)
protectedvirtual

Definition at line 71 of file SwitchingFunctionConstraintLagrange.C.

72 {
73  const int eta = _j_eta[j_var];
74 
75  if (eta >= 0)
76  return (*_dh[eta])[_qp] * _phi[_j][_qp] * _test[_i][_qp];
77  else
78  return 0.0;
79 }
std::vector< const MaterialProperty< Real > * > _dh
std::vector< int > _j_eta
eta index for the j_vars in the jacobian computation
Real SwitchingFunctionConstraintLagrange::computeQpResidual ( )
protectedvirtual

Definition at line 55 of file SwitchingFunctionConstraintLagrange.C.

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

Member Data Documentation

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

shift factor

Definition at line 49 of file SwitchingFunctionConstraintLagrange.h.

Referenced by computeQpJacobian(), and computeQpResidual().

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

Switching functions and their drivatives.

Definition at line 40 of file SwitchingFunctionConstraintLagrange.h.

Referenced by computeQpResidual(), and SwitchingFunctionConstraintLagrange().

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

Switching function names.

Definition at line 36 of file SwitchingFunctionConstraintLagrange.h.

Referenced by SwitchingFunctionConstraintLagrange().

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

eta index for the j_vars in the jacobian computation

Definition at line 46 of file SwitchingFunctionConstraintLagrange.h.

Referenced by computeQpOffDiagJacobian(), and SwitchingFunctionConstraintLagrange().

unsigned int SwitchingFunctionConstraintLagrange::_num_h
protected
const unsigned int SwitchingFunctionConstraintLagrange::_number_of_nl_variables
protected

number of non-linear variables in the problem

Definition at line 43 of file SwitchingFunctionConstraintLagrange.h.

Referenced by SwitchingFunctionConstraintLagrange().


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