LCOV - code coverage report
Current view: top level - src/materials - MultiBarrierFunctionMaterial.C (source / functions) Hit Total Coverage
Test: idaholab/moose phase_field: #31405 (292dce) with base fef103 Lines: 38 41 92.7 %
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 "MultiBarrierFunctionMaterial.h"
      11             : 
      12             : registerMooseObject("PhaseFieldApp", MultiBarrierFunctionMaterial);
      13             : 
      14             : InputParameters
      15         270 : MultiBarrierFunctionMaterial::validParams()
      16             : {
      17         270 :   InputParameters params = Material::validParams();
      18         270 :   params.addClassDescription("Double well phase transformation barrier free energy contribution.");
      19         540 :   params.addParam<std::string>("function_name", "g", "actual name for g(eta_i)");
      20         540 :   MooseEnum h_order("SIMPLE=0", "SIMPLE");
      21         540 :   params.addParam<MooseEnum>(
      22             :       "g_order", h_order, "Polynomial order of the switching function h(eta)");
      23         540 :   params.addParam<bool>("well_only",
      24         540 :                         false,
      25             :                         "Make the g zero in [0:1] so it only contributes to "
      26             :                         "enforcing the eta range and not to the phase "
      27             :                         "transformation barrier.");
      28         540 :   params.addRequiredCoupledVar("etas", "eta_i order parameters, one for each h");
      29         270 :   return params;
      30         270 : }
      31             : 
      32         207 : MultiBarrierFunctionMaterial::MultiBarrierFunctionMaterial(const InputParameters & parameters)
      33             :   : DerivativeMaterialInterface<Material>(parameters),
      34         207 :     _function_name(getParam<std::string>("function_name")),
      35         414 :     _g_order(getParam<MooseEnum>("g_order")),
      36         414 :     _well_only(getParam<bool>("well_only")),
      37         207 :     _num_eta(coupledComponents("etas")),
      38         207 :     _eta(coupledValues("etas")),
      39         207 :     _prop_g(declareProperty<Real>(_function_name)),
      40         207 :     _prop_dg(_num_eta),
      41         414 :     _prop_d2g(_num_eta)
      42             : {
      43             :   // declare derivative properties, fetch eta values
      44         720 :   for (unsigned int i = 0; i < _num_eta; ++i)
      45             :   {
      46         513 :     const VariableName & eta_name = coupledName("etas", i);
      47         513 :     if (!isCoupledConstant(eta_name))
      48             :     {
      49         513 :       _prop_dg[i] = &declarePropertyDerivative<Real>(_function_name, eta_name);
      50         513 :       _prop_d2g[i] = &declarePropertyDerivative<Real>(_function_name, eta_name, eta_name);
      51             :     }
      52             :   }
      53         207 : }
      54             : 
      55             : void
      56     1822720 : MultiBarrierFunctionMaterial::computeQpProperties()
      57             : {
      58             :   Real g = 0.0;
      59             : 
      60     6338560 :   for (unsigned int i = 0; i < _num_eta; ++i)
      61             :   {
      62     4515840 :     const Real n = (*_eta[i])[_qp];
      63             : 
      64     4515840 :     if (_well_only && n >= 0.0 && n <= 1.0 && _prop_dg[i])
      65             :     {
      66           0 :       (*_prop_dg[i])[_qp] = 0.0;
      67           0 :       (*_prop_d2g[i])[_qp] = 0.0;
      68           0 :       continue;
      69             :     }
      70             : 
      71     4515840 :     switch (_g_order)
      72             :     {
      73     4515840 :       case 0: // SIMPLE
      74     4515840 :         g += n * n * (1.0 - n) * (1.0 - n);
      75     4515840 :         if (_prop_dg[i])
      76             :         {
      77     4515840 :           (*_prop_dg[i])[_qp] = 2.0 * n * (n - 1.0) * (2.0 * n - 1.0);
      78     4515840 :           (*_prop_d2g[i])[_qp] = 12.0 * (n * n - n) + 2.0;
      79             :         }
      80             :         break;
      81             :     }
      82             :   }
      83             : 
      84     1822720 :   _prop_g[_qp] = g;
      85     1822720 : }

Generated by: LCOV version 1.14