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

SwitchingFunctionPenalty is a constraint kernel adds a penalty to each order parameter to enforce \( \sum_n h_i(\eta_i) \equiv 1 \). More...

#include <SwitchingFunctionPenalty.h>

Inheritance diagram for SwitchingFunctionPenalty:
[legend]

Public Member Functions

 SwitchingFunctionPenalty (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 MaterialProperty< Real > * _d2h
 
const Real _penalty
 Penalty pre-factor. More...
 
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...
 
int _a
 Index of the eta this kernel is operating on. More...
 

Detailed Description

SwitchingFunctionPenalty is a constraint kernel adds a penalty to each order parameter to enforce \( \sum_n h_i(\eta_i) \equiv 1 \).

Definition at line 24 of file SwitchingFunctionPenalty.h.

Constructor & Destructor Documentation

SwitchingFunctionPenalty::SwitchingFunctionPenalty ( const InputParameters &  parameters)

Definition at line 23 of file SwitchingFunctionPenalty.C.

24  : DerivativeMaterialInterface<Kernel>(parameters),
25  _h_names(getParam<std::vector<MaterialPropertyName>>("h_names")),
26  _num_h(_h_names.size()),
27  _h(_num_h),
28  _dh(_num_h),
29  _penalty(getParam<Real>("penalty")),
30  _number_of_nl_variables(_fe_problem.getNonlinearSystemBase().nVariables()),
32  _a(-1)
33 {
34  // parameter check. We need exactly one eta per h
35  if (_num_h != coupledComponents("etas"))
36  mooseError("Need to pass in as many h_names as etas in SwitchingFunctionPenalty kernel ",
37  name());
38 
39  // fetch switching functions (for the residual) and h derivatives (for the Jacobian)
40  for (unsigned int i = 0; i < _num_h; ++i)
41  {
42  _h[i] = &getMaterialPropertyByName<Real>(_h_names[i]);
43  _dh[i] = &getMaterialPropertyDerivative<Real>(_h_names[i], getVar("etas", i)->name());
44 
45  // generate the lookup table from j_var -> eta index
46  unsigned int num = coupled("etas", i);
47  if (num < _number_of_nl_variables)
48  _j_eta[num] = i;
49 
50  // figure out which variable this kernel is acting on
51  if (num == _var.number())
52  _a = i;
53  }
54 
55  if (_a < 0)
56  mooseError("Kernel variable must be listed in etas for SwitchingFunctionPenalty kernel ",
57  name());
58 
59  _d2h = &getMaterialPropertyDerivative<Real>(_h_names[_a], _var.name(), _var.name());
60 }
const unsigned int _number_of_nl_variables
number of non-linear variables in the problem
std::vector< const MaterialProperty< Real > * > _h
Switching functions and their drivatives.
std::vector< int > _j_eta
eta index for the j_vars in the jacobian computation
std::vector< MaterialPropertyName > _h_names
Switching function names.
const Real _penalty
Penalty pre-factor.
std::vector< const MaterialProperty< Real > * > _dh
int _a
Index of the eta this kernel is operating on.
const MaterialProperty< Real > * _d2h

Member Function Documentation

Real SwitchingFunctionPenalty::computeQpJacobian ( )
protectedvirtual

Definition at line 73 of file SwitchingFunctionPenalty.C.

74 {
75  Real g = -1.0;
76  for (unsigned int i = 0; i < _num_h; ++i)
77  g += (*_h[i])[_qp];
78 
79  return _test[_i][_qp] * _penalty * _phi[_j][_qp] * 2.0 *
80  ((*_dh[_a])[_qp] * (*_dh[_a])[_qp] + g * (*_d2h)[_qp]);
81 }
std::vector< const MaterialProperty< Real > * > _h
Switching functions and their drivatives.
const Real _penalty
Penalty pre-factor.
std::vector< const MaterialProperty< Real > * > _dh
int _a
Index of the eta this kernel is operating on.
Real SwitchingFunctionPenalty::computeQpOffDiagJacobian ( unsigned int  j_var)
protectedvirtual

Definition at line 84 of file SwitchingFunctionPenalty.C.

85 {
86  const int eta = _j_eta[j_var];
87 
88  if (eta >= 0)
89  return _test[_i][_qp] * _penalty * _phi[_j][_qp] * 2.0 * (*_dh[eta])[_qp] * (*_dh[_a])[_qp];
90  else
91  return 0.0;
92 }
std::vector< int > _j_eta
eta index for the j_vars in the jacobian computation
const Real _penalty
Penalty pre-factor.
std::vector< const MaterialProperty< Real > * > _dh
int _a
Index of the eta this kernel is operating on.
Real SwitchingFunctionPenalty::computeQpResidual ( )
protectedvirtual

Definition at line 63 of file SwitchingFunctionPenalty.C.

64 {
65  Real g = -1.0;
66  for (unsigned int i = 0; i < _num_h; ++i)
67  g += (*_h[i])[_qp];
68 
69  return _test[_i][_qp] * _penalty * 2.0 * g * (*_dh[_a])[_qp];
70 }
std::vector< const MaterialProperty< Real > * > _h
Switching functions and their drivatives.
const Real _penalty
Penalty pre-factor.
std::vector< const MaterialProperty< Real > * > _dh
int _a
Index of the eta this kernel is operating on.

Member Data Documentation

int SwitchingFunctionPenalty::_a
protected

Index of the eta this kernel is operating on.

Definition at line 52 of file SwitchingFunctionPenalty.h.

Referenced by computeQpJacobian(), computeQpOffDiagJacobian(), computeQpResidual(), and SwitchingFunctionPenalty().

const MaterialProperty<Real>* SwitchingFunctionPenalty::_d2h
protected

Definition at line 40 of file SwitchingFunctionPenalty.h.

Referenced by SwitchingFunctionPenalty().

std::vector<const MaterialProperty<Real> *> SwitchingFunctionPenalty::_dh
protected
std::vector<const MaterialProperty<Real> *> SwitchingFunctionPenalty::_h
protected

Switching functions and their drivatives.

Definition at line 39 of file SwitchingFunctionPenalty.h.

Referenced by computeQpJacobian(), computeQpResidual(), and SwitchingFunctionPenalty().

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

Switching function names.

Definition at line 35 of file SwitchingFunctionPenalty.h.

Referenced by SwitchingFunctionPenalty().

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

eta index for the j_vars in the jacobian computation

Definition at line 49 of file SwitchingFunctionPenalty.h.

Referenced by computeQpOffDiagJacobian(), and SwitchingFunctionPenalty().

unsigned int SwitchingFunctionPenalty::_num_h
protected
const unsigned int SwitchingFunctionPenalty::_number_of_nl_variables
protected

number of non-linear variables in the problem

Definition at line 46 of file SwitchingFunctionPenalty.h.

Referenced by SwitchingFunctionPenalty().

const Real SwitchingFunctionPenalty::_penalty
protected

Penalty pre-factor.

Definition at line 43 of file SwitchingFunctionPenalty.h.

Referenced by computeQpJacobian(), computeQpOffDiagJacobian(), and computeQpResidual().


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