LCOV - code coverage report
Current view: top level - src/kernels - KKSMultiACBulkBase.C (source / functions) Hit Total Coverage
Test: idaholab/moose phase_field: #31405 (292dce) with base fef103 Lines: 38 40 95.0 %
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 "KKSMultiACBulkBase.h"
      11             : 
      12             : InputParameters
      13         816 : KKSMultiACBulkBase::validParams()
      14             : {
      15         816 :   InputParameters params = ACBulk<Real>::validParams();
      16         816 :   params.addClassDescription("Multi-order parameter KKS model kernel for the Bulk Allen-Cahn. This "
      17             :                              "operates on one of the order parameters 'eta_i' as the non-linear "
      18             :                              "variable");
      19        1632 :   params.addRequiredParam<std::vector<MaterialPropertyName>>(
      20             :       "Fj_names", "List of free energies for each phase. Place in same order as hj_names!");
      21        1632 :   params.addRequiredParam<std::vector<MaterialPropertyName>>(
      22             :       "hj_names", "Switching Function Materials that provide h. Place in same order as Fj_names!");
      23        1632 :   params.addRequiredCoupledVar("eta_i",
      24             :                                "Order parameter that derivatives are taken with respect to");
      25         816 :   return params;
      26           0 : }
      27             : 
      28         426 : KKSMultiACBulkBase::KKSMultiACBulkBase(const InputParameters & parameters)
      29             :   : ACBulk<Real>(parameters),
      30         426 :     _etai_name(coupledName("eta_i", 0)),
      31         426 :     _etai_var(coupled("eta_i", 0)),
      32        1278 :     _Fj_names(getParam<std::vector<MaterialPropertyName>>("Fj_names")),
      33         426 :     _num_j(_Fj_names.size()),
      34         426 :     _prop_Fj(_num_j),
      35         426 :     _prop_dFjdarg(_num_j),
      36         852 :     _hj_names(getParam<std::vector<MaterialPropertyName>>("hj_names")),
      37         426 :     _prop_hj(_num_j),
      38         426 :     _prop_dhjdetai(_num_j),
      39         426 :     _prop_d2hjdetai2(_num_j),
      40         852 :     _prop_d2hjdetaidarg(_num_j)
      41             : {
      42             :   // check passed in parameter vectors
      43         426 :   if (_num_j != _hj_names.size())
      44           0 :     paramError("hj_names", "Need to pass in as many hj_names as Fj_names");
      45             : 
      46             :   // reserve space and set phase material properties
      47        1542 :   for (unsigned int n = 0; n < _num_j; ++n)
      48             :   {
      49             :     // get phase free energy
      50        1116 :     _prop_Fj[n] = &getMaterialPropertyByName<Real>(_Fj_names[n]);
      51        1116 :     _prop_dFjdarg[n].resize(_n_args);
      52             : 
      53             :     // get switching function and derivatives wrt eta_i, the nonlinear variable
      54        1116 :     _prop_hj[n] = &getMaterialPropertyByName<Real>(_hj_names[n]);
      55        1116 :     _prop_dhjdetai[n] = &getMaterialPropertyDerivative<Real>(_hj_names[n], _etai_name);
      56        1116 :     _prop_d2hjdetai2[n] =
      57        2232 :         &getMaterialPropertyDerivative<Real>(_hj_names[n], _etai_name, _etai_name);
      58        1116 :     _prop_d2hjdetaidarg[n].resize(_n_args);
      59             : 
      60        8196 :     for (unsigned int i = 0; i < _n_args; ++i)
      61             :     {
      62             :       // Get derivatives of all Fj wrt all coupled variables
      63        7080 :       _prop_dFjdarg[n][i] = &getMaterialPropertyDerivative<Real>(_Fj_names[n], i);
      64             : 
      65             :       // Get second derivatives of all hj wrt eta_i and all coupled variables
      66        7080 :       _prop_d2hjdetaidarg[n][i] = &getMaterialPropertyDerivative<Real>(_hj_names[n], _etai_name, i);
      67             :     }
      68             :   }
      69         426 : }
      70             : 
      71             : void
      72         408 : KKSMultiACBulkBase::initialSetup()
      73             : {
      74         408 :   ACBulk<Real>::initialSetup();
      75             : 
      76        1488 :   for (unsigned int n = 0; n < _num_j; ++n)
      77             :   {
      78        3240 :     validateNonlinearCoupling<Real>(_Fj_names[n]);
      79        2160 :     validateNonlinearCoupling<Real>(_hj_names[n]);
      80             :   }
      81         408 : }

Generated by: LCOV version 1.14