LCOV - code coverage report
Current view: top level - include/userobjects - InterfaceQpMaterialPropertyBaseUserObject.h (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 39 41 95.1 %
Date: 2025-07-17 01:28:37 Functions: 4 5 80.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 "InterfaceQpUserObjectBase.h"
      13             : 
      14             : /**
      15             :  * Specialization of InterfaceQpUserObjectBase for material properties. Material property type
      16             :  * specialization is achieved by specializing computeScalarMaterialProperty in derived classes.
      17             :  */
      18             : template <typename T>
      19             : class InterfaceQpMaterialPropertyBaseUserObject : public InterfaceQpUserObjectBase
      20             : {
      21             : public:
      22             :   static InputParameters validParams();
      23             :   /**
      24             :    * Class constructor
      25             :    * @param parameters The input parameters for this object
      26             :    */
      27             :   InterfaceQpMaterialPropertyBaseUserObject(const InputParameters & parameters);
      28          36 :   virtual ~InterfaceQpMaterialPropertyBaseUserObject(){};
      29             : 
      30             : protected:
      31             :   /**
      32             :    * method defining the scalar value computation given a scalar material property value
      33             :    **/
      34             :   virtual Real computeRealValue(const unsigned int qp) override final;
      35             :   /**
      36             :    * method returning a scalar material property value given a generic T type
      37             :    **/
      38             :   virtual Real computeScalarMaterialProperty(const MaterialProperty<T> *,
      39             :                                              const unsigned int qp) = 0;
      40             : 
      41             :   /// the material property and neighbor material property current and old value
      42             :   ///@{
      43             :   const MaterialProperty<T> & _prop;
      44             :   const MaterialProperty<T> & _prop_neighbor;
      45             :   const MaterialProperty<T> * const _prop_old;
      46             :   const MaterialProperty<T> * const _prop_neighbor_old;
      47             :   ///@}
      48             : };
      49             : 
      50             : template <typename T>
      51             : InputParameters
      52       14337 : InterfaceQpMaterialPropertyBaseUserObject<T>::validParams()
      53             : {
      54       14337 :   InputParameters params = InterfaceQpUserObjectBase::validParams();
      55       14337 :   params.addRequiredParam<MaterialPropertyName>("property", "The material property name");
      56       14337 :   params.addParam<MaterialPropertyName>("property_neighbor", "The neighbor material property name");
      57       14337 :   params.addClassDescription(
      58             :       "Computes the interface material property value or rate across an interface. The value or "
      59             :       "rate is computed according to the provided interface_value_type parameter.");
      60       14337 :   return params;
      61           0 : }
      62             : 
      63             : template <typename T>
      64          36 : InterfaceQpMaterialPropertyBaseUserObject<T>::InterfaceQpMaterialPropertyBaseUserObject(
      65             :     const InputParameters & parameters)
      66             :   : InterfaceQpUserObjectBase(parameters),
      67          36 :     _prop(getMaterialProperty<T>("property")),
      68          72 :     _prop_neighbor(parameters.isParamSetByUser("property_neighbor")
      69          72 :                        ? getNeighborMaterialProperty<T>("property_neighbor")
      70          36 :                        : getNeighborMaterialProperty<T>("property")),
      71          36 :     _prop_old(_value_type > 0 ? &getMaterialPropertyOld<T>("property") : nullptr),
      72          36 :     _prop_neighbor_old(_value_type > 0
      73          96 :                            ? ((parameters.isParamSetByUser("property_neighbor")
      74          60 :                                    ? &getNeighborMaterialPropertyOld<T>("property_neighbor")
      75          36 :                                    : &getNeighborMaterialPropertyOld<T>("property")))
      76          36 :                            : nullptr)
      77             : {
      78          36 : }
      79             : 
      80             : template <typename T>
      81             : Real
      82        1704 : InterfaceQpMaterialPropertyBaseUserObject<T>::computeRealValue(const unsigned int qp)
      83             : {
      84        1704 :   Real value_primary = 0;
      85        1704 :   Real value_secondary = 0;
      86             :   // using an if else here because a switch produce an unkown error in the docuemantion test
      87        1704 :   if (_value_type == 0) /*value*/
      88             :   {
      89         568 :     value_primary = computeScalarMaterialProperty(&_prop, qp);
      90         568 :     value_secondary = computeScalarMaterialProperty(&_prop_neighbor, qp);
      91             :   }
      92        1136 :   else if (_value_type == 1) /*rate*/
      93             :   {
      94         568 :     if (_dt != 0)
      95             :     {
      96         536 :       value_primary = (computeScalarMaterialProperty(&_prop, qp) -
      97         536 :                        computeScalarMaterialProperty(_prop_old, qp)) /
      98         536 :                       _dt;
      99         536 :       value_secondary = (computeScalarMaterialProperty(&_prop_neighbor, qp) -
     100         536 :                          computeScalarMaterialProperty(_prop_neighbor_old, qp)) /
     101         536 :                         _dt;
     102             :     }
     103             :   }
     104         568 :   else if (_value_type == 2) /*increment*/
     105             :   {
     106         568 :     value_primary =
     107         568 :         (computeScalarMaterialProperty(&_prop, qp) - computeScalarMaterialProperty(_prop_old, qp));
     108         568 :     value_secondary = (computeScalarMaterialProperty(&_prop_neighbor, qp) -
     109         568 :                        computeScalarMaterialProperty(_prop_neighbor_old, qp));
     110             :   }
     111             :   else
     112           0 :     mooseError("InterfaceQpMaterialPropertyBaseUserObject::computeRealValue the supplied "
     113             :                "value type has not been implemented");
     114             : 
     115        1704 :   return computeInterfaceValueType(value_primary, value_secondary);
     116             : }

Generated by: LCOV version 1.14