LCOV - code coverage report
Current view: top level - src/kernels - SwitchingFunctionConstraintEta.C (source / functions) Hit Total Coverage
Test: idaholab/moose phase_field: #31613 (c7d555) with base 7323e9 Lines: 29 30 96.7 %
Date: 2025-11-06 14:16:56 Functions: 5 5 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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             : 
      10             : #include "SwitchingFunctionConstraintEta.h"
      11             : 
      12             : registerMooseObject("PhaseFieldApp", SwitchingFunctionConstraintEta);
      13             : 
      14             : InputParameters
      15         379 : SwitchingFunctionConstraintEta::validParams()
      16             : {
      17         379 :   InputParameters params = Kernel::validParams();
      18         379 :   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         758 :   params.addParam<MaterialPropertyName>("h_name",
      22             :                                         "Switching Function Materials that provides h(eta_i)");
      23         758 :   params.addRequiredCoupledVar("lambda", "Lagrange multiplier");
      24         758 :   params.addCoupledVar("coupled_variables",
      25             :                        "Vector of further variable arguments to the switching function");
      26         379 :   return params;
      27           0 : }
      28             : 
      29         198 : SwitchingFunctionConstraintEta::SwitchingFunctionConstraintEta(const InputParameters & parameters)
      30             :   : DerivativeMaterialInterface<JvarMapKernelInterface<Kernel>>(parameters),
      31         198 :     _eta_name(_var.name()),
      32         198 :     _dh(getMaterialPropertyDerivative<Real>("h_name", _eta_name)),
      33         198 :     _d2h(getMaterialPropertyDerivative<Real>("h_name", _eta_name, _eta_name)),
      34         198 :     _d2ha(coupledComponents("coupled_variables")),
      35         198 :     _d2ha_map(getParameterJvarMap("coupled_variables")),
      36         198 :     _lambda(coupledValue("lambda")),
      37         396 :     _lambda_var(coupled("lambda"))
      38             : {
      39         384 :   for (std::size_t i = 0; i < _d2ha.size(); ++i)
      40         558 :     _d2ha[i] = &getMaterialPropertyDerivative<Real>(
      41         372 :         "h_name", _eta_name, coupledName("coupled_variables", i));
      42         198 : }
      43             : 
      44             : Real
      45    24950160 : SwitchingFunctionConstraintEta::computeQpResidual()
      46             : {
      47    24950160 :   return _lambda[_qp] * _dh[_qp] * _test[_i][_qp];
      48             : }
      49             : 
      50             : Real
      51    13279040 : SwitchingFunctionConstraintEta::computeQpJacobian()
      52             : {
      53    13279040 :   return _lambda[_qp] * _d2h[_qp] * _phi[_j][_qp] * _test[_i][_qp];
      54             : }
      55             : 
      56             : Real
      57    29532800 : SwitchingFunctionConstraintEta::computeQpOffDiagJacobian(unsigned int jvar)
      58             : {
      59    29532800 :   if (jvar == _lambda_var)
      60    13279040 :     return _phi[_j][_qp] * _dh[_qp] * _test[_i][_qp];
      61             : 
      62    16253760 :   auto k = mapJvarToCvar(jvar, _d2ha_map);
      63    16253760 :   if (k >= 0)
      64    16253760 :     return _lambda[_qp] * (*_d2ha[k])[_qp] * _phi[_j][_qp] * _test[_i][_qp];
      65             : 
      66             :   return 0.0;
      67             : }

Generated by: LCOV version 1.14