https://mooseframework.inl.gov
SwitchingFunctionConstraintEta.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
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("coupled_variables",
25  "Vector of further variable arguments to the switching function");
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(coupledComponents("coupled_variables")),
35  _d2ha_map(getParameterJvarMap("coupled_variables")),
36  _lambda(coupledValue("lambda")),
37  _lambda_var(coupled("lambda"))
38 {
39  for (std::size_t i = 0; i < _d2ha.size(); ++i)
40  _d2ha[i] = &getMaterialPropertyDerivative<Real>(
41  "h_name", _eta_name, coupledName("coupled_variables", i));
42 }
43 
44 Real
46 {
47  return _lambda[_qp] * _dh[_qp] * _test[_i][_qp];
48 }
49 
50 Real
52 {
53  return _lambda[_qp] * _d2h[_qp] * _phi[_j][_qp] * _test[_i][_qp];
54 }
55 
56 Real
58 {
59  if (jvar == _lambda_var)
60  return _phi[_j][_qp] * _dh[_qp] * _test[_i][_qp];
61 
62  auto k = mapJvarToCvar(jvar, _d2ha_map);
63  if (k >= 0)
64  return _lambda[_qp] * (*_d2ha[k])[_qp] * _phi[_j][_qp] * _test[_i][_qp];
65 
66  return 0.0;
67 }
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
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:130