LCOV - code coverage report
Current view: top level - src/auxkernels - TotalFreeEnergy.C (source / functions) Hit Total Coverage
Test: idaholab/moose phase_field: #32971 (54bef8) with base c6cf66 Lines: 18 20 90.0 %
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 "TotalFreeEnergy.h"
      11             : 
      12             : registerMooseObject("PhaseFieldApp", TotalFreeEnergy);
      13             : 
      14             : InputParameters
      15         164 : TotalFreeEnergy::validParams()
      16             : {
      17         164 :   InputParameters params = TotalFreeEnergyBase::validParams();
      18         164 :   params.addClassDescription("Total free energy (both the bulk and gradient parts), where the bulk "
      19             :                              "free energy has been defined in a material");
      20         328 :   params.addParam<MaterialPropertyName>("f_name", "F", " Base name of the free energy function");
      21         164 :   params.addParam<std::vector<MaterialPropertyName>>("kappa_names",
      22         164 :                                                      std::vector<MaterialPropertyName>(),
      23             :                                                      "Vector of kappa names corresponding to "
      24             :                                                      "each variable name in interfacial_vars "
      25             :                                                      "in the same order.");
      26         164 :   return params;
      27           0 : }
      28             : 
      29          88 : TotalFreeEnergy::TotalFreeEnergy(const InputParameters & parameters)
      30          88 :   : TotalFreeEnergyBase(parameters), _F(getMaterialProperty<Real>("f_name")), _kappas(_nkappas)
      31             : {
      32             :   // Error check to ensure size of interfacial_vars is the same as kappa_names
      33          88 :   if (_nvars != _nkappas)
      34           0 :     mooseError(
      35             :         "Size of interfacial_vars is not equal to the size of kappa_names in TotalFreeEnergy");
      36             : 
      37             :   // Assign kappa values
      38         200 :   for (unsigned int i = 0; i < _nkappas; ++i)
      39         112 :     _kappas[i] = &getMaterialPropertyByName<Real>(_kappa_names[i]);
      40          88 : }
      41             : 
      42             : Real
      43     2904016 : TotalFreeEnergy::computeValue()
      44             : {
      45             :   // Include bulk energy contribution and additional contributions
      46     2904016 :   Real total_energy = _F[_qp] + _additional_free_energy[_qp];
      47             : 
      48             :   // Calculate interfacial energy of each variable
      49     6527648 :   for (unsigned int i = 0; i < _nvars; ++i)
      50     3623632 :     total_energy += (*_kappas[i])[_qp] / 2.0 * (*_grad_vars[i])[_qp].norm_sq();
      51             : 
      52     2904016 :   return total_energy;
      53             : }

Generated by: LCOV version 1.14