LCOV - code coverage report
Current view: top level - src/materials - AsymmetricCrossTermBarrierFunctionMaterial.C (source / functions) Hit Total Coverage
Test: idaholab/moose phase_field: #31405 (292dce) with base fef103 Lines: 51 55 92.7 %
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 "AsymmetricCrossTermBarrierFunctionMaterial.h"
      11             : 
      12             : registerMooseObject("PhaseFieldApp", AsymmetricCrossTermBarrierFunctionMaterial);
      13             : 
      14             : InputParameters
      15         141 : AsymmetricCrossTermBarrierFunctionMaterial::validParams()
      16             : {
      17         141 :   InputParameters params = CrossTermBarrierFunctionBase::validParams();
      18         141 :   params.addClassDescription(
      19             :       "Free energy contribution asymmetric across interfaces between arbitrary pairs of phases.");
      20         282 :   params.addParam<std::vector<MaterialPropertyName>>(
      21             :       "hi_names", "Switching Function Materials that provide h(eta_i)");
      22         141 :   return params;
      23           0 : }
      24             : 
      25         108 : AsymmetricCrossTermBarrierFunctionMaterial::AsymmetricCrossTermBarrierFunctionMaterial(
      26         108 :     const InputParameters & parameters)
      27         108 :   : CrossTermBarrierFunctionBase(parameters), _h(_num_eta), _dh(_num_eta), _d2h(_num_eta)
      28             : {
      29             :   // switching functions
      30             :   const std::vector<MaterialPropertyName> & hi_names =
      31         216 :       getParam<std::vector<MaterialPropertyName>>("hi_names");
      32         108 :   if (hi_names.size() != _num_eta)
      33           0 :     paramError("hi_names", "The number of hi_names must be equal to the number of coupled etas");
      34             : 
      35         432 :   for (unsigned int i = 0; i < _num_eta; ++i)
      36             :   {
      37         324 :     _h[i] = &getMaterialProperty<Real>(hi_names[i]);
      38         324 :     _dh[i] = &getMaterialPropertyDerivative<Real>(hi_names[i], _eta_names[i]);
      39         324 :     _d2h[i] = &getMaterialPropertyDerivative<Real>(hi_names[i], _eta_names[i], _eta_names[i]);
      40             :   }
      41         108 : }
      42             : 
      43             : void
      44        7200 : AsymmetricCrossTermBarrierFunctionMaterial::computeQpProperties()
      45             : {
      46             :   // Initialize properties to zero before accumulating
      47        7200 :   CrossTermBarrierFunctionBase::computeQpProperties();
      48             : 
      49             :   // Sum the components of our W_ij matrix to get constant used in our g function
      50       28800 :   for (unsigned int i = 0; i < _num_eta; ++i)
      51       43200 :     for (unsigned int j = i + 1; j < _num_eta; ++j)
      52             :     {
      53             :       // readable aliases
      54       21600 :       const Real ni = (*_eta[i])[_qp];
      55       21600 :       const Real nj = (*_eta[j])[_qp];
      56             : 
      57       21600 :       const Real Wij = _W_ij[_num_eta * i + j];
      58       21600 :       const Real Wji = _W_ij[_num_eta * j + i];
      59             : 
      60       21600 :       const Real hi = (*_h[i])[_qp];
      61       21600 :       const Real hj = (*_h[j])[_qp];
      62       21600 :       const Real dhi = (*_dh[i])[_qp];
      63       21600 :       const Real dhj = (*_dh[j])[_qp];
      64       21600 :       const Real d2hi = (*_d2h[i])[_qp];
      65       21600 :       const Real d2hj = (*_d2h[j])[_qp];
      66             : 
      67             :       // raw barrier term and derivatives
      68             :       Real B, dBi, dBj, d2Bii, d2Bjj, d2Bij;
      69       21600 :       switch (_g_order)
      70             :       {
      71        7200 :         case 0: // SIMPLE
      72        7200 :           B = 16.0 * ni * ni * nj * nj;
      73        7200 :           dBi = 16.0 * 2.0 * ni * nj * nj;
      74        7200 :           dBj = 16.0 * 2.0 * ni * ni * nj;
      75        7200 :           d2Bii = 16.0 * 2.0 * nj * nj;
      76             :           d2Bjj = 16.0 * 2.0 * ni * ni;
      77        7200 :           d2Bij = 16.0 * 4.0 * ni * nj;
      78        7200 :           break;
      79             : 
      80       14400 :         case 1: // LOW
      81       14400 :           B = 4.0 * ni * nj;
      82       14400 :           dBi = 4.0 * nj;
      83             :           dBj = 4.0 * ni;
      84             :           d2Bii = 0.0;
      85             :           d2Bjj = 0.0;
      86             :           d2Bij = 4.0;
      87       14400 :           break;
      88             : 
      89           0 :         default:
      90           0 :           mooseError("Internal error");
      91             :       }
      92             : 
      93       21600 :       _prop_g[_qp] += (Wij * hi + Wji * hj) * B;
      94             :       // first derivatives
      95       21600 :       (*_prop_dg[i])[_qp] += (Wij * hi + Wji * hj) * dBi + (Wij * dhi) * B;
      96       21600 :       (*_prop_dg[j])[_qp] += (Wij * hi + Wji * hj) * dBj + (Wji * dhj) * B;
      97             :       // second derivatives (diagonal)
      98       21600 :       (*_prop_d2g[i][i])[_qp] +=
      99       21600 :           (Wij * hi + Wji * hj) * d2Bii + 2 * (Wij * dhi) * dBi + (Wij * d2hi) * B;
     100       21600 :       (*_prop_d2g[j][j])[_qp] +=
     101       21600 :           (Wij * hi + Wji * hj) * d2Bjj + 2 * (Wji * dhj) * dBj + (Wji * d2hj) * B;
     102             :       // second derivatives (off-diagonal)
     103       21600 :       (*_prop_d2g[i][j])[_qp] =
     104       21600 :           (Wij * hi + Wji * hj) * (d2Bij) + (Wji * dhj) * dBi + (Wij * dhi) * dBj;
     105             :     }
     106        7200 : }

Generated by: LCOV version 1.14