LCOV - code coverage report
Current view: top level - src/kernels - KKSMultiACBulkBase.C (source / functions) Hit Total Coverage
Test: idaholab/moose phase_field: #32971 (54bef8) with base c6cf66 Lines: 38 40 95.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 "KKSMultiACBulkBase.h"
      11             : 
      12             : InputParameters
      13         536 : KKSMultiACBulkBase::validParams()
      14             : {
      15         536 :   InputParameters params = ACBulk<Real>::validParams();
      16         536 :   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        1072 :   params.addRequiredParam<std::vector<MaterialPropertyName>>(
      20             :       "Fj_names", "List of free energies for each phase. Place in same order as hj_names!");
      21        1072 :   params.addRequiredParam<std::vector<MaterialPropertyName>>(
      22             :       "hj_names", "Switching Function Materials that provide h. Place in same order as Fj_names!");
      23        1072 :   params.addRequiredCoupledVar("eta_i",
      24             :                                "Order parameter that derivatives are taken with respect to");
      25         536 :   return params;
      26           0 : }
      27             : 
      28         286 : KKSMultiACBulkBase::KKSMultiACBulkBase(const InputParameters & parameters)
      29             :   : ACBulk<Real>(parameters),
      30         286 :     _etai_name(coupledName("eta_i", 0)),
      31         286 :     _etai_var(coupled("eta_i", 0)),
      32         858 :     _Fj_names(getParam<std::vector<MaterialPropertyName>>("Fj_names")),
      33         286 :     _num_j(_Fj_names.size()),
      34         286 :     _prop_Fj(_num_j),
      35         286 :     _prop_dFjdarg(_num_j),
      36         572 :     _hj_names(getParam<std::vector<MaterialPropertyName>>("hj_names")),
      37         286 :     _prop_hj(_num_j),
      38         286 :     _prop_dhjdetai(_num_j),
      39         286 :     _prop_d2hjdetai2(_num_j),
      40         572 :     _prop_d2hjdetaidarg(_num_j)
      41             : {
      42             :   // check passed in parameter vectors
      43         286 :   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        1034 :   for (unsigned int n = 0; n < _num_j; ++n)
      48             :   {
      49             :     // get phase free energy
      50         748 :     _prop_Fj[n] = &getMaterialPropertyByName<Real>(_Fj_names[n]);
      51         748 :     _prop_dFjdarg[n].resize(_n_args);
      52             : 
      53             :     // get switching function and derivatives wrt eta_i, the nonlinear variable
      54         748 :     _prop_hj[n] = &getMaterialPropertyByName<Real>(_hj_names[n]);
      55         748 :     _prop_dhjdetai[n] = &getMaterialPropertyDerivative<Real>(_hj_names[n], _etai_name);
      56         748 :     _prop_d2hjdetai2[n] =
      57        1496 :         &getMaterialPropertyDerivative<Real>(_hj_names[n], _etai_name, _etai_name);
      58         748 :     _prop_d2hjdetaidarg[n].resize(_n_args);
      59             : 
      60        5492 :     for (unsigned int i = 0; i < _n_args; ++i)
      61             :     {
      62             :       // Get derivatives of all Fj wrt all coupled variables
      63        4744 :       _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        4744 :       _prop_d2hjdetaidarg[n][i] = &getMaterialPropertyDerivative<Real>(_hj_names[n], _etai_name, i);
      67             :     }
      68             :   }
      69         286 : }
      70             : 
      71             : void
      72         272 : KKSMultiACBulkBase::initialSetup()
      73             : {
      74         272 :   ACBulk<Real>::initialSetup();
      75             : 
      76         992 :   for (unsigned int n = 0; n < _num_j; ++n)
      77             :   {
      78        2160 :     validateNonlinearCoupling<Real>(_Fj_names[n]);
      79        1440 :     validateNonlinearCoupling<Real>(_hj_names[n]);
      80             :   }
      81         272 : }

Generated by: LCOV version 1.14