LCOV - code coverage report
Current view: top level - include/solidproperties - ThermalSolidProperties.h (source / functions) Hit Total Coverage
Test: idaholab/moose solid_properties: #31405 (292dce) with base fef103 Lines: 4 11 36.4 %
Date: 2025-09-04 07:57:33 Functions: 4 12 33.3 %
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             : #pragma once
      11             : 
      12             : #include "SolidProperties.h"
      13             : 
      14             : /**
      15             :  * Adds default error implementation for non-AD value, which should be overridden in child classes
      16             :  */
      17             : #define propfuncNonADValueOnly(want)                                                               \
      18             :   virtual Real want##_from_T(const Real &) const                                                   \
      19             :   {                                                                                                \
      20             :     mooseError(__PRETTY_FUNCTION__, " not implemented.");                                          \
      21             :   }
      22             : 
      23             : /**
      24             :  * Adds default error implementation for non-AD value and derivatives, which should be overridden
      25             :  * in child classes
      26             :  */
      27             : #define propfuncNonADDerivatives(want)                                                             \
      28             :   virtual void want##_from_T(const Real & T, Real & val, Real & d##want##dT) const                 \
      29             :   {                                                                                                \
      30             :     solidPropError(__PRETTY_FUNCTION__, " derivatives not implemented.");                          \
      31             :     d##want##dT = 0;                                                                               \
      32             :     val = want##_from_T(T);                                                                        \
      33             :   }
      34             : 
      35             : /**
      36             :  * Adds AD versions of each solid property. These functions use the Real versions of these methods
      37             :  * to compute the AD variables complete with derivatives. Typically, these do not need to be
      38             :  * overridden in derived classes.
      39             :  */
      40             : #define propfuncAD(want)                                                                           \
      41             :   virtual ADReal want##_from_T(const ADReal & T) const                                             \
      42             :   {                                                                                                \
      43             :     Real x = 0;                                                                                    \
      44             :     Real raw = T.value();                                                                          \
      45             :     Real dxdT = 0;                                                                                 \
      46             :     want##_from_T(raw, x, dxdT);                                                                   \
      47             :                                                                                                    \
      48             :     ADReal result = x;                                                                             \
      49             :     result.derivatives() = T.derivatives() * dxdT;                                                 \
      50             :     return result;                                                                                 \
      51             :   }
      52             : 
      53             : /**
      54             :  * Adds function definitions with not implemented error. These functions should be overridden in
      55             :  * derived classes where required. AD versions are constructed automatically using propfuncAD.
      56             :  */
      57             : #define propfunc(want) propfuncNonADValueOnly(want) propfuncNonADDerivatives(want) propfuncAD(want)
      58             : 
      59             : /**
      60             :  * Common class for solid properties that are a function of temperature
      61             :  */
      62             : class ThermalSolidProperties : public SolidProperties
      63             : {
      64             : public:
      65             :   static InputParameters validParams();
      66             : 
      67             :   ThermalSolidProperties(const InputParameters & parameters);
      68             : 
      69             : #pragma GCC diagnostic push
      70             : #pragma GCC diagnostic ignored "-Woverloaded-virtual"
      71             :   // clang-format off
      72             : 
      73             :   /**
      74             :    * @brief Compute a solid property as a function of temperature (Kelvin)
      75             :    *
      76             :    * For all functions, the first argument is the given property (temperature)
      77             :    * that defines the solid properties. For the one-argument variants, the desired
      78             :    * property is the return value. The three-argument variants also provide partial
      79             :    * derivatives dx/dT where x is the desired property being computed, and T is the
      80             :    * temperature. The desired property and dx/dT are stored into the 2nd and 3rd
      81             :    * arguments, respectively.
      82             :    *
      83             :    * Properties/parameters used in these function are listed below with their units:
      84             :    *
      85             :    * @begincode
      86             :    * k      thermal conductivity [W/(m*K)]
      87             :    * cp     isobaric specific heat capacity [J/(kg*K)]
      88             :    * rho    density [kg/m^3]
      89             :    * @endcode
      90             :    */
      91             :   ///@{
      92      112045 :   propfunc(k)
      93      112045 :   propfunc(cp)
      94      112084 :   propfunc(rho)
      95             : 
      96             :   /**
      97             :    * Computes the integral of isobaric specific heat capacity w.r.t. temperature,
      98             :    * from the zero-e reference temperature, provided by a user parameter.
      99             :    *
     100             :    * Note that the constant of integration is not included. This function is
     101             :    * called in the \c e_from_T(T) method.
     102             :    */
     103           0 :   virtual Real cp_integral(const Real & /*T*/) const
     104             :   {
     105           0 :     mooseError(__PRETTY_FUNCTION__, " not implemented.");
     106             :   }
     107             : 
     108             :   // Specific internal energy methods; these designed to not be virtual; only
     109             :   // cp_integral(T) needs to be implemented.
     110             :   Real e_from_T(const Real & T) const;
     111             :   void e_from_T(const Real & T, Real & val, Real & dedT) const;
     112          36 :   propfuncAD(e)
     113             :   ///@}
     114             : 
     115             :   // clang-format on
     116             : 
     117             : #undef propfunc
     118             : #undef propfuncAD
     119             : 
     120             :       protected :
     121             :     /// Function to determine how to elevate errors/warnings about missing AD derivatives
     122             :     template <typename... Args>
     123           0 :     void solidPropError(Args... args) const
     124             :   {
     125           0 :     if (_allow_imperfect_jacobians)
     126           0 :       mooseDoOnce(mooseWarning(std::forward<Args>(args)...));
     127             :     else
     128           0 :       mooseError(std::forward<Args>(args)...);
     129           0 :   }
     130             : 
     131             : protected:
     132             :   /// Temperature at which the specific internal energy is assumed to be zero
     133             :   const Real _T_zero_e;
     134             : };
     135             : 
     136             : #pragma GCC diagnostic pop

Generated by: LCOV version 1.14