LCOV - code coverage report
Current view: top level - src/materials - AnisoHeatConductionMaterial.C (source / functions) Hit Total Coverage
Test: idaholab/moose heat_transfer: #31405 (292dce) with base fef103 Lines: 43 57 75.4 %
Date: 2025-09-04 07:53:51 Functions: 4 10 40.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 "AnisoHeatConductionMaterial.h"
      11             : #include "Function.h"
      12             : #include "ConstantFunction.h"
      13             : #include "MooseMesh.h"
      14             : #include "RankTwoTensorImplementation.h"
      15             : 
      16             : #include "libmesh/quadrature.h"
      17             : 
      18             : registerMooseObject("HeatTransferApp", AnisoHeatConductionMaterial);
      19             : registerMooseObject("HeatTransferApp", ADAnisoHeatConductionMaterial);
      20             : 
      21             : template <bool is_ad>
      22             : InputParameters
      23         448 : AnisoHeatConductionMaterialTempl<is_ad>::validParams()
      24             : {
      25         448 :   InputParameters params = Material::validParams();
      26             : 
      27         896 :   params.addCoupledVar("temperature", "Coupled variable for temperature.");
      28         896 :   params.addParam<Real>(
      29         896 :       "reference_temperature", 293.0, "Reference temperature for thermal conductivity in Kelvin.");
      30         896 :   params.addParam<std::string>("base_name", "Material property base name.");
      31         896 :   params.addRequiredParam<std::vector<Real>>("thermal_conductivity",
      32             :                                              "The thermal conductivity tensor values");
      33         896 :   params.addParam<FunctionName>(
      34             :       "thermal_conductivity_temperature_coefficient_function",
      35             :       "",
      36             :       "Temperature coefficient for thermal conductivity as a function of temperature.");
      37         896 :   params.addRequiredParam<FunctionName>("specific_heat",
      38             :                                         "Specific heat as a function of temperature.");
      39         448 :   params.addClassDescription("General-purpose material model for anisotropic heat conduction");
      40         448 :   return params;
      41           0 : }
      42             : 
      43             : template <bool is_ad>
      44         348 : AnisoHeatConductionMaterialTempl<is_ad>::AnisoHeatConductionMaterialTempl(
      45             :     const InputParameters & parameters)
      46             :   : DerivativeMaterialInterface<Material>(parameters),
      47         348 :     _dim(_subproblem.mesh().dimension()),
      48         696 :     _ref_temp(getParam<Real>("reference_temperature")),
      49             : 
      50         348 :     _has_temp(isCoupled("temperature")),
      51         348 :     _T(coupledGenericValue<is_ad>("temperature")),
      52         348 :     _T_var(coupled("temperature")),
      53         348 :     _T_name(coupledName("temperature", 0)),
      54         696 :     _base_name(isParamValid("base_name") ? getParam<std::string>("base_name") + "_" : ""),
      55             : 
      56         696 :     _user_provided_thermal_conductivity(getParam<std::vector<Real>>("thermal_conductivity")),
      57         348 :     _thermal_conductivity(
      58         348 :         declareGenericProperty<RankTwoTensor, is_ad>(_base_name + "thermal_conductivity")),
      59         348 :     _dthermal_conductivity_dT(
      60         696 :         declarePropertyDerivative<RankTwoTensor>(_base_name + "thermal_conductivity", _T_name)),
      61         348 :     _thermal_conductivity_temperature_coefficient_function(
      62         696 :         getParam<FunctionName>("thermal_conductivity_temperature_coefficient_function") != ""
      63         348 :             ? &getFunction("thermal_conductivity_temperature_coefficient_function")
      64             :             : nullptr),
      65             : 
      66         696 :     _specific_heat(declareGenericProperty<Real, is_ad>(_base_name + "specific_heat")),
      67         348 :     _dspecific_heat_dT(declarePropertyDerivative<Real>(_base_name + "specific_heat", _T_name)),
      68         348 :     _specific_heat_function(&getFunction("specific_heat")),
      69         348 :     _ad_q_point(is_ad ? &_assembly.adQPoints() : nullptr)
      70             : {
      71         348 : }
      72             : 
      73             : template <bool is_ad>
      74             : void
      75           0 : AnisoHeatConductionMaterialTempl<is_ad>::initQpStatefulProperties()
      76             : {
      77           0 :   _thermal_conductivity[_qp] = _user_provided_thermal_conductivity;
      78           0 :   DerivativeMaterialInterface::initQpStatefulProperties();
      79           0 : }
      80             : 
      81             : template <>
      82             : auto
      83           0 : AnisoHeatConductionMaterialTempl<true>::genericQPoints()
      84             : {
      85           0 :   return (*_ad_q_point)[_qp];
      86             : }
      87             : 
      88             : template <>
      89             : auto
      90      108180 : AnisoHeatConductionMaterialTempl<false>::genericQPoints()
      91             : {
      92      108180 :   return _q_point[_qp];
      93             : }
      94             : 
      95             : template <bool is_ad>
      96             : void
      97      108180 : AnisoHeatConductionMaterialTempl<is_ad>::computeQpProperties()
      98             : {
      99      108180 :   const auto & temp_qp = _T[_qp];
     100      108180 :   const auto & p = genericQPoints();
     101             : 
     102      108180 :   if (_thermal_conductivity_temperature_coefficient_function)
     103             :   {
     104             : 
     105           0 :     _thermal_conductivity[_qp] =
     106             :         _user_provided_thermal_conductivity *
     107           0 :         (1.0 + _thermal_conductivity_temperature_coefficient_function->value(temp_qp, p) *
     108           0 :                    (temp_qp - _ref_temp));
     109           0 :     _dthermal_conductivity_dT[_qp] =
     110             :         _user_provided_thermal_conductivity *
     111           0 :         _thermal_conductivity_temperature_coefficient_function->timeDerivative(
     112           0 :             MetaPhysicL::raw_value(temp_qp), _q_point[_qp]) *
     113           0 :         MetaPhysicL::raw_value(temp_qp - _ref_temp);
     114             :   }
     115             :   else
     116      108180 :     _thermal_conductivity[_qp] = _user_provided_thermal_conductivity;
     117             : 
     118      108180 :   _specific_heat[_qp] = _specific_heat_function->value(temp_qp, p);
     119      108180 :   _dspecific_heat_dT[_qp] =
     120      108180 :       _specific_heat_function->timeDerivative(MetaPhysicL::raw_value(temp_qp), _q_point[_qp]);
     121      108180 : }
     122             : 
     123             : template class AnisoHeatConductionMaterialTempl<false>;
     124             : template class AnisoHeatConductionMaterialTempl<true>;

Generated by: LCOV version 1.14