LCOV - code coverage report
Current view: top level - src/auxkernels - PFCEnergyDensity.C (source / functions) Hit Total Coverage
Test: idaholab/moose phase_field: #31405 (292dce) with base fef103 Lines: 28 29 96.6 %
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 "PFCEnergyDensity.h"
      11             : #include "libmesh/utility.h"
      12             : 
      13             : registerMooseObject("PhaseFieldApp", PFCEnergyDensity);
      14             : 
      15             : InputParameters
      16          23 : PFCEnergyDensity::validParams()
      17             : {
      18          23 :   InputParameters params = AuxKernel::validParams();
      19          23 :   params.addClassDescription("Computes the crystal free energy density");
      20          46 :   params.addRequiredCoupledVar("v", "Array of coupled variables");
      21          23 :   return params;
      22           0 : }
      23             : 
      24          12 : PFCEnergyDensity::PFCEnergyDensity(const InputParameters & parameters)
      25             :   : AuxKernel(parameters),
      26          24 :     _vals(coupledValues("v")),
      27          12 :     _order(coupledComponents("v")),
      28          12 :     _a(getMaterialProperty<Real>("a")),
      29          24 :     _b(getMaterialProperty<Real>("b"))
      30             : {
      31          12 :   _coeff.resize(_order);
      32             : 
      33          12 :   std::string coeff_name_base = "C";
      34             : 
      35          48 :   for (unsigned int i = 0; i < _order; ++i)
      36             :   {
      37          36 :     std::string coeff_name = coeff_name_base;
      38          36 :     std::stringstream out;
      39          36 :     out << i * 2;
      40          36 :     coeff_name.append(out.str());
      41          36 :     _console << coeff_name << std::endl;
      42          36 :     _coeff[i] = &getMaterialProperty<Real>(coeff_name);
      43          36 :   }
      44          12 : }
      45             : 
      46             : Real
      47       11700 : PFCEnergyDensity::computeValue()
      48             : {
      49       11700 :   Real val = Utility::pow<2>((*_vals[0])[_qp]) * (1.0 - (*_coeff[0])[_qp]) / 2.0;
      50             : 
      51             :   // Loop Through Variables
      52             :   // the sign of negative terms have been taken care of by changing the sign of the coefficients;
      53       35100 :   for (unsigned int i = 1; i < _order; ++i)
      54       23400 :     val += (*_coeff[i])[_qp] * (*_vals[0])[_qp] * (*_vals[i])[_qp] / 2.0;
      55             : 
      56       11700 :   val += (_b[_qp] / 12.0 * Utility::pow<4>((*_vals[0])[_qp])) -
      57       11700 :          (_a[_qp] / 6.0 * Utility::pow<3>((*_vals[0])[_qp]));
      58             : 
      59       11700 :   return val;
      60             : }

Generated by: LCOV version 1.14