LCOV - code coverage report
Current view: top level - src/materials - SwitchingFunction3PhaseMaterial.C (source / functions) Hit Total Coverage
Test: idaholab/moose phase_field: #30119 (aa6062) with base 79f9bd Lines: 18 27 66.7 %
Date: 2025-03-20 17:26:41 Functions: 2 2 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //* This file is part of the MOOSE framework
       2             : //* https://www.mooseframework.org
       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 "SwitchingFunction3PhaseMaterial.h"
      11             : 
      12             : registerMooseObject("PhaseFieldApp", SwitchingFunction3PhaseMaterial);
      13             : 
      14             : InputParameters
      15         209 : SwitchingFunction3PhaseMaterial::validParams()
      16             : {
      17         209 :   InputParameters params = DerivativeParsedMaterialHelper::validParams();
      18         209 :   params.addClassDescription(
      19             :       "Material for switching function that prevents formation of a third "
      20             :       "phase at a two-phase interface: $h_i = \\eta_i^2/4 [15 (1-\\eta_i) [1 + "
      21             :       "\\eta_i - (\\eta_k - \\eta_j)^2] + \\eta_i (9\\eta_i^2 - 5)]$");
      22         418 :   params.addRequiredCoupledVar("eta_i", "Order parameter i");
      23         418 :   params.addRequiredCoupledVar("eta_j", "Order parameter j");
      24         418 :   params.addRequiredCoupledVar("eta_k", "Order parameter k");
      25         418 :   params.addParam<bool>(
      26             :       "constrain_range",
      27         418 :       false,
      28             :       "Use a formulation that constrains the switching function values to [0:1]. This requires the "
      29             :       "Lagrange multiplier to constrain the sum of the switching function, rather than the etas.");
      30         209 :   return params;
      31           0 : }
      32             : 
      33         165 : SwitchingFunction3PhaseMaterial::SwitchingFunction3PhaseMaterial(const InputParameters & parameters)
      34         165 :   : DerivativeParsedMaterialHelper(parameters), _eta_i("eta_i"), _eta_j("eta_j"), _eta_k("eta_k")
      35             : {
      36         165 :   EBTerm h_i;
      37             : 
      38         330 :   if (getParam<bool>("constrain_range"))
      39             :   {
      40           0 :     EBFunction h;
      41           0 :     EBTerm eta("eta");
      42             : 
      43           0 :     h(eta) =
      44           0 :         conditional(eta < 0, 0, conditional(eta > 1, 1, 3.0 * pow(eta, 2) - 2.0 * pow(eta, 3)));
      45             : 
      46           0 :     h_i = pow(h(_eta_i), 2) / 4.0 *
      47           0 :           (15.0 * (1.0 - h(_eta_i)) * (1.0 + h(_eta_i) - pow(h(_eta_k) - h(_eta_j), 2)) +
      48           0 :            h(_eta_i) * (9.0 * pow(h(_eta_i), 2) - 5.0));
      49           0 :   }
      50             :   else
      51         330 :     h_i = pow(_eta_i, 2) / 4.0 *
      52         330 :           (15.0 * (1.0 - _eta_i) * (1.0 + _eta_i - pow(_eta_k - _eta_j, 2)) +
      53         495 :            _eta_i * (9.0 * pow(_eta_i, 2) - 5.0));
      54             : 
      55             :   // Parse function for automatic differentiation
      56         165 :   functionParse(h_i);
      57         165 : }

Generated by: LCOV version 1.14