LCOV - code coverage report
Current view: top level - src/materials - ThirdPhaseSuppressionMaterial.C (source / functions) Hit Total Coverage
Test: idaholab/moose phase_field: #31405 (292dce) with base fef103 Lines: 45 46 97.8 %
Date: 2025-09-04 07:55:36 Functions: 3 3 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 "ThirdPhaseSuppressionMaterial.h"
      11             : 
      12             : registerMooseObject("PhaseFieldApp", ThirdPhaseSuppressionMaterial);
      13             : 
      14             : InputParameters
      15          47 : ThirdPhaseSuppressionMaterial::validParams()
      16             : {
      17          47 :   InputParameters params = Material::validParams();
      18          94 :   params.addParam<std::string>("function_name", "g", "actual name for g(eta_i)");
      19          94 :   params.addRequiredCoupledVar("etas", "eta_i order parameters, one for each h");
      20          47 :   params.addClassDescription(
      21             :       "Free Energy contribution that penalizes more than two order parameters being non-zero");
      22          47 :   return params;
      23           0 : }
      24             : 
      25          36 : ThirdPhaseSuppressionMaterial::ThirdPhaseSuppressionMaterial(const InputParameters & parameters)
      26             :   : DerivativeMaterialInterface<Material>(parameters),
      27          36 :     _function_name(getParam<std::string>("function_name")),
      28          36 :     _num_eta(coupledComponents("etas")),
      29          36 :     _eta(coupledValues("etas")),
      30          36 :     _prop_g(declareProperty<Real>(_function_name)),
      31          36 :     _prop_dg(_num_eta),
      32          72 :     _prop_d2g(_num_eta)
      33             : {
      34          36 :   const auto eta_name = coupledNames("etas");
      35             : 
      36         144 :   for (unsigned int i = 0; i < _num_eta; ++i)
      37         108 :     _prop_d2g[i].resize(_num_eta);
      38             : 
      39         144 :   for (unsigned int i = 0; i < _num_eta; ++i)
      40             :   {
      41         108 :     _prop_dg[i] = &declarePropertyDerivative<Real>(_function_name, eta_name[i]);
      42         324 :     for (unsigned int j = i; j < _num_eta; ++j)
      43             :     {
      44         216 :       _prop_d2g[i][j] = _prop_d2g[j][i] =
      45         432 :           &declarePropertyDerivative<Real>(_function_name, eta_name[i], eta_name[j]);
      46             :     }
      47             :   }
      48          36 : }
      49             : 
      50             : void
      51         300 : ThirdPhaseSuppressionMaterial::computeQpProperties()
      52             : {
      53             :   // Initialize properties to zero before accumulating
      54         300 :   _prop_g[_qp] = 0.0;
      55        1200 :   for (unsigned int i = 0; i < _num_eta; ++i)
      56             :   {
      57         900 :     (*_prop_dg[i])[_qp] = 0.0;
      58        2700 :     for (unsigned int j = i; j < _num_eta; ++j)
      59        1800 :       (*_prop_d2g[i][j])[_qp] = 0.0;
      60             :   }
      61             : 
      62             :   // Create Interface barrier preventing interfaces involving more than two order parameters
      63        1200 :   for (unsigned int i = 0; i < _num_eta; ++i)
      64        1800 :     for (unsigned int j = 0; j < i; ++j)
      65        1200 :       for (unsigned int k = 0; k < j; ++k)
      66             :       {
      67         300 :         const Real ni = (*_eta[i])[_qp];
      68         300 :         const Real nj = (*_eta[j])[_qp];
      69         300 :         const Real nk = (*_eta[k])[_qp];
      70             : 
      71         300 :         _prop_g[_qp] += ni * ni * nj * nj * nk * nk;
      72         300 :         (*_prop_dg[i])[_qp] += 2 * ni * nj * nj * nk * nk;
      73         300 :         (*_prop_dg[j])[_qp] += 2 * ni * ni * nj * nk * nk;
      74         300 :         (*_prop_dg[k])[_qp] += 2 * ni * ni * nj * nj * nk;
      75         300 :         (*_prop_d2g[i][i])[_qp] += 2 * nj * nj * nk * nk;
      76         300 :         (*_prop_d2g[j][j])[_qp] += 2 * ni * ni * nk * nk;
      77         300 :         (*_prop_d2g[k][k])[_qp] += 2 * ni * ni * nj * nj;
      78         300 :         (*_prop_d2g[i][j])[_qp] += 4 * ni * nj * nk * nk;
      79         300 :         (*_prop_d2g[i][k])[_qp] += 4 * ni * nj * nj * nk;
      80         300 :         (*_prop_d2g[k][j])[_qp] += 4 * ni * ni * nj * nk;
      81             :       }
      82         300 : }

Generated by: LCOV version 1.14