LCOV - code coverage report
Current view: top level - src/materials - BarrierFunctionMaterial.C (source / functions) Hit Total Coverage
Test: idaholab/moose phase_field: #31405 (292dce) with base fef103 Lines: 33 39 84.6 %
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 "BarrierFunctionMaterial.h"
      11             : 
      12             : registerMooseObject("PhaseFieldApp", BarrierFunctionMaterial);
      13             : 
      14             : InputParameters
      15        1514 : BarrierFunctionMaterial::validParams()
      16             : {
      17        1514 :   InputParameters params = OrderParameterFunctionMaterial::validParams();
      18        1514 :   params.addClassDescription("Helper material to provide $g(\\eta)$ and its derivative in a "
      19             :                              "polynomial.\nSIMPLE: $\\eta^2(1-\\eta)^2$\nLOW: $\\eta(1-\\eta)$"
      20             :                              "\nHIGH: $\\eta^2(1-\\eta^2)^2$");
      21        3028 :   MooseEnum g_order("SIMPLE=0 LOW HIGH", "SIMPLE");
      22        3028 :   params.addParam<MooseEnum>("g_order", g_order, "Polynomial order of the barrier function g(eta)");
      23        3028 :   params.addParam<bool>("well_only",
      24        3028 :                         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        3028 :   params.set<std::string>("function_name") = std::string("g");
      29        1514 :   return params;
      30        1514 : }
      31             : 
      32        1161 : BarrierFunctionMaterial::BarrierFunctionMaterial(const InputParameters & parameters)
      33             :   : OrderParameterFunctionMaterial(parameters),
      34        1161 :     _g_order(getParam<MooseEnum>("g_order")),
      35        3483 :     _well_only(getParam<bool>("well_only"))
      36             : {
      37        1161 : }
      38             : 
      39             : void
      40    17960972 : BarrierFunctionMaterial::computeQpProperties()
      41             : {
      42    17960972 :   const Real n = _eta[_qp];
      43             : 
      44    17960972 :   if (_well_only && n >= 0.0 && n <= 1.0)
      45             :   {
      46           0 :     _prop_f[_qp] = 0.0;
      47           0 :     _prop_df[_qp] = 0.0;
      48           0 :     _prop_d2f[_qp] = 0.0;
      49           0 :     return;
      50             :   }
      51             : 
      52    17960972 :   switch (_g_order)
      53             :   {
      54    17922572 :     case 0: // SIMPLE
      55    17922572 :       _prop_f[_qp] = n * n * (1.0 - n) * (1.0 - n);
      56    17922572 :       _prop_df[_qp] = 2.0 * n * (n - 1.0) * (2.0 * n - 1.0);
      57    17922572 :       _prop_d2f[_qp] = 12.0 * (n * n - n) + 2.0;
      58    17922572 :       break;
      59             : 
      60        9600 :     case 1: // LOW
      61        9600 :       _prop_f[_qp] = n * (1.0 - n);
      62        9600 :       _prop_df[_qp] = 1.0 - 2.0 * n;
      63        9600 :       _prop_d2f[_qp] = -2.0;
      64        9600 :       break;
      65             : 
      66       28800 :     case 2: // HIGH
      67       28800 :       _prop_f[_qp] = n * n * (1.0 - n * n) * (1.0 - n * n);
      68       28800 :       _prop_df[_qp] = n * (2.0 - n * n * (8.0 + 6.0 * n * n));
      69       28800 :       _prop_d2f[_qp] = 2.0 - n * n * (24.0 + 30.0 * n * n);
      70       28800 :       break;
      71             : 
      72           0 :     default:
      73           0 :       mooseError("Internal error");
      74             :   }
      75             : }

Generated by: LCOV version 1.14