https://mooseframework.inl.gov
Loading...
Searching...
No Matches
SwitchingFunctionConstraintLagrange.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 the Lagrange "
20 "multiplier variable.");
21 params.addParam<std::vector<MaterialPropertyName>>("h_names", "Switching function materials");
22 params.addRequiredCoupledVar("etas", "eta order parameters");
23 params.addParam<Real>("epsilon", 1e-9, "Shift factor to avoid a zero pivot");
24 return params;
25}
26
28 const InputParameters & parameters)
30 _h_names(getParam<std::vector<MaterialPropertyName>>("h_names")),
31 _num_h(_h_names.size()),
32 _h(_num_h),
33 _dh(_num_h),
34 _eta_map(getParameterJvarMap("etas")),
35 _epsilon(getParam<Real>("epsilon"))
36{
37 // parameter check. We need exactly one eta per h
38 if (_num_h != coupledComponents("etas"))
39 paramError("etas", "Need to pass in as many etas as h_names");
40
41 // fetch switching functions (for the residual) and h derivatives (for the Jacobian)
42 for (std::size_t i = 0; i < _num_h; ++i)
43 {
44 _h[i] = &getMaterialPropertyByName<Real>(_h_names[i]);
45
46 _dh[i].resize(_num_h);
47 for (std::size_t j = 0; j < _num_h; ++j)
48 _dh[i][j] = &getMaterialPropertyDerivative<Real>(_h_names[i], coupledName("etas", j));
49 }
50}
51
52Real
54{
55 Real g = -_epsilon * _u[_qp] - 1.0;
56 for (std::size_t i = 0; i < _num_h; ++i)
57 g += (*_h[i])[_qp];
58
59 return _test[_i][_qp] * g;
60}
61
62Real
64{
65 return _test[_i][_qp] * -_epsilon * _phi[_j][_qp];
66}
67
68Real
70{
71 auto eta = mapJvarToCvar(jvar, _eta_map);
72 if (eta >= 0)
73 {
74 Real g = 0.0;
75 for (std::size_t i = 0; i < _num_h; ++i)
76 g += (*_dh[i][eta])[_qp] * _phi[_j][_qp];
77 return g * _test[_i][_qp];
78 }
79
80 return 0.0;
81}
Point eta
registerMooseObject("PhaseFieldApp", SwitchingFunctionConstraintLagrange)
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()
SwitchingFunctionConstraintLagrange is a constraint kernel that acts on the lambda lagrange multiplie...
std::vector< std::vector< const MaterialProperty< Real > * > > _dh
Switching function derivatives.
std::vector< const MaterialProperty< Real > * > _h
Switching functions.
unsigned int _num_h
number of switching functions
std::vector< MaterialPropertyName > _h_names
Switching function names.
SwitchingFunctionConstraintLagrange(const InputParameters &parameters)
const JvarMap & _eta_map
map for getting the "etas" index from jvar