www.mooseframework.org
Public Types | Public Member Functions | Static 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 Types

typedef DerivativeMaterialPropertyNameInterface::SymbolName SymbolName
 

Public Member Functions

 SwitchingFunctionPenalty (const InputParameters &parameters)
 
const GenericMaterialProperty< U, is_ad > & getDefaultMaterialProperty (const std::string &name)
 
const GenericMaterialProperty< U, is_ad > & getDefaultMaterialPropertyByName (const std::string &name)
 
void validateDerivativeMaterialPropertyBase (const std::string &base)
 
const MaterialPropertyName derivativePropertyName (const MaterialPropertyName &base, const std::vector< SymbolName > &c) const
 
const MaterialPropertyName derivativePropertyNameFirst (const MaterialPropertyName &base, const SymbolName &c1) const
 
const MaterialPropertyName derivativePropertyNameSecond (const MaterialPropertyName &base, const SymbolName &c1, const SymbolName &c2) const
 
const MaterialPropertyName derivativePropertyNameThird (const MaterialPropertyName &base, const SymbolName &c1, const SymbolName &c2, const SymbolName &c3) const
 
GenericMaterialProperty< U, is_ad > & declarePropertyDerivative (const std::string &base, const std::vector< VariableName > &c)
 
GenericMaterialProperty< U, is_ad > & declarePropertyDerivative (const std::string &base, const std::vector< SymbolName > &c)
 
GenericMaterialProperty< U, is_ad > & declarePropertyDerivative (const std::string &base, const SymbolName &c1, const SymbolName &c2="", const SymbolName &c3="")
 
GenericMaterialProperty< U, is_ad > & declarePropertyDerivative (const std::string &base, const std::vector< VariableName > &c)
 
GenericMaterialProperty< U, is_ad > & declarePropertyDerivative (const std::string &base, const std::vector< SymbolName > &c)
 
GenericMaterialProperty< U, is_ad > & declarePropertyDerivative (const std::string &base, const SymbolName &c1, const SymbolName &c2="", const SymbolName &c3="")
 
const GenericMaterialProperty< U, is_ad > & getMaterialPropertyDerivative (const std::string &base, const std::vector< VariableName > &c)
 
const GenericMaterialProperty< U, is_ad > & getMaterialPropertyDerivative (const std::string &base, const std::vector< SymbolName > &c)
 
const GenericMaterialProperty< U, is_ad > & getMaterialPropertyDerivative (const std::string &base, const SymbolName &c1, const SymbolName &c2="", const SymbolName &c3="")
 
const GenericMaterialProperty< U, is_ad > & getMaterialPropertyDerivative (const std::string &base, const SymbolName &c1, unsigned int v2, unsigned int v3=libMesh::invalid_uint)
 
const GenericMaterialProperty< U, is_ad > & getMaterialPropertyDerivative (const std::string &base, unsigned int v1, unsigned int v2=libMesh::invalid_uint, unsigned int v3=libMesh::invalid_uint)
 
const GenericMaterialProperty< U, is_ad > & getMaterialPropertyDerivative (const std::string &base, const std::vector< VariableName > &c)
 
const GenericMaterialProperty< U, is_ad > & getMaterialPropertyDerivative (const std::string &base, const std::vector< SymbolName > &c)
 
const GenericMaterialProperty< U, is_ad > & getMaterialPropertyDerivative (const std::string &base, const SymbolName &c1, const SymbolName &c2="", const SymbolName &c3="")
 
const GenericMaterialProperty< U, is_ad > & getMaterialPropertyDerivative (const std::string &base, const SymbolName &c1, unsigned int v2, unsigned int v3=libMesh::invalid_uint)
 
const GenericMaterialProperty< U, is_ad > & getMaterialPropertyDerivative (const std::string &base, unsigned int v1, unsigned int v2=libMesh::invalid_uint, unsigned int v3=libMesh::invalid_uint)
 
const GenericMaterialProperty< U, is_ad > & getMaterialPropertyDerivativeByName (const MaterialPropertyName &base, const std::vector< VariableName > &c)
 
const GenericMaterialProperty< U, is_ad > & getMaterialPropertyDerivativeByName (const MaterialPropertyName &base, const std::vector< SymbolName > &c)
 
const GenericMaterialProperty< U, is_ad > & getMaterialPropertyDerivativeByName (const MaterialPropertyName &base, const SymbolName &c1, const SymbolName &c2="", const SymbolName &c3="")
 
const GenericMaterialProperty< U, is_ad > & getMaterialPropertyDerivativeByName (const MaterialPropertyName &base, const std::vector< VariableName > &c)
 
const GenericMaterialProperty< U, is_ad > & getMaterialPropertyDerivativeByName (const MaterialPropertyName &base, const std::vector< SymbolName > &c)
 
const GenericMaterialProperty< U, is_ad > & getMaterialPropertyDerivativeByName (const MaterialPropertyName &base, const SymbolName &c1, const SymbolName &c2="", const SymbolName &c3="")
 
void validateCoupling (const MaterialPropertyName &base, const std::vector< VariableName > &c, bool validate_aux=true)
 
void validateCoupling (const MaterialPropertyName &base, const VariableName &c1="", const VariableName &c2="", const VariableName &c3="")
 
void validateCoupling (const MaterialPropertyName &base, const std::vector< VariableName > &c, bool validate_aux=true)
 
void validateCoupling (const MaterialPropertyName &base, const VariableName &c1="", const VariableName &c2="", const VariableName &c3="")
 
void validateNonlinearCoupling (const MaterialPropertyName &base, const VariableName &c1="", const VariableName &c2="", const VariableName &c3="")
 
void validateNonlinearCoupling (const MaterialPropertyName &base, const VariableName &c1="", const VariableName &c2="", const VariableName &c3="")
 
const MaterialPropertyName propertyName (const MaterialPropertyName &base, const std::vector< SymbolName > &c) const
 
const MaterialPropertyName propertyName (const MaterialPropertyName &base, const std::vector< SymbolName > &c) const
 
const MaterialPropertyName propertyNameFirst (const MaterialPropertyName &base, const SymbolName &c1) const
 
const MaterialPropertyName propertyNameFirst (const MaterialPropertyName &base, const SymbolName &c1) const
 
const MaterialPropertyName propertyNameSecond (const MaterialPropertyName &base, const SymbolName &c1, const SymbolName &c2) const
 
const MaterialPropertyName propertyNameSecond (const MaterialPropertyName &base, const SymbolName &c1, const SymbolName &c2) const
 
const MaterialPropertyName propertyNameThird (const MaterialPropertyName &base, const SymbolName &c1, const SymbolName &c2, const SymbolName &c3) const
 
const MaterialPropertyName propertyNameThird (const MaterialPropertyName &base, const SymbolName &c1, const SymbolName &c2, const SymbolName &c3) const
 

Static Public Member Functions

static InputParameters validParams ()
 

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 20 of file SwitchingFunctionPenalty.h.

Constructor & Destructor Documentation

◆ SwitchingFunctionPenalty()

SwitchingFunctionPenalty::SwitchingFunctionPenalty ( const InputParameters parameters)

Definition at line 27 of file SwitchingFunctionPenalty.C.

29  _h_names(getParam<std::vector<MaterialPropertyName>>("h_names")),
30  _num_h(_h_names.size()),
31  _h(_num_h),
32  _dh(_num_h),
33  _penalty(getParam<Real>("penalty")),
34  _number_of_nl_variables(_sys.nVariables()),
36  _a(-1)
37 {
38  // parameter check. We need exactly one eta per h
39  if (_num_h != coupledComponents("etas"))
40  paramError("h_names", "Need to pass in as many h_names as etas");
41 
42  // fetch switching functions (for the residual) and h derivatives (for the Jacobian)
43  for (unsigned int i = 0; i < _num_h; ++i)
44  {
45  _h[i] = &getMaterialPropertyByName<Real>(_h_names[i]);
46  _dh[i] = &getMaterialPropertyDerivative<Real>(_h_names[i], coupledName("etas", i));
47 
48  // generate the lookup table from j_var -> eta index
49  unsigned int num = coupled("etas", i);
50  if (num < _number_of_nl_variables)
51  _j_eta[num] = i;
52 
53  // figure out which variable this kernel is acting on
54  if (num == _var.number())
55  _a = i;
56  }
57 
58  if (_a < 0)
59  paramError("etas", "Kernel variable must be listed in etas");
60 
61  _d2h = &getMaterialPropertyDerivative<Real>(_h_names[_a], _var.name(), _var.name());
62 }
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

◆ computeQpJacobian()

Real SwitchingFunctionPenalty::computeQpJacobian ( )
protectedvirtual

Definition at line 75 of file SwitchingFunctionPenalty.C.

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

◆ computeQpOffDiagJacobian()

Real SwitchingFunctionPenalty::computeQpOffDiagJacobian ( unsigned int  j_var)
protectedvirtual

Definition at line 86 of file SwitchingFunctionPenalty.C.

87 {
88  const int eta = _j_eta[j_var];
89 
90  if (eta >= 0)
91  return _test[_i][_qp] * _penalty * _phi[_j][_qp] * 2.0 * (*_dh[eta])[_qp] * (*_dh[_a])[_qp];
92  else
93  return 0.0;
94 }
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.

◆ computeQpResidual()

Real SwitchingFunctionPenalty::computeQpResidual ( )
protectedvirtual

Definition at line 65 of file SwitchingFunctionPenalty.C.

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

◆ validParams()

InputParameters SwitchingFunctionPenalty::validParams ( )
static

Definition at line 15 of file SwitchingFunctionPenalty.C.

16 {
18  params.addClassDescription(
19  "Penalty kernel to constrain the sum of all switching functions in a multiphase system.");
20  params.addParam<std::vector<MaterialPropertyName>>(
21  "h_names", "Switching Function Materials that provide h(eta_i)");
22  params.addRequiredCoupledVar("etas", "eta_i order parameters, one for each h");
23  params.addParam<Real>("penalty", 1.0, "Penalty scaling factor");
24  return params;
25 }
static InputParameters validParams()
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void addClassDescription(const std::string &doc_string)

Member Data Documentation

◆ _a

int SwitchingFunctionPenalty::_a
protected

Index of the eta this kernel is operating on.

Definition at line 50 of file SwitchingFunctionPenalty.h.

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

◆ _d2h

const MaterialProperty<Real>* SwitchingFunctionPenalty::_d2h
protected

Definition at line 38 of file SwitchingFunctionPenalty.h.

Referenced by SwitchingFunctionPenalty().

◆ _dh

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

◆ _h

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

Switching functions and their drivatives.

Definition at line 37 of file SwitchingFunctionPenalty.h.

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

◆ _h_names

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

Switching function names.

Definition at line 33 of file SwitchingFunctionPenalty.h.

Referenced by SwitchingFunctionPenalty().

◆ _j_eta

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

eta index for the j_vars in the jacobian computation

Definition at line 47 of file SwitchingFunctionPenalty.h.

Referenced by computeQpOffDiagJacobian(), and SwitchingFunctionPenalty().

◆ _num_h

unsigned int SwitchingFunctionPenalty::_num_h
protected

◆ _number_of_nl_variables

const unsigned int SwitchingFunctionPenalty::_number_of_nl_variables
protected

number of non-linear variables in the problem

Definition at line 44 of file SwitchingFunctionPenalty.h.

Referenced by SwitchingFunctionPenalty().

◆ _penalty

const Real SwitchingFunctionPenalty::_penalty
protected

Penalty pre-factor.

Definition at line 41 of file SwitchingFunctionPenalty.h.

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


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