LCOV - code coverage report
Current view: top level - src/materials - CrossTermBarrierFunctionBase.C (source / functions) Hit Total Coverage
Test: idaholab/moose phase_field: #32971 (54bef8) with base c6cf66 Lines: 36 38 94.7 %
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 "CrossTermBarrierFunctionBase.h"
      11             : 
      12             : InputParameters
      13         155 : CrossTermBarrierFunctionBase::validParams()
      14             : {
      15         155 :   InputParameters params = Material::validParams();
      16         310 :   params.addParam<std::string>("function_name", "g", "actual name for g(eta_i)");
      17         310 :   MooseEnum g_order("SIMPLE=0 LOW", "SIMPLE");
      18         310 :   params.addParam<MooseEnum>("g_order", g_order, "Polynomial order of the barrier function g(eta)");
      19         310 :   params.addRequiredCoupledVar("etas", "eta_i order parameters, one for each h");
      20         310 :   params.addRequiredParam<std::vector<Real>>("W_ij",
      21             :                                              "Terms controlling barrier height set W=1 in "
      22             :                                              "DerivativeMultiPhaseMaterial for these to "
      23             :                                              "apply");
      24         155 :   return params;
      25         155 : }
      26             : 
      27         120 : CrossTermBarrierFunctionBase::CrossTermBarrierFunctionBase(const InputParameters & parameters)
      28             :   : DerivativeMaterialInterface<Material>(parameters),
      29         120 :     _function_name(getParam<std::string>("function_name")),
      30         240 :     _g_order(getParam<MooseEnum>("g_order")),
      31         240 :     _W_ij(getParam<std::vector<Real>>("W_ij")),
      32         120 :     _num_eta(coupledComponents("etas")),
      33         120 :     _eta_names(coupledNames("etas")),
      34         120 :     _eta(coupledValues("etas")),
      35         120 :     _prop_g(declareProperty<Real>(_function_name)),
      36         120 :     _prop_dg(_num_eta),
      37         240 :     _prop_d2g(_num_eta)
      38             : {
      39             :   // if Vector W_ij is not the correct size to fill the matrix give error
      40         120 :   if (_num_eta * _num_eta != _W_ij.size())
      41           0 :     paramError("W_ij",
      42             :                "Size of W_ij does not match (number of etas)^2. Supply W_ij of correct size.");
      43             : 
      44             :   // error out if the W_ij diagonal values are not zero
      45         480 :   for (unsigned int i = 0; i < _num_eta; ++i)
      46         360 :     if (_W_ij[_num_eta * i + i] != 0)
      47           0 :       paramError("W_ij", "Set on-diagonal values of W_ij to zero.");
      48             : 
      49             :   // declare g derivative properties, fetch eta values
      50         480 :   for (unsigned int i = 0; i < _num_eta; ++i)
      51         360 :     _prop_d2g[i].resize(_num_eta);
      52             : 
      53         480 :   for (unsigned int i = 0; i < _num_eta; ++i)
      54             :   {
      55         360 :     _prop_dg[i] = &declarePropertyDerivative<Real>(_function_name, _eta_names[i]);
      56        1080 :     for (unsigned int j = i; j < _num_eta; ++j)
      57             :     {
      58         720 :       _prop_d2g[i][j] = _prop_d2g[j][i] =
      59        1440 :           &declarePropertyDerivative<Real>(_function_name, _eta_names[i], _eta_names[j]);
      60             :     }
      61             :   }
      62         120 : }
      63             : 
      64             : void
      65       10000 : CrossTermBarrierFunctionBase::computeQpProperties()
      66             : {
      67             :   // Initialize properties to zero before accumulating
      68       10000 :   _prop_g[_qp] = 0.0;
      69       40000 :   for (unsigned int i = 0; i < _num_eta; ++i)
      70             :   {
      71       30000 :     (*_prop_dg[i])[_qp] = 0.0;
      72       30000 :     (*_prop_d2g[i][i])[_qp] = 0.0;
      73             :   }
      74       10000 : }

Generated by: LCOV version 1.14