LCOV - code coverage report
Current view: top level - src/materials - CrossTermBarrierFunctionMaterial.C (source / functions) Hit Total Coverage
Test: idaholab/moose phase_field: #32971 (54bef8) with base c6cf66 Lines: 34 38 89.5 %
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 "CrossTermBarrierFunctionMaterial.h"
      11             : 
      12             : registerMooseObject("PhaseFieldApp", CrossTermBarrierFunctionMaterial);
      13             : 
      14             : InputParameters
      15          62 : CrossTermBarrierFunctionMaterial::validParams()
      16             : {
      17          62 :   InputParameters params = CrossTermBarrierFunctionBase::validParams();
      18          62 :   params.addClassDescription(
      19             :       "Free energy contribution symmetric across interfaces between arbitrary pairs of phases.");
      20          62 :   return params;
      21           0 : }
      22             : 
      23          48 : CrossTermBarrierFunctionMaterial::CrossTermBarrierFunctionMaterial(
      24          48 :     const InputParameters & parameters)
      25          48 :   : CrossTermBarrierFunctionBase(parameters)
      26             : {
      27             :   // error out if W_ij is not symmetric
      28         192 :   for (unsigned int i = 0; i < _num_eta; ++i)
      29         288 :     for (unsigned int j = 0; j < i; ++j)
      30         144 :       if (_W_ij[_num_eta * i + j] != _W_ij[_num_eta * j + i])
      31           0 :         paramError("W_ij", "Please supply a symmetric W_ij matrix");
      32          48 : }
      33             : 
      34             : void
      35        4000 : CrossTermBarrierFunctionMaterial::computeQpProperties()
      36             : {
      37             :   // Initialize properties to zero before accumulating
      38        4000 :   CrossTermBarrierFunctionBase::computeQpProperties();
      39             : 
      40             :   // Sum the components of our W_ij matrix to get constant used in our g function
      41       16000 :   for (unsigned int i = 0; i < _num_eta; ++i)
      42       24000 :     for (unsigned int j = i + 1; j < _num_eta; ++j)
      43             :     {
      44       12000 :       const Real ni = (*_eta[i])[_qp];
      45       12000 :       const Real nj = (*_eta[j])[_qp];
      46       12000 :       const Real Wij = _W_ij[_num_eta * i + j];
      47             : 
      48       12000 :       switch (_g_order)
      49             :       {
      50        6000 :         case 0: // SIMPLE
      51        6000 :           _prop_g[_qp] += 16.0 * Wij * (ni * ni * nj * nj);
      52             :           // first derivatives
      53        6000 :           (*_prop_dg[i])[_qp] += 16.0 * Wij * (2 * ni * nj * nj);
      54        6000 :           (*_prop_dg[j])[_qp] += 16.0 * Wij * (2 * ni * ni * nj);
      55             :           // second derivatives (diagonal)
      56        6000 :           (*_prop_d2g[i][i])[_qp] += 16.0 * Wij * (2 * nj * nj);
      57        6000 :           (*_prop_d2g[j][j])[_qp] += 16.0 * Wij * (2 * ni * ni);
      58             :           // second derivatives (off-diagonal)
      59        6000 :           (*_prop_d2g[i][j])[_qp] = 16.0 * Wij * (4 * ni * nj);
      60        6000 :           break;
      61             : 
      62        6000 :         case 1: // LOW
      63        6000 :           _prop_g[_qp] += 4.0 * Wij * (ni * nj);
      64             :           // first derivatives
      65        6000 :           (*_prop_dg[i])[_qp] += 4.0 * Wij * nj;
      66        6000 :           (*_prop_dg[j])[_qp] += 4.0 * Wij * ni;
      67             :           // second derivatives (diagonal) vanish
      68             :           // second derivatives (off-diagonal)
      69        6000 :           (*_prop_d2g[i][j])[_qp] = 4.0 * Wij;
      70        6000 :           break;
      71             : 
      72           0 :         default:
      73           0 :           mooseError("Internal error");
      74             :       }
      75             :     }
      76        4000 : }

Generated by: LCOV version 1.14