LCOV - code coverage report
Current view: top level - src/auxkernels - CrossTermGradientFreeEnergy.C (source / functions) Hit Total Coverage
Test: idaholab/moose phase_field: #31405 (292dce) with base fef103 Lines: 20 22 90.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 "CrossTermGradientFreeEnergy.h"
      11             : 
      12             : registerMooseObject("PhaseFieldApp", CrossTermGradientFreeEnergy);
      13             : 
      14             : InputParameters
      15          40 : CrossTermGradientFreeEnergy::validParams()
      16             : {
      17          40 :   InputParameters params = TotalFreeEnergyBase::validParams();
      18          40 :   params.addClassDescription("Free energy contribution from the cross terms in ACMultiInterface");
      19          80 :   params.addRequiredParam<std::vector<MaterialPropertyName>>(
      20             :       "kappa_names",
      21             :       "Matrix of kappa names with rows and columns corresponding to each variable "
      22             :       "name in interfacial_vars in the same order (should be symmetric).");
      23          40 :   return params;
      24           0 : }
      25             : 
      26          21 : CrossTermGradientFreeEnergy::CrossTermGradientFreeEnergy(const InputParameters & parameters)
      27          21 :   : TotalFreeEnergyBase(parameters), _kappas(_nvars)
      28             : {
      29             :   // Error check to ensure size of interfacial_vars is the same as kappa_names
      30          21 :   if (_nvars * _nvars != _nkappas)
      31           0 :     paramError("kappa_names",
      32             :                "Size of interfacial_vars squared is not equal to the size of kappa_names in "
      33             :                "CrossTermGradientFreeEnergy");
      34             : 
      35             :   // Assign kappa values
      36          84 :   for (unsigned int i = 0; i < _nvars; ++i)
      37             :   {
      38          63 :     _kappas[i].resize(_nvars);
      39             : 
      40         252 :     for (unsigned int j = 0; j < _nvars; ++j)
      41         189 :       _kappas[i][j] = &getMaterialPropertyByName<Real>(_kappa_names[i * _nvars + j]);
      42             :   }
      43          21 : }
      44             : 
      45             : Real
      46      163200 : CrossTermGradientFreeEnergy::computeValue()
      47             : {
      48             :   // This kernel does _not_ include the bulk energy contribution.
      49             :   // It is to be used as an additional free energy component in TotalFreeEnergy.
      50             :   // additional_free_energy can be used to daisy chain contributions!
      51      163200 :   Real total_energy = _additional_free_energy[_qp];
      52             : 
      53             :   // Calculate interfacial energy of each variable combination
      54      652800 :   for (unsigned int i = 0; i < _nvars; ++i)
      55      979200 :     for (unsigned int j = 0; j < i; ++j)
      56             :     {
      57             :       const RealGradient cross =
      58      489600 :           (*_vars[i])[_qp] * (*_grad_vars[j])[_qp] + (*_vars[j])[_qp] * (*_grad_vars[i])[_qp];
      59      489600 :       total_energy += (*_kappas[i][j])[_qp] / 2.0 * cross * cross;
      60             :     }
      61      163200 :   return total_energy;
      62             : }

Generated by: LCOV version 1.14