LCOV - code coverage report
Current view: top level - src/materials - CrossTermBarrierFunctionBase.C (source / functions) Hit Total Coverage
Test: idaholab/moose phase_field: #31405 (292dce) with base fef103 Lines: 36 38 94.7 %
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 "CrossTermBarrierFunctionBase.h"
      11             : 
      12             : InputParameters
      13         235 : CrossTermBarrierFunctionBase::validParams()
      14             : {
      15         235 :   InputParameters params = Material::validParams();
      16         470 :   params.addParam<std::string>("function_name", "g", "actual name for g(eta_i)");
      17         470 :   MooseEnum g_order("SIMPLE=0 LOW", "SIMPLE");
      18         470 :   params.addParam<MooseEnum>("g_order", g_order, "Polynomial order of the barrier function g(eta)");
      19         470 :   params.addRequiredCoupledVar("etas", "eta_i order parameters, one for each h");
      20         470 :   params.addRequiredParam<std::vector<Real>>("W_ij",
      21             :                                              "Terms controlling barrier height set W=1 in "
      22             :                                              "DerivativeMultiPhaseMaterial for these to "
      23             :                                              "apply");
      24         235 :   return params;
      25         235 : }
      26             : 
      27         180 : CrossTermBarrierFunctionBase::CrossTermBarrierFunctionBase(const InputParameters & parameters)
      28             :   : DerivativeMaterialInterface<Material>(parameters),
      29         180 :     _function_name(getParam<std::string>("function_name")),
      30         360 :     _g_order(getParam<MooseEnum>("g_order")),
      31         360 :     _W_ij(getParam<std::vector<Real>>("W_ij")),
      32         180 :     _num_eta(coupledComponents("etas")),
      33         180 :     _eta_names(coupledNames("etas")),
      34         180 :     _eta(coupledValues("etas")),
      35         180 :     _prop_g(declareProperty<Real>(_function_name)),
      36         180 :     _prop_dg(_num_eta),
      37         360 :     _prop_d2g(_num_eta)
      38             : {
      39             :   // if Vector W_ij is not the correct size to fill the matrix give error
      40         180 :   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         720 :   for (unsigned int i = 0; i < _num_eta; ++i)
      46         540 :     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         720 :   for (unsigned int i = 0; i < _num_eta; ++i)
      51         540 :     _prop_d2g[i].resize(_num_eta);
      52             : 
      53         720 :   for (unsigned int i = 0; i < _num_eta; ++i)
      54             :   {
      55         540 :     _prop_dg[i] = &declarePropertyDerivative<Real>(_function_name, _eta_names[i]);
      56        1620 :     for (unsigned int j = i; j < _num_eta; ++j)
      57             :     {
      58        1080 :       _prop_d2g[i][j] = _prop_d2g[j][i] =
      59        2160 :           &declarePropertyDerivative<Real>(_function_name, _eta_names[i], _eta_names[j]);
      60             :     }
      61             :   }
      62         180 : }
      63             : 
      64             : void
      65       12000 : CrossTermBarrierFunctionBase::computeQpProperties()
      66             : {
      67             :   // Initialize properties to zero before accumulating
      68       12000 :   _prop_g[_qp] = 0.0;
      69       48000 :   for (unsigned int i = 0; i < _num_eta; ++i)
      70             :   {
      71       36000 :     (*_prop_dg[i])[_qp] = 0.0;
      72       36000 :     (*_prop_d2g[i][i])[_qp] = 0.0;
      73             :   }
      74       12000 : }

Generated by: LCOV version 1.14