www.mooseframework.org
SwitchingFunctionConstraintEta.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
11 
13 
16 {
18  params.addClassDescription("Lagrange multiplier kernel to constrain the sum of all switching "
19  "functions in a multiphase system. This kernel acts on a "
20  "non-conserved order parameter eta_i.");
21  params.addParam<MaterialPropertyName>("h_name",
22  "Switching Function Materials that provides h(eta_i)");
23  params.addRequiredCoupledVar("lambda", "Lagrange multiplier");
24  params.addCoupledVar("args", "Vector of further variable arguments to the switching function");
25  params.deprecateCoupledVar("args", "coupled_variables", "02/27/2024");
26  return params;
27 }
28 
31  _eta_name(_var.name()),
32  _dh(getMaterialPropertyDerivative<Real>("h_name", _eta_name)),
33  _d2h(getMaterialPropertyDerivative<Real>("h_name", _eta_name, _eta_name)),
34  _d2ha(isCoupled("args") ? coupledComponents("args") : coupledComponents("coupled_variables")),
35  _d2ha_map(isCoupled("args") ? getParameterJvarMap("args")
36  : getParameterJvarMap("coupled_variables")),
37  _lambda(coupledValue("lambda")),
38  _lambda_var(coupled("lambda"))
39 {
40  for (std::size_t i = 0; i < _d2ha.size(); ++i)
41  {
42  if (isCoupled("args"))
43  _d2ha[i] = &getMaterialPropertyDerivative<Real>("h_name", _eta_name, coupledName("args", i));
44  else
45  _d2ha[i] = &getMaterialPropertyDerivative<Real>(
46  "h_name", _eta_name, coupledName("coupled_variables", i));
47  }
48 }
49 
50 Real
52 {
53  return _lambda[_qp] * _dh[_qp] * _test[_i][_qp];
54 }
55 
56 Real
58 {
59  return _lambda[_qp] * _d2h[_qp] * _phi[_j][_qp] * _test[_i][_qp];
60 }
61 
62 Real
64 {
65  if (jvar == _lambda_var)
66  return _phi[_j][_qp] * _dh[_qp] * _test[_i][_qp];
67 
68  auto k = mapJvarToCvar(jvar, _d2ha_map);
69  if (k >= 0)
70  return _lambda[_qp] * (*_d2ha[k])[_qp] * _phi[_j][_qp] * _test[_i][_qp];
71 
72  return 0.0;
73 }
virtual bool isCoupled(const std::string &var_name, unsigned int i=0) const
static InputParameters validParams()
VariableName coupledName(const std::string &var_name, unsigned int comp=0) const
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
SwitchingFunctionConstraintEta(const InputParameters &parameters)
std::vector< const MaterialProperty< Real > * > _d2ha
const MaterialProperty< Real > & _dh
Switching function drivatives.
const std::string name
Definition: Setup.h:20
void deprecateCoupledVar(const std::string &old_name, const std::string &new_name, const std::string &removal_date)
SwitchingFunctionConstraintEta is a constraint kernel that acts on the lambda lagrange multiplier non...
void addCoupledVar(const std::string &name, const std::string &doc_string)
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
const MaterialProperty< Real > & _d2h
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
registerMooseObject("PhaseFieldApp", SwitchingFunctionConstraintEta)
VariableName _eta_name
Switching function name.
virtual Real computeQpOffDiagJacobian(unsigned int)
void addClassDescription(const std::string &doc_string)
const VariableValue & _lambda
Lagrange multiplier.
static const std::string k
Definition: NS.h:124