LCOV - code coverage report
Current view: top level - include/materials - DerivativeMaterialInterfaceTHM.h (source / functions) Hit Total Coverage
Test: idaholab/moose thermal_hydraulics: #30301 (3b550b) with base 2ad78d Lines: 10 10 100.0 %
Date: 2025-07-30 13:02:48 Functions: 3 5 60.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             : #pragma once
      11             : 
      12             : #include "DerivativeMaterialInterface.h"
      13             : 
      14             : template <class T>
      15             : class DerivativeMaterialInterfaceTHM : public DerivativeMaterialInterface<T>
      16             : {
      17             : public:
      18             :   DerivativeMaterialInterfaceTHM(const InputParameters & parameters);
      19             : 
      20             : protected:
      21             :   /**
      22             :    * Method for declaring derivative material properties
      23             :    *
      24             :    * @tparam U The material property type
      25             :    * @param base The name of the property to take the derivative of
      26             :    * @param var_name The name of the coupled variable vector containing the variable to take the
      27             :    * derivative with respect to
      28             :    * @param i The index of the variable to take the derivative with respect to within the coupled
      29             :    * variable vector
      30             :    */
      31             :   template <typename U>
      32             :   MaterialProperty<U> & declarePropertyDerivativeTHM(const std::string & base,
      33             :                                                      const std::string & var_name,
      34             :                                                      const unsigned int i = 0);
      35             : 
      36             :   /**
      37             :    * Method for retrieving derivative material properties
      38             :    *
      39             :    * @tparam U The material property type
      40             :    * @param base The name of the property to take the derivative of
      41             :    * @param var_name The name of the coupled variable vector containing the variable to take the
      42             :    * derivative with respect to
      43             :    * @param i The index of the variable to take the derivative with respect to within the coupled
      44             :    * variable vector
      45             :    */
      46             :   template <typename U>
      47             :   const MaterialProperty<U> & getMaterialPropertyDerivativeTHM(const std::string & base,
      48             :                                                                const std::string & var_name,
      49             :                                                                const unsigned int i = 0);
      50             : 
      51             :   /**
      52             :    * Method for retrieving derivative material properties corresponding to phase-dependent
      53             :    * derivatives.
      54             :    *
      55             :    * The intended behavior of this function is as follows. If the material property
      56             :    * and derivative variable correspond to the same phase, then the material property
      57             :    * is retrieved as usual. Else, a zero-valued material property is returned, as
      58             :    * it is assumed that the material property depends only upon the variables
      59             :    * corresponding to its phase.
      60             :    *
      61             :    * @tparam U The material property type
      62             :    * @param base The name of the property to take the derivative of
      63             :    * @param property_is_liquid  Does the property correspond to the liquid phase?
      64             :    * @param var_name The name of the coupled variable vector containing the variable to take the
      65             :    *   derivative with respect to
      66             :    * @param var_is_liquid  Does the derivative variable correspond to the liquid phase?
      67             :    * @param i The index of the variable to take the derivative with respect to within the coupled
      68             :    *   variable vector
      69             :    */
      70             :   template <typename U>
      71             :   const MaterialProperty<U> & getMaterialPropertyDerivativeTHMPhase(const std::string & base,
      72             :                                                                     bool property_is_liquid,
      73             :                                                                     const std::string & var_name,
      74             :                                                                     bool var_is_liquid,
      75             :                                                                     const unsigned int i = 0);
      76             : };
      77             : 
      78             : template <class T>
      79         582 : DerivativeMaterialInterfaceTHM<T>::DerivativeMaterialInterfaceTHM(
      80             :     const InputParameters & parameters)
      81         582 :   : DerivativeMaterialInterface<T>(parameters)
      82             : {
      83         582 : }
      84             : 
      85             : template <class T>
      86             : template <typename U>
      87             : MaterialProperty<U> &
      88        3951 : DerivativeMaterialInterfaceTHM<T>::declarePropertyDerivativeTHM(const std::string & base,
      89             :                                                                 const std::string & var_name,
      90             :                                                                 const unsigned int i)
      91             : {
      92        7902 :   return this->template declarePropertyDerivative<U>(base, this->coupledName(var_name, i));
      93             : }
      94             : 
      95             : template <class T>
      96             : template <typename U>
      97             : const MaterialProperty<U> &
      98         933 : DerivativeMaterialInterfaceTHM<T>::getMaterialPropertyDerivativeTHM(const std::string & base,
      99             :                                                                     const std::string & var_name,
     100             :                                                                     const unsigned int i)
     101             : {
     102             :   // get the base property name
     103         933 :   const std::string prop_name = this->getMaterialPropertyName(base);
     104             : 
     105             :   // get the name of the variable which derivative is respect to
     106         933 :   const std::string der_var_name = this->coupledName(var_name, i);
     107             : 
     108        1866 :   return this->template getMaterialPropertyByName<U>(
     109         933 :       this->derivativePropertyNameFirst(prop_name, der_var_name));
     110             : }
     111             : 
     112             : template <class T>
     113             : template <typename U>
     114             : const MaterialProperty<U> &
     115             : DerivativeMaterialInterfaceTHM<T>::getMaterialPropertyDerivativeTHMPhase(
     116             :     const std::string & base,
     117             :     bool property_is_liquid,
     118             :     const std::string & var_name,
     119             :     bool var_is_liquid,
     120             :     const unsigned int i)
     121             : {
     122             :   if (property_is_liquid == var_is_liquid)
     123             :   {
     124             :     return getMaterialPropertyDerivativeTHM<U>(base, var_name, i);
     125             :   }
     126             :   else
     127             :   {
     128             :     const std::string prop_name = this->getMaterialPropertyName(base);
     129             :     const std::string der_var_name = this->coupledName(var_name, i);
     130             :     const std::string der_prop_name = this->derivativePropertyNameFirst(prop_name, der_var_name);
     131             :     return this->template getZeroMaterialProperty<U>(der_prop_name);
     132             :   }
     133             : }

Generated by: LCOV version 1.14