LCOV - code coverage report
Current view: top level - src/materials - DerivativeMultiPhaseMaterial.C (source / functions) Hit Total Coverage
Test: idaholab/moose phase_field: #31405 (292dce) with base fef103 Lines: 32 56 57.1 %
Date: 2025-09-04 07:55:36 Functions: 4 5 80.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 "DerivativeMultiPhaseMaterial.h"
      11             : 
      12             : registerMooseObject("PhaseFieldApp", DerivativeMultiPhaseMaterial);
      13             : 
      14             : InputParameters
      15         223 : DerivativeMultiPhaseMaterial::validParams()
      16             : {
      17         223 :   InputParameters params = DerivativeMultiPhaseBase::validParams();
      18         223 :   params.addClassDescription("Two phase material that combines n phase materials using a switching "
      19             :                              "function with and n non-conserved order parameters (to be used with "
      20             :                              "SwitchingFunctionConstraint*).");
      21         446 :   params.addCoupledVar("etas", "Order parameters for all phases.");
      22         223 :   return params;
      23           0 : }
      24             : 
      25         171 : DerivativeMultiPhaseMaterial::DerivativeMultiPhaseMaterial(const InputParameters & parameters)
      26         171 :   : DerivativeMultiPhaseBase(parameters), _dhi(_num_etas), _d2hi(_num_etas), _d3hi(_num_etas)
      27             : {
      28             :   // verify that the user supplied one less eta than the number of phases
      29         171 :   if (_num_hi != _num_etas)
      30           0 :     paramError("hi_names", "The number of hi_names must be equal to the number of coupled etas");
      31             : 
      32         612 :   for (unsigned int i = 0; i < _num_etas; ++i)
      33             :   {
      34         441 :     _dhi[i] = &getMaterialPropertyDerivative<Real>(_hi_names[i], _eta_names[i]);
      35         441 :     _d2hi[i] = &getMaterialPropertyDerivative<Real>(_hi_names[i], _eta_names[i], _eta_names[i]);
      36             : 
      37         441 :     if (_third_derivatives)
      38          81 :       _d3hi[i] = &getMaterialPropertyDerivative<Real>(
      39             :           _hi_names[i], _eta_names[i], _eta_names[i], _eta_names[i]);
      40             :   }
      41         171 : }
      42             : 
      43             : Real
      44     5378160 : DerivativeMultiPhaseMaterial::computeDF(unsigned int i_var)
      45             : {
      46             :   const unsigned int i = argIndex(i_var);
      47     5378160 :   const int i_eta = _eta_index[i];
      48             : 
      49     5378160 :   if (i_eta >= 0)
      50     4455840 :     return (*_dhi[i_eta])[_qp] * (*_prop_Fi[i_eta])[_qp] + _W * (*_dg[i_eta])[_qp];
      51             :   else
      52             :   {
      53             :     Real dF = 0.0;
      54     2766960 :     for (unsigned n = 0; n < _num_fi; ++n)
      55     1844640 :       dF += (*_hi[n])[_qp] * (*_prop_dFi[n][i])[_qp];
      56      922320 :     return dF;
      57             :   }
      58             : }
      59             : 
      60             : Real
      61    10756320 : DerivativeMultiPhaseMaterial::computeD2F(unsigned int i_var, unsigned int j_var)
      62             : {
      63             :   const unsigned int i = argIndex(i_var);
      64    10756320 :   const int i_eta = _eta_index[i];
      65             :   const unsigned int j = argIndex(j_var);
      66    10756320 :   const int j_eta = _eta_index[j];
      67             : 
      68             :   // all arguments are eta-variables
      69             : 
      70    10756320 :   if (i_eta >= 0 && j_eta >= 0)
      71             :   {
      72             :     // if the derivatives are taken w.r.t. a single eta the d2hi term for eta_i appears, otherwise
      73             :     // it drops out
      74             :     // because we assume that hi _only_ depends on eta_i
      75     7989360 :     Real d2F = (i_eta == j_eta) ? (*_d2hi[i_eta])[_qp] * (*_prop_Fi[i_eta])[_qp] : 0.0;
      76             : 
      77     7989360 :     return d2F + _W * (*_d2g[i_eta][j_eta])[_qp];
      78             :   }
      79             : 
      80             :   // one argument is an eta-variable
      81             : 
      82     2766960 :   if (i_eta >= 0)
      83           0 :     return (*_dhi[i_eta])[_qp] * (*_prop_dFi[i_eta][j])[_qp];
      84             : 
      85     2766960 :   if (j_eta >= 0)
      86     1844640 :     return (*_dhi[j_eta])[_qp] * (*_prop_dFi[j_eta][i])[_qp];
      87             : 
      88             :   // no arguments are eta-variables
      89             : 
      90             :   Real d2F = 0.0;
      91     2766960 :   for (unsigned n = 0; n < _num_fi; ++n)
      92     1844640 :     d2F += (*_hi[n])[_qp] * (*_prop_d2Fi[n][i][j])[_qp];
      93             :   return d2F;
      94             : }
      95             : 
      96             : Real
      97           0 : DerivativeMultiPhaseMaterial::computeD3F(unsigned int i_var, unsigned int j_var, unsigned int k_var)
      98             : {
      99             :   const unsigned int i = argIndex(i_var);
     100           0 :   const int i_eta = _eta_index[i];
     101             :   const unsigned int j = argIndex(j_var);
     102           0 :   const int j_eta = _eta_index[j];
     103             :   const unsigned int k = argIndex(k_var);
     104           0 :   const int k_eta = _eta_index[k];
     105             : 
     106             :   // all arguments are eta-variables
     107             : 
     108           0 :   if (i_eta >= 0 && j_eta >= 0 && k_eta >= 0)
     109             :   {
     110             :     // if the derivatives are taken w.r.t. a single eta the d3hi term for eta_i appears, otherwise
     111             :     // it drops out
     112             :     // because we assume that hi _only_ depends on eta_i
     113             :     Real d3F =
     114           0 :         (i_eta == j_eta && j_eta == k_eta) ? (*_d3hi[i_eta])[_qp] * (*_prop_Fi[i_eta])[_qp] : 0.0;
     115             : 
     116           0 :     return d3F + _W * (*_d3g[i_eta][j_eta][k_eta])[_qp];
     117             :   }
     118             : 
     119             :   // two arguments are eta-variables
     120             : 
     121           0 :   if (i_eta >= 0 && j_eta >= 0)
     122           0 :     return (i_eta == j_eta) ? (*_d2hi[i_eta])[_qp] * (*_prop_dFi[i_eta][k])[_qp] : 0.0;
     123             : 
     124           0 :   if (j_eta >= 0 && k_eta >= 0)
     125           0 :     return (j_eta == k_eta) ? (*_d2hi[j_eta])[_qp] * (*_prop_dFi[j_eta][i])[_qp] : 0.0;
     126             : 
     127           0 :   if (k_eta >= 0 && i_eta >= 0)
     128           0 :     return (k_eta == i_eta) ? (*_d2hi[k_eta])[_qp] * (*_prop_dFi[k_eta][j])[_qp] : 0.0;
     129             : 
     130             :   // one argument is an eta-variable
     131             : 
     132           0 :   if (i_eta >= 0)
     133           0 :     return (*_dhi[i_eta])[_qp] * (*_prop_d2Fi[i_eta][j][k])[_qp];
     134             : 
     135           0 :   if (j_eta >= 0)
     136           0 :     return (*_dhi[j_eta])[_qp] * (*_prop_d2Fi[j_eta][i][k])[_qp];
     137             : 
     138           0 :   if (k_eta >= 0)
     139           0 :     return (*_dhi[k_eta])[_qp] * (*_prop_d2Fi[k_eta][i][j])[_qp];
     140             : 
     141             :   // no arguments are eta-variables
     142             : 
     143             :   Real d3F = 0.0;
     144           0 :   for (unsigned n = 0; n < _num_fi; ++n)
     145           0 :     d3F += (*_hi[n])[_qp] * (*_prop_d3Fi[n][i][j][k])[_qp];
     146             :   return d3F;
     147             : }

Generated by: LCOV version 1.14