LCOV - code coverage report
Current view: top level - src/materials - SwitchingFunctionMaterial.C (source / functions) Hit Total Coverage
Test: idaholab/moose phase_field: #31405 (292dce) with base fef103 Lines: 26 28 92.9 %
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 "SwitchingFunctionMaterial.h"
      11             : 
      12             : registerMooseObject("PhaseFieldApp", SwitchingFunctionMaterial);
      13             : 
      14             : InputParameters
      15        1666 : SwitchingFunctionMaterial::validParams()
      16             : {
      17        1666 :   InputParameters params = OrderParameterFunctionMaterial::validParams();
      18        1666 :   params.addClassDescription(
      19             :       "Helper material to provide $h(\\eta)$ and its derivative in one of two "
      20             :       "polynomial forms.\nSIMPLE: $3\\eta^2-2\\eta^3$\nHIGH: "
      21             :       "$\\eta^3(6\\eta^2-15\\eta+10)$");
      22        3332 :   MooseEnum h_order("SIMPLE=0 HIGH", "SIMPLE");
      23        3332 :   params.addParam<MooseEnum>(
      24             :       "h_order", h_order, "Polynomial order of the switching function h(eta)");
      25        3332 :   params.set<std::string>("function_name") = std::string("h");
      26        1666 :   return params;
      27        1666 : }
      28             : 
      29        1278 : SwitchingFunctionMaterial::SwitchingFunctionMaterial(const InputParameters & parameters)
      30        2556 :   : OrderParameterFunctionMaterial(parameters), _h_order(getParam<MooseEnum>("h_order"))
      31             : {
      32        1278 : }
      33             : 
      34             : void
      35    10783652 : SwitchingFunctionMaterial::computeQpProperties()
      36             : {
      37    10783652 :   Real n = _eta[_qp];
      38    10783652 :   n = n > 1 ? 1 : (n < 0 ? 0 : n);
      39             : 
      40    10783652 :   switch (_h_order)
      41             :   {
      42     4507360 :     case 0: // SIMPLE
      43     4507360 :       _prop_f[_qp] = 3.0 * n * n - 2.0 * n * n * n;
      44     4507360 :       _prop_df[_qp] = 6.0 * n - 6.0 * n * n;
      45     4507360 :       _prop_d2f[_qp] = 6.0 - 12.0 * n;
      46     4507360 :       break;
      47             : 
      48     6276292 :     case 1: // HIGH
      49     6276292 :       _prop_f[_qp] = n * n * n * (6.0 * n * n - 15.0 * n + 10.0);
      50     6276292 :       _prop_df[_qp] = 30.0 * n * n * (n * n - 2.0 * n + 1.0);
      51     6276292 :       _prop_d2f[_qp] = n * (120.0 * n * n - 180.0 * n + 60.0);
      52     6276292 :       break;
      53             : 
      54           0 :     default:
      55           0 :       mooseError("Internal error");
      56             :   }
      57    10783652 : }

Generated by: LCOV version 1.14