LCOV - code coverage report
Current view: top level - src/materials - GrandPotentialTensorMaterial.C (source / functions) Hit Total Coverage
Test: idaholab/moose phase_field: #31405 (292dce) with base fef103 Lines: 66 67 98.5 %
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 "GrandPotentialTensorMaterial.h"
      11             : 
      12             : // libMesh includes
      13             : #include "libmesh/quadrature.h"
      14             : 
      15             : registerMooseObject("PhaseFieldApp", GrandPotentialTensorMaterial);
      16             : 
      17             : InputParameters
      18         329 : GrandPotentialTensorMaterial::validParams()
      19             : {
      20         329 :   InputParameters params = PolycrystalDiffusivityTensorBase::validParams();
      21         329 :   params.addClassDescription("Diffusion and mobility parameters for grand potential model "
      22             :                              "governing equations. Uses a tensor diffusivity");
      23         658 :   params.addRequiredParam<Real>("int_width",
      24             :                                 "The interfacial width in the lengthscale of the problem");
      25         658 :   params.addParam<MaterialPropertyName>("chi", "Coefficient to multiply by D");
      26         658 :   params.addParam<Real>("GBmob0", 0.0, "Grain boundary mobility prefactor");
      27         658 :   params.addRequiredParam<Real>("Q", "Grain boundary migration activation energy in eV");
      28         658 :   params.addParam<Real>(
      29         658 :       "GBMobility", -1, "GB mobility input that overrides the temperature dependent calculation");
      30         658 :   params.addParam<std::string>("f_name", "chiD", "Name for the mobility material property");
      31         658 :   params.addRequiredParam<MaterialPropertyName>("surface_energy", "Surface energy of material");
      32         658 :   params.addParam<std::string>("solid_mobility", "L", "Name of grain mobility for solid phase");
      33         658 :   params.addParam<std::string>("void_mobility", "Lv", "Name of void phase mobility");
      34         329 :   return params;
      35           0 : }
      36             : 
      37         252 : GrandPotentialTensorMaterial::GrandPotentialTensorMaterial(const InputParameters & parameters)
      38             :   : PolycrystalDiffusivityTensorBase(parameters),
      39         252 :     _chiD_name(getParam<std::string>("f_name")),
      40         252 :     _chiD(declareProperty<RealTensorValue>(_chiD_name)),
      41         252 :     _dchiDdc(isCoupledConstant(_c_name)
      42         252 :                  ? nullptr
      43         504 :                  : &declarePropertyDerivative<RealTensorValue>(_chiD_name, _c_name)),
      44         252 :     _dchiDdgradc(isCoupledConstant(_c_name)
      45         252 :                      ? nullptr
      46         756 :                      : &declarePropertyDerivative<RankThreeTensor>(_chiD_name, "gradc")),
      47         504 :     _Ls_name(getParam<std::string>("solid_mobility")),
      48         252 :     _Ls(declareProperty<Real>(_Ls_name)),
      49         504 :     _Lv_name(getParam<std::string>("void_mobility")),
      50         252 :     _Lv(declareProperty<Real>(_Lv_name)),
      51         252 :     _chiDmag(declareProperty<Real>(_chiD_name + "_mag")),
      52         504 :     _sigma_s(getMaterialProperty<Real>("surface_energy")),
      53         504 :     _int_width(getParam<Real>("int_width")),
      54         504 :     _chi_name(getParam<MaterialPropertyName>("chi")),
      55         252 :     _chi(getMaterialProperty<Real>(_chi_name)),
      56         252 :     _dchidc(getMaterialPropertyDerivative<Real>(_chi_name, _c_name)),
      57         252 :     _dchideta(_op_num),
      58         252 :     _dchiDdeta(_op_num),
      59         252 :     _dchiDdgradeta(_op_num),
      60         504 :     _GBMobility(getParam<Real>("GBMobility")),
      61         504 :     _GBmob0(getParam<Real>("GBmob0")),
      62         756 :     _Q(getParam<Real>("Q"))
      63             : {
      64         828 :   for (unsigned int i = 0; i < _op_num; ++i)
      65             :   {
      66         576 :     _dchideta[i] = &getMaterialPropertyDerivative<Real>(_chi_name, _vals_name[i]);
      67         576 :     if (!isCoupledConstant(_vals_name[i]))
      68         576 :       _dchiDdeta[i] = &declarePropertyDerivative<RealTensorValue>(_chiD_name, _vals_name[i]);
      69         576 :     if (!isCoupledConstant(_vals_name[i]))
      70         576 :       _dchiDdgradeta[i] =
      71        1152 :           &declarePropertyDerivative<RankThreeTensor>(_chiD_name, ("grad" + _vals_name[i]));
      72             :   }
      73         252 : }
      74             : 
      75             : void
      76     2148553 : GrandPotentialTensorMaterial::computeProperties()
      77             : {
      78     2148553 :   PolycrystalDiffusivityTensorBase::computeProperties();
      79             : 
      80     9859565 :   for (_qp = 0; _qp < _qrule->n_points(); ++_qp)
      81             :   {
      82     7711012 :     _chiD[_qp] = _D[_qp] * _chi[_qp];
      83     7711012 :     if (_dchiDdc)
      84     7711012 :       (*_dchiDdc)[_qp] = (*_dDdc)[_qp] * _chi[_qp] + _D[_qp] * _dchidc[_qp];
      85     7711012 :     if (_dchiDdgradc)
      86     7711012 :       (*_dchiDdgradc)[_qp] = (*_dDdgradc)[_qp] * _chi[_qp];
      87    23195460 :     for (unsigned int i = 0; i < _op_num; ++i)
      88             :     {
      89    15484448 :       if (_dchiDdeta[i])
      90    15484448 :         (*_dchiDdeta[i])[_qp] = _D[_qp] * (*_dchideta[i])[_qp] + (*_dDdeta[i])[_qp] * _chi[_qp];
      91    15484448 :       if (_dchiDdgradeta[i])
      92    15484448 :         (*_dchiDdgradeta[i])[_qp] = (*_dDdgradeta[i])[_qp] * _chi[_qp];
      93             :     }
      94             : 
      95     7711012 :     _chiDmag[_qp] = _chiD[_qp].norm();
      96             : 
      97             :     Real GBmob;
      98     7711012 :     if (_GBMobility < 0)
      99     7711012 :       GBmob = _GBmob0 * std::exp(-_Q / (_kb * _T[_qp]));
     100             :     else
     101             :       GBmob = _GBMobility;
     102             : 
     103     7711012 :     _Ls[_qp] = 4.0 / 3.0 * GBmob / _int_width;
     104     7711012 :     _Lv[_qp] = 40 * _Ls[_qp];
     105             :   }
     106     2148553 : }

Generated by: LCOV version 1.14