LCOV - code coverage report
Current view: top level - src/materials - MixedSwitchingFunctionMaterial.C (source / functions) Hit Total Coverage
Test: idaholab/moose phase_field: #32971 (54bef8) with base c6cf66 Lines: 26 36 72.2 %
Date: 2026-05-29 20:38:39 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 "MixedSwitchingFunctionMaterial.h"
      11             : 
      12             : registerMooseObject("PhaseFieldApp", MixedSwitchingFunctionMaterial);
      13             : 
      14             : InputParameters
      15          31 : MixedSwitchingFunctionMaterial::validParams()
      16             : {
      17          31 :   InputParameters params = OrderParameterFunctionMaterial::validParams();
      18          31 :   params.addClassDescription("Helper material to provide h(eta) and its derivative in one of two "
      19             :                              "polynomial forms. MIX234 and MIX246");
      20          62 :   MooseEnum h_order("MIX234=0 MIX246", "MIX234");
      21          62 :   params.addParam<MooseEnum>(
      22             :       "h_order", h_order, "Polynomial order of the switching function h(eta)");
      23          62 :   params.set<std::string>("function_name") = std::string("h");
      24             : 
      25          93 :   params.addRangeCheckedParam<Real>(
      26          62 :       "weight", 1.0, "weight <= 1 & weight >= 0", "Weight parameter for MIX type h(eta)");
      27             : 
      28          31 :   return params;
      29          31 : }
      30             : 
      31          24 : MixedSwitchingFunctionMaterial::MixedSwitchingFunctionMaterial(const InputParameters & parameters)
      32             :   : OrderParameterFunctionMaterial(parameters),
      33          24 :     _h_order(getParam<MooseEnum>("h_order")),
      34          72 :     _weight(getParam<Real>("weight"))
      35             : {
      36          24 : }
      37             : 
      38             : void
      39      825600 : MixedSwitchingFunctionMaterial::computeQpProperties()
      40             : {
      41      825600 :   Real n = _eta[_qp];
      42      825600 :   n = n > 1 ? 1 : (n < 0 ? 0 : n);
      43             : 
      44      825600 :   switch (_h_order)
      45             :   {
      46      825600 :     case 0: // MIX234
      47      825600 :       _prop_f[_qp] =
      48      825600 :           n * n * (3.0 * _weight + (4.0 - 6.0 * _weight) * n + (3.0 * _weight - 3.0) * n * n);
      49      825600 :       _prop_df[_qp] =
      50      825600 :           n * (6.0 * _weight + (12.0 - 18.0 * _weight) * n + (12.0 * _weight - 12.0) * n * n);
      51      825600 :       _prop_d2f[_qp] = 6.0 * _weight + ((24.0 - 36.0 * _weight) + (36.0 * _weight - 36.0) * n) * n;
      52      825600 :       break;
      53             : 
      54           0 :     case 1: // MIX246
      55           0 :       _prop_f[_qp] =
      56           0 :           n * n * (2.0 * _weight + n * n * ((3.0 - 4.0 * _weight) + (2.0 * _weight - 2.0) * n * n));
      57           0 :       _prop_df[_qp] =
      58           0 :           n * (4.0 * _weight + n * n * ((12.0 - 16.0 * _weight) + (12.0 * _weight - 12.0) * n * n));
      59           0 :       _prop_d2f[_qp] =
      60           0 :           4.0 * _weight + n * n * ((36.0 - 48.0 * _weight) + (60.0 * _weight - 60.0) * n * n);
      61           0 :       break;
      62             : 
      63           0 :     default:
      64           0 :       mooseError("Internal error");
      65             :   }
      66      825600 : }

Generated by: LCOV version 1.14