https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private 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.
 
unsigned int _num_h
 
std::vector< const MaterialProperty< Real > * > _h
 Switching functions and their drivatives.
 
std::vector< const MaterialProperty< Real > * > _dh
 
const MaterialProperty< Real > * _d2h
 
const Real _penalty
 Penalty pre-factor.
 
const unsigned int _number_of_nl_variables
 number of non-linear variables in the problem
 
std::vector< int_j_eta
 eta index for the j_vars in the jacobian computation
 
int _a
 Index of the eta this kernel is operating on.
 

Private Member Functions

bool haveMaterialProperty (const std::string &prop_name)
 
std::vector< VariableName > buildVariableVector (const VariableName &c1, const VariableName &c2, const VariableName &c3)
 
void validateCouplingHelper (const MaterialPropertyName &base, const std::vector< VariableName > &c, const System &system, std::vector< VariableName > &missing)
 
bool isNotObjectVariable (const VariableName &name)
 

Private Attributes

FEProblemBase_dmi_fe_problem
 

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);
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}
std::vector< MaterialPropertyName > _h_names
Switching function names.
std::vector< const MaterialProperty< Real > * > _dh
int _a
Index of the eta this kernel is operating on.
std::vector< int > _j_eta
eta index for the j_vars in the jacobian computation
const unsigned int _number_of_nl_variables
number of non-linear variables in the problem
const Real _penalty
Penalty pre-factor.
std::vector< const MaterialProperty< Real > * > _h
Switching functions and their drivatives.
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}
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real

◆ 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}
Point eta

◆ 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}

◆ validParams()

InputParameters SwitchingFunctionPenalty::validParams ( )
static

Definition at line 15 of file SwitchingFunctionPenalty.C.

16{
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}
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
static InputParameters validParams()

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: