LCOV - code coverage report
Current view: top level - src/materials - ComputeDilatationThermalExpansionFunctionEigenstrain.C (source / functions) Hit Total Coverage
Test: idaholab/moose solid_mechanics: f45d79 Lines: 11 12 91.7 %
Date: 2025-07-25 05:00:39 Functions: 6 6 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 "ComputeDilatationThermalExpansionFunctionEigenstrain.h"
      11             : 
      12             : #include "Function.h"
      13             : 
      14             : registerMooseObject("SolidMechanicsApp", ComputeDilatationThermalExpansionFunctionEigenstrain);
      15             : registerMooseObject("SolidMechanicsApp", ADComputeDilatationThermalExpansionFunctionEigenstrain);
      16             : 
      17             : template <bool is_ad>
      18             : InputParameters
      19          48 : ComputeDilatationThermalExpansionFunctionEigenstrainTempl<is_ad>::validParams()
      20             : {
      21             :   InputParameters params = ComputeDilatationThermalExpansionEigenstrainBase::validParams();
      22          48 :   params.addClassDescription("Computes eigenstrain due to thermal expansion using a function that "
      23             :                              "describes the total dilatation as a function of temperature");
      24          96 :   params.addRequiredParam<FunctionName>(
      25             :       "dilatation_function",
      26             :       "Function describing the thermal dilatation as a function of temperature");
      27          48 :   return params;
      28           0 : }
      29             : 
      30             : template <bool is_ad>
      31          36 : ComputeDilatationThermalExpansionFunctionEigenstrainTempl<is_ad>::
      32             :     ComputeDilatationThermalExpansionFunctionEigenstrainTempl(const InputParameters & parameters)
      33             :   : ComputeDilatationThermalExpansionEigenstrainBaseTempl<is_ad>(parameters),
      34          36 :     _dilatation_function(this->getFunction("dilatation_function"))
      35             : {
      36          36 : }
      37             : 
      38             : template <bool is_ad>
      39             : ValueAndDerivative<is_ad>
      40        9600 : ComputeDilatationThermalExpansionFunctionEigenstrainTempl<is_ad>::computeDilatation(
      41             :     const ValueAndDerivative<is_ad> & temperature)
      42             : {
      43             :   // we need these two branches because we cannot yet evaluate Functions with ChainedReals
      44             :   if constexpr (is_ad)
      45        4800 :     return _dilatation_function.value(temperature);
      46             :   else
      47        4800 :     return {_dilatation_function.value(temperature.value()),
      48        4800 :             _dilatation_function.timeDerivative(temperature.value()) * temperature.derivatives()};
      49             : }
      50             : 
      51             : template class ComputeDilatationThermalExpansionFunctionEigenstrainTempl<false>;
      52             : template class ComputeDilatationThermalExpansionFunctionEigenstrainTempl<true>;

Generated by: LCOV version 1.14